CI: cancel previous jobs on PR updates #1284
Workflow file for this run
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: Run Code Checks | |
on: | |
pull_request: | |
push: | |
# When a PR is updated, cancel the jobs from the previous version. Merges | |
# do not define head_ref, so use run_id to never cancel those jobs. | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | |
cancel-in-progress: true | |
jobs: | |
build-wheels: | |
timeout-minutes: 15 | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- name: Setup Python | |
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0 | |
with: | |
python-version: "3.10" | |
- name: Install Dependencies | |
run: | | |
python -m pip install --upgrade build | |
python -m pip freeze | |
- name: Build Clean Packages | |
run: | | |
mkdir -p ./wheels/clean | |
python -m build | |
mv dist/* ./wheels/clean/ | |
find ./wheels/clean -type f | |
- name: Upload wheels as artifacts | |
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 | |
with: | |
name: wheels | |
path: ./wheels/clean/ | |
retention-days: 1 | |
build-test-env-base: | |
timeout-minutes: 15 | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4 | |
id: conda_cache | |
with: | |
path: /tmp/test_env | |
key: ${{ runner.os }}-test-env-py310-${{ hashFiles('tests/test-env-py310.yml') }} | |
- uses: conda-incubator/setup-miniconda@835234971496cad1653abb28a638a281cf32541f # v3.2.0 | |
if: steps.conda_cache.outputs.cache-hit != 'true' | |
with: | |
miniforge-version: latest | |
channels: conda-forge,defaults | |
activate-environment: "" | |
- name: Dump Conda Environment Info | |
shell: bash -l {0} | |
if: steps.conda_cache.outputs.cache-hit != 'true' | |
run: | | |
conda info | |
conda list | |
mamba --version | |
conda config --show-sources | |
conda config --show | |
printenv | sort | |
- name: Build Python Environment for Testing | |
shell: bash -l {0} | |
if: steps.conda_cache.outputs.cache-hit != 'true' | |
run: | | |
mamba env create -f tests/test-env-py310.yml -p /tmp/test_env | |
- name: Check Python Env | |
shell: bash -l {0} | |
if: steps.conda_cache.outputs.cache-hit != 'true' | |
run: | | |
mamba env export -p /tmp/test_env | |
run-black-check: | |
timeout-minutes: 15 | |
runs-on: ubuntu-latest | |
needs: | |
- build-test-env-base | |
steps: | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- name: Get Conda Environment from Cache | |
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4 | |
id: conda_cache | |
with: | |
path: /tmp/test_env | |
key: ${{ runner.os }}-test-env-py310-${{ hashFiles('tests/test-env-py310.yml') }} | |
- name: Update PATH | |
shell: bash | |
run: | | |
echo "/tmp/test_env/bin" >> $GITHUB_PATH | |
- name: Check formatting (black) | |
shell: bash | |
run: | | |
black --check . | |
run-pylint: | |
timeout-minutes: 15 | |
runs-on: ubuntu-latest | |
needs: | |
- build-test-env-base | |
steps: | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- name: Get Conda Environment from Cache | |
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4 | |
id: conda_cache | |
with: | |
path: /tmp/test_env | |
key: ${{ runner.os }}-test-env-py310-${{ hashFiles('tests/test-env-py310.yml') }} | |
- name: Update PATH | |
shell: bash | |
run: | | |
echo "/tmp/test_env/bin" >> $GITHUB_PATH | |
- name: Install in Edit mode | |
shell: bash | |
run: | | |
pip install -e . --no-deps | |
- name: Check with pylint | |
shell: bash | |
run: | | |
pylint -v odc | |
run-mypy: | |
timeout-minutes: 15 | |
runs-on: ubuntu-latest | |
needs: | |
- build-test-env-base | |
steps: | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- name: Get Conda Environment from Cache | |
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4 | |
id: conda_cache | |
with: | |
path: /tmp/test_env | |
key: ${{ runner.os }}-test-env-py310-${{ hashFiles('tests/test-env-py310.yml') }} | |
- name: Update PATH | |
shell: bash | |
run: | | |
echo "/tmp/test_env/bin" >> $GITHUB_PATH | |
- name: Check with mypy | |
shell: bash | |
run: | | |
mypy --explicit-package-bases --python-version 3.10 odc | |
test-with-coverage: | |
timeout-minutes: 15 | |
runs-on: ubuntu-latest | |
permissions: | |
id-token: write | |
needs: | |
- build-test-env-base | |
- run-black-check | |
steps: | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- name: Get Conda Environment from Cache | |
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4 | |
id: conda_cache | |
with: | |
path: /tmp/test_env | |
key: ${{ runner.os }}-test-env-py310-${{ hashFiles('tests/test-env-py310.yml') }} | |
- name: Update PATH | |
shell: bash | |
run: | | |
echo "/tmp/test_env/bin" >> $GITHUB_PATH | |
- name: Install in Edit mode | |
shell: bash | |
run: | | |
pip install -e . --no-deps | |
- name: Run Tests | |
shell: bash | |
run: | | |
echo "Running Tests" | |
pytest --cov=odc \ | |
--cov-report=html \ | |
--cov-report=term \ | |
--cov-report=xml:coverage.xml \ | |
--timeout=30 \ | |
tests | |
env: | |
DASK_TEMPORARY_DIRECTORY: /tmp/dask | |
- name: Upload Coverage | |
if: | | |
github.repository == 'opendatacube/odc-geo' | |
uses: codecov/codecov-action@18283e04ce6e62d37312384ff67231eb8fd56d24 # v5.4.3 | |
with: | |
fail_ci_if_error: false | |
verbose: false | |
use_oidc: true | |
test-wheels: | |
timeout-minutes: 15 | |
runs-on: ubuntu-latest | |
needs: | |
- build-test-env-base | |
- run-black-check | |
- build-wheels | |
steps: | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- name: Download wheels from artifacts | |
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0 | |
with: | |
name: wheels | |
path: ./wheels/clean | |
- name: Get Conda Environment from Cache | |
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4 | |
id: conda_cache | |
with: | |
path: /tmp/test_env | |
key: ${{ runner.os }}-test-env-py310-${{ hashFiles('tests/test-env-py310.yml') }} | |
- name: Update PATH | |
shell: bash | |
run: | | |
echo "/tmp/test_env/bin" >> $GITHUB_PATH | |
- name: Install wheels for testing | |
shell: bash | |
run: | | |
which python | |
ls -lh wheels/clean | |
python -m pip install --no-deps wheels/clean/*whl | |
python -m pip check || true | |
- name: Run Tests | |
shell: bash | |
run: | | |
echo "Running Tests" | |
pytest --timeout=30 tests | |
env: | |
DASK_TEMPORARY_DIRECTORY: /tmp/dask | |
check-docs: | |
timeout-minutes: 15 | |
runs-on: ubuntu-latest | |
needs: | |
- build-test-env-base | |
- run-black-check | |
steps: | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- name: Get Conda Environment from Cache | |
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4 | |
id: conda_cache | |
with: | |
path: /tmp/test_env | |
key: ${{ runner.os }}-test-env-py310-${{ hashFiles('tests/test-env-py310.yml') }} | |
- name: Update PATH | |
shell: bash | |
run: | | |
echo "/tmp/test_env/bin" >> $GITHUB_PATH | |
- name: Install in Edit mode | |
shell: bash | |
run: | | |
pip install -e . --no-deps | |
- name: Build docs | |
shell: bash | |
run: | | |
make -C docs html | |
- name: Deploy to Netlify | |
id: netlify | |
if: github.event_name == 'pull_request' | |
uses: nwtgck/actions-netlify@4cbaf4c08f1a7bfa537d6113472ef4424e4eb654 # v3.0.0 | |
with: | |
production-branch: "main" | |
publish-dir: "docs/_build/html" | |
deploy-message: "Deploy from GitHub Actions" | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
enable-pull-request-comment: true | |
enable-commit-comment: false | |
env: | |
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} | |
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} | |
- name: Print Notice | |
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 | |
if: github.event_name == 'pull_request' | |
env: | |
NETLIFY_URL: ${{ steps.netlify.outputs.deploy-url }} | |
with: | |
script: | | |
const {NETLIFY_URL} = process.env | |
core.notice(`Published to: ${NETLIFY_URL}`) |