Merge pull request #2505 from Parcels-code/patch/ux-uv-uvw #2304
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: ci | |
| on: | |
| push: | |
| branches: | |
| - "main" | |
| - "test-me/*" | |
| pull_request: | |
| concurrency: | |
| group: branch-${{ github.head_ref }} | |
| cancel-in-progress: true | |
| defaults: | |
| run: | |
| shell: bash -el {0} | |
| jobs: | |
| should-run-ci: | |
| name: should run ci | |
| runs-on: ubuntu-slim | |
| if: | | |
| github.repository == 'Parcels-code/Parcels' | |
| && (github.event_name == 'push' || github.event_name == 'pull_request') | |
| steps: | |
| - uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 2 | |
| - uses: xarray-contrib/ci-trigger@v1 | |
| id: check-skip | |
| with: | |
| keyword: "[skip-ci]" | |
| - name: Decide if we skip CI | |
| if: steps.check-skip.outputs.trigger-found == 'true' || contains(github.event.pull_request.labels.*.name, 'skip-ci') | |
| run: | | |
| echo "Skipping CI." | |
| exit 1 | |
| cache-pixi-lock: | |
| runs-on: ubuntu-latest | |
| needs: [should-run-ci] | |
| outputs: | |
| cache-key: ${{ steps.pixi-lock.outputs.cache-key }} | |
| pixi-version: ${{ steps.pixi-lock.outputs.pixi-version }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: Parcels-code/pixi-lock/create-and-cache@2b823a4a804631370fbde7e6088ee5db71a26c60 | |
| id: pixi-lock | |
| - uses: actions/upload-artifact@v6 | |
| with: | |
| name: pixi-lock | |
| path: pixi.lock | |
| unit-test: | |
| name: "Unit tests: ${{ matrix.os }} | pixi run -e ${{ matrix.pixi-environment }} tests" | |
| runs-on: ${{ matrix.os }}-latest | |
| needs: [cache-pixi-lock] | |
| env: | |
| COVERAGE_REPORT: "${{ matrix.os }}_${{ matrix.pixi-environment }}_unit_test_report.html" | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu, windows] | |
| pixi-environment: [test] | |
| include: | |
| - os: ubuntu | |
| pixi-environment: "test-py311" | |
| - os: ubuntu | |
| pixi-environment: "test-py313" | |
| - os: ubuntu | |
| pixi-environment: "test-minimum" | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Restore cached pixi lockfile | |
| uses: Parcels-code/pixi-lock/restore@2b823a4a804631370fbde7e6088ee5db71a26c60 # TODO: Update to action in prefix-dev once available | |
| with: | |
| cache-key: ${{ needs.cache-pixi-lock.outputs.cache-key }} | |
| - uses: prefix-dev/setup-pixi@v0.9.0 | |
| with: | |
| pixi-version: ${{ needs.cache-pixi-lock.outputs.pixi-version }} | |
| cache: true | |
| cache-write: ${{ github.event_name == 'push' && github.ref_name == 'main' }} | |
| # https://github.com/actions/cache/blob/main/tips-and-workarounds.md#update-a-cache | |
| - name: Restore cached hypothesis directory | |
| id: restore-hypothesis-cache | |
| uses: actions/cache/restore@v4 | |
| with: | |
| path: .hypothesis/ | |
| key: cache-hypothesis-${{ runner.os }}-${{ github.run_id }} | |
| restore-keys: | | |
| cache-hypothesis-${{ runner.os }}- | |
| - name: Unit test | |
| id: unit-test | |
| run: | | |
| pixi run -e ${{ matrix.pixi-environment }} tests -v -s --cov=parcels --cov-report=xml --html="${{ env.COVERAGE_REPORT }}" --self-contained-html | |
| # explicitly save the cache so it gets updated, also do this even if it fails. | |
| - name: Save cached hypothesis directory | |
| id: save-hypothesis-cache | |
| if: always() && steps.unit-test.outcome != 'skipped' | |
| uses: actions/cache/save@v4 | |
| with: | |
| path: .hypothesis/ | |
| key: cache-hypothesis-${{ runner.os }}-${{ github.run_id }} | |
| - name: Codecov | |
| uses: codecov/codecov-action@v5.5.1 | |
| env: | |
| CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | |
| with: | |
| flags: unit-tests | |
| - name: Upload test results | |
| if: ${{ always() }} # Always run this step, even if tests fail | |
| uses: actions/upload-artifact@v5 | |
| with: | |
| name: Unittest report ${{ matrix.os }}-${{ matrix.pixi-environment }} | |
| path: ${{ env.COVERAGE_REPORT }} | |
| integration-test: | |
| name: "Integration: ${{ matrix.os }} | pixi run -e ${{ matrix.pixi-environment }} tests-notebooks" | |
| runs-on: ${{ matrix.os }}-latest | |
| needs: [cache-pixi-lock] | |
| # TODO v4: Re-enable the workflow once development has stabilized and we want to run integration tests again | |
| if: false | |
| env: | |
| COVERAGE_REPORT: "${{ matrix.os }}_${{ matrix.pixi-environment }}_integration_test_report.html" | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu] #, mac, windows] # TODO v4: Re-enable windows and mac | |
| python-version: ["3.12"] | |
| include: | |
| - os: ubuntu | |
| python-version: "3.11" | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Restore cached pixi lockfile | |
| uses: Parcels-code/pixi-lock/restore@2b823a4a804631370fbde7e6088ee5db71a26c60 # TODO: Update to action in prefix-dev once available | |
| with: | |
| cache-key: ${{ needs.cache-pixi-lock.outputs.cache-key }} | |
| - uses: prefix-dev/setup-pixi@v0.9.0 | |
| with: | |
| pixi-version: ${{ needs.cache-pixi-lock.outputs.pixi-version }} | |
| cache: true | |
| cache-write: ${{ github.event_name == 'push' && github.ref_name == 'main' }} | |
| - name: Integration test | |
| run: | | |
| pixi run test-notebooks -v -s --html="${{ env.COVERAGE_REPORT }}" --self-contained-html --cov=parcels --cov-report=xml | |
| - name: Codecov | |
| uses: codecov/codecov-action@v5.5.1 | |
| env: | |
| CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | |
| with: | |
| flags: integration-tests | |
| - name: Upload test results | |
| if: ${{ always() }} # Always run this step, even if tests fail | |
| uses: actions/upload-artifact@v5 | |
| with: | |
| name: Integration test report ${{ matrix.os }}-${{ matrix.pixi-environment }} | |
| path: ${{ env.COVERAGE_REPORT }} | |
| merge-test-artifacts: | |
| runs-on: ubuntu-latest | |
| needs: | |
| - unit-test | |
| - integration-test | |
| - typechecking | |
| steps: | |
| - name: Merge Artifacts | |
| uses: actions/upload-artifact/merge@v5 | |
| with: | |
| name: Testing reports | |
| pattern: "* report *" | |
| typechecking: | |
| name: "TypeChecking: pixi run typing" | |
| runs-on: ubuntu-latest | |
| needs: [cache-pixi-lock] | |
| # TODO v4: Enable typechecking again | |
| if: false | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| - name: Restore cached pixi lockfile | |
| uses: Parcels-code/pixi-lock/restore@2b823a4a804631370fbde7e6088ee5db71a26c60 # TODO: Update to action in prefix-dev once available | |
| with: | |
| cache-key: ${{ needs.cache-pixi-lock.outputs.cache-key }} | |
| - uses: prefix-dev/setup-pixi@v0.9.0 | |
| with: | |
| pixi-version: ${{ needs.cache-pixi-lock.outputs.pixi-version }} | |
| cache: true | |
| cache-write: ${{ github.event_name == 'push' && github.ref_name == 'main' }} | |
| - name: Typechecking | |
| run: | | |
| pixi run typing --non-interactive --html-report mypy-report | |
| - name: Upload test results | |
| if: ${{ always() }} # Upload even on mypy error | |
| uses: actions/upload-artifact@v5 | |
| with: | |
| name: Mypy report | |
| path: mypy-report | |
| build-and-upload-nightly-parcels: # for alpha testing | |
| needs: [cache-pixi-lock] | |
| permissions: | |
| contents: read | |
| id-token: write | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| - name: Restore cached pixi lockfile | |
| uses: Parcels-code/pixi-lock/restore@2b823a4a804631370fbde7e6088ee5db71a26c60 # TODO: Update to action in prefix-dev once available | |
| with: | |
| cache-key: ${{ needs.cache-pixi-lock.outputs.cache-key }} | |
| - uses: prefix-dev/setup-pixi@v0.9.0 | |
| with: | |
| pixi-version: ${{ needs.cache-pixi-lock.outputs.pixi-version }} | |
| cache: true | |
| cache-write: ${{ github.event_name == 'push' && github.ref_name == 'main' }} | |
| - run: pixi run get-parcels-alpha-version >> $GITHUB_ENV | |
| - run: echo "PARCELS_ALPHA_VERSION is $PARCELS_ALPHA_VERSION" | |
| - name: Build conda package | |
| uses: prefix-dev/rattler-build-action@v0.2.34 | |
| with: | |
| recipe-path: .github/ci/recipe.yaml | |
| - if: github.ref == 'refs/heads/main' | |
| run: | | |
| for pkg in $(find output -type f \( -name "*.conda" -o -name "*.tar.bz2" \) ); do | |
| echo "Uploading ${pkg}" | |
| rattler-build upload prefix -c parcels "${pkg}" | |
| done | |
| env: | |
| PREFIX_API_KEY: ${{ secrets.PREFIX_API_KEY }} |