diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ef022f4d8..409c556cf 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,162 +1,13 @@ name: Tests -on: [push] +on: [push, pull_request] +# Unit tests are defined once, centrally, in PyAutoPulse's reusable workflow +# (Pulse owns all health/readiness checking). This thin caller preserves PR-time +# gating: the `unittest` job is the required status check on this repo. jobs: unittest: - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - python-version: ['3.12', '3.13'] - steps: - - name: Checkout PyAutoConf - uses: actions/checkout@v2 - with: - repository: PyAutoLabs/PyAutoConf - path: PyAutoConf - - name: Checkout PyAutoFit - uses: actions/checkout@v2 - with: - path: PyAutoFit - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - uses: actions/cache@v3 - id: cache-pip - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} - restore-keys: | - ${{ runner.os }}-pip- - - name: Extract branch name - shell: bash - run: | - cd PyAutoFit - echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})" - id: extract_branch - - name: Change to same branch if exists in deps - shell: bash - run: | - export PACKAGES=("PyAutoConf") - export BRANCH="${{ steps.extract_branch.outputs.branch }}" - for PACKAGE in ${PACKAGES[@]}; do - pushd $PACKAGE - export existed_in_remote=$(git ls-remote --heads origin ${BRANCH}) - if [[ -z ${existed_in_remote} ]]; then - echo "Branch $BRANCH did not exist in $PACKAGE" - else - echo "Branch $BRANCH did exist in $PACKAGE" - git fetch - git checkout $BRANCH - fi - popd - done - - name: Install dependencies - # if: steps.cache-pip.outputs.cache-hit != 'true' - run: | - pip3 install --upgrade pip - pip3 install setuptools - pip3 install wheel - pip3 install pytest coverage pytest-cov - pip install ./PyAutoConf "./PyAutoFit[optional]" - - name: Run tests - run: | - export ROOT_DIR=`pwd` - export PYTHONPATH=$PYTHONPATH:$ROOT_DIR/PyAutoConf - export PYTHONPATH=$PYTHONPATH:$ROOT_DIR/PyAutoFit - pushd PyAutoFit - # The NSS test suite (test_autofit/non_linear/search/nest/nss/) runs in - # the parallel `unittest_nss` job below — it needs the handley-lab - # blackjax fork from the [nss] extra, which conflicts with the - # blackjax>=1.2.0 mainline pinned in [optional]. - if [ "${{ matrix.python-version }}" = "3.13" ]; then - pytest --cov autofit --cov-report xml:coverage.xml \ - --ignore=test_autofit/non_linear/search/nest/nss \ - --ignore=test_autofit/database/test_file_types.py \ - --ignore=test_autofit/non_linear/paths/test_save_and_load.py \ - --ignore=test_autofit/aggregator/summary_files/test_aggregate_fits.py \ - --ignore=test_autofit/aggregator/test_child_analysis.py \ - --ignore=test_autofit/aggregator/test_reference.py \ - --ignore=test_autofit/aggregator/test_scrape.py \ - --ignore=test_autofit/graphical/gaussian/test_optimizer.py \ - --ignore=test_autofit/graphical/hierarchical/test_optimise.py \ - --ignore=test_autofit/non_linear/search/test_sneaky_map.py \ - --deselect "test_autofit/graphical/test_composition.py::test_other_priors[LogUniformPrior]" \ - --deselect "test_autofit/mapper/prior/test_prior.py::TestLogUniformPrior::test__non_zero_lower_limit" - else - pytest --cov autofit --cov-report xml:coverage.xml \ - --ignore=test_autofit/non_linear/search/nest/nss - fi - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v3 - - name: Slack send - if: ${{ failure() }} - id: slack - uses: slackapi/slack-github-action@v1.21.0 - env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} - with: - channel-id: C03S98FEDK2 - payload: | - { - "text": "${{ github.repository }}/${{ github.ref_name }} (Python ${{ matrix.python-version }}) build result: ${{ job.status }}\n${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" - } - - unittest_nss: - # NSS tests live in their own job because the [nss] extra pins the - # handley-lab/blackjax fork (BSD-3-Clause, ~0.1.0b1.dev85+gef45acd2f), - # which is mutually incompatible with the mainline `blackjax>=1.2.0` - # that the `[optional]` extra (and `test_blackjax_nuts.py`) requires. - # Two envs in parallel keep both test families green without forcing a - # choice between them. - name: NSS tests (fork blackjax) - runs-on: ubuntu-latest - timeout-minutes: 20 - strategy: - fail-fast: false - matrix: - python-version: ['3.12', '3.13'] - steps: - - name: Checkout PyAutoConf - uses: actions/checkout@v4 - with: - repository: PyAutoLabs/PyAutoConf - path: PyAutoConf - - name: Checkout PyAutoFit - uses: actions/checkout@v4 - with: - path: PyAutoFit - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - pip install --upgrade pip - pip install pytest pytest-cov - pip install ./PyAutoConf "./PyAutoFit[nss]" - # blackjax (handley-lab fork) and yallup/nss can't live in the [nss] - # extra — PyPI bans direct git+ URLs in uploaded wheel metadata. - # Install them post-extras instead. SHAs are the single source of - # truth in PyAutoFit/pyproject.toml's [nss] comment — keep in sync. - pip install \ - "blackjax @ git+https://github.com/handley-lab/blackjax.git@ef45acd2f2fa0cca15adbdcd3ff7cb3a98987cb5" \ - "nss @ git+https://github.com/yallup/nss.git@69159b0f4a3a53123b9eec7df91e4ed3885e4dc4" - - name: Run NSS tests - run: | - export PYTHONPATH=$PWD/PyAutoConf:$PWD/PyAutoFit - pushd PyAutoFit - pytest test_autofit/non_linear/search/nest/nss - - name: Slack send - if: ${{ failure() }} - uses: slackapi/slack-github-action@v1.21.0 - env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} - with: - channel-id: C03S98FEDK2 - payload: | - { - "text": "${{ github.repository }}/${{ github.ref_name }} NSS tests (Python ${{ matrix.python-version }}) result: ${{ job.status }}\n${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" - } \ No newline at end of file + uses: PyAutoLabs/PyAutoPulse/.github/workflows/lib-tests.yml@main + with: + package: autofit + secrets: inherit