Add PR template (#2556) #2419
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@a9aee67fa67426e6b0297fa5bef80600572be153 | |
| id: pixi-lock | |
| - uses: actions/upload-artifact@v7 | |
| 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@a9aee67fa67426e6b0297fa5bef80600572be153 | |
| 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 }} | |
| locked: false # TODO: Remove once v7 of the lock file is removed, or once we stop having external source dependencies https://github.com/Parcels-code/Parcels/pull/2550#issuecomment-4088660238 | |
| 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@v7 | |
| 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@a9aee67fa67426e6b0297fa5bef80600572be153 | |
| 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 }} | |
| locked: false # TODO: Remove once v7 of the lock file is removed, or once we stop having external source dependencies https://github.com/Parcels-code/Parcels/pull/2550#issuecomment-4088660238 | |
| 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@v7 | |
| 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@v7 | |
| with: | |
| name: Testing reports | |
| pattern: "* report *" | |
| typechecking: | |
| name: "TypeChecking: pixi run typing" | |
| runs-on: ubuntu-latest | |
| needs: [cache-pixi-lock] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| - name: Restore cached pixi lockfile | |
| uses: Parcels-code/pixi-lock/restore@a9aee67fa67426e6b0297fa5bef80600572be153 | |
| 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 }} | |
| locked: false # TODO: Remove once v7 of the lock file is removed, or once we stop having external source dependencies https://github.com/Parcels-code/Parcels/pull/2550#issuecomment-4088660238 | |
| cache: true | |
| cache-write: ${{ github.event_name == 'push' && github.ref_name == 'main' }} | |
| - name: Typechecking | |
| run: | # TODO: Remove `|| true` once typechecking is stable | |
| pixi run typing --output-format github || true | |
| 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@a9aee67fa67426e6b0297fa5bef80600572be153 | |
| 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 }} | |
| locked: false # TODO: Remove once v7 of the lock file is removed, or once we stop having external source dependencies https://github.com/Parcels-code/Parcels/pull/2550#issuecomment-4088660238 | |
| cache: true | |
| cache-write: ${{ github.event_name == 'push' && github.ref_name == 'main' }} | |
| - name: Find the alpha version of Parcels | |
| run: pixi run get-parcels-alpha-version >> $GITHUB_ENV | |
| - name: Build Parcels conda package | |
| run: pixi run build-parcels | |
| - if: github.ref == 'refs/heads/main' | |
| run: | | |
| for pkg in $(find output -type f \( -name "*.conda" -o -name "*.tar.bz2" \) ); do | |
| echo "Uploading ${pkg}" | |
| pixi run -e build rattler-build upload prefix -c parcels "${pkg}" | |
| done | |
| env: | |
| PREFIX_API_KEY: ${{ secrets.PREFIX_API_KEY }} |