Skip to content

Fix the collector job #39

Fix the collector job

Fix the collector job #39

Workflow file for this run

name: Test
on: [push, pull_request]
permissions:
contents: read
jobs:
pytest-conda:
name: pytest (conda)
strategy:
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
python-version:
# - '3.13t'
- '3.13'
- '3.12'
- '3.11'
- '3.10'
- '3.9'
- '3.8'
- '3.7'
exclude:
- os: macos-latest
python-version: '3.7'
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash -l {0}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Substitute Python version
run: |
perl -i -spwe 's/^ *- python=\K.+$/$pyver/' -- \
-pyver=${{ matrix.python-version }} environment.yml
- name: Set up micromamba
uses: mamba-org/setup-micromamba@v2
with:
environment-file: environment.yml
- name: Run all tests
run: pytest --doctest-modules
timeout-minutes: 2
pytest-pipenv-lock:
name: pytest (Pipfile.lock)
strategy:
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.11
- name: Upgrade PyPA packages
run: python -m pip install -U pip setuptools wheel
- name: Install pipenv
run: pip install pipenv
- name: Install project with all dependencies
run: pipenv install -d
- name: Run all tests
run: pipenv run pytest --doctest-modules
timeout-minutes: 2
pytest-pipenv:
name: pytest (Pipfile)
strategy:
matrix:
os:
- ubuntu-latest
- ubuntu-22.04
- macos-latest
# - windows-latest
python-version:
# - '3.13t'
- '3.13'
- '3.12'
- '3.11'
- '3.10'
- '3.9'
- '3.8'
- '3.7'
exclude:
# Don't test Python 3.7 on Ubuntu >= 24.04 LTS.
- os: ubuntu-latest
python-version: '3.7'
# Only test Python 3.7 on Ubuntu 22.04 LTS.
- os: ubuntu-22.04
python-version: '3.13'
- os: ubuntu-22.04
python-version: '3.12'
- os: ubuntu-22.04
python-version: '3.11'
- os: ubuntu-22.04
python-version: '3.10'
- os: ubuntu-22.04
python-version: '3.9'
- os: ubuntu-22.04
python-version: '3.8'
# Don't test Python 3.7 on macOS.
- os: macos-latest
python-version: '3.7'
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Remove Pipfile.lock
run: rm Pipfile.lock
- name: Drop full Python version
run: |
perl -i -nwe 'print unless /^python_full_version = "[^"]+"$/' Pipfile
- name: Substitute Python version
run: |
perl -i -spwe 's/^python_version = "\K[^"]+(?="$)/$pyver/' -- \
-pyver=${{ matrix.python-version }} Pipfile
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Upgrade PyPA packages
run: python -m pip install -U pip setuptools wheel
- name: Install pipenv
run: pip install pipenv
- name: Install project with all dependencies
run: pipenv install -d
- name: Run all tests
run: pipenv run pytest --doctest-modules
timeout-minutes: 2
lint:
name: Lint (flake8)
runs-on: ubuntu-latest
steps:
- name: Check out source repository
uses: actions/checkout@v4
- name: Set up Python environment
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: flake8 Lint
uses: py-actions/flake8@v2
shellcheck:
name: ShellCheck
runs-on: ubuntu-latest
steps:
- name: Check out source repository
uses: actions/checkout@v4
- name: Analyze shell scripts
uses: bewuethr/shellcheck-action@v2
# Check that only jobs intended not to block PR auto-merge are omitted as
# dependencies of the `all-pass` job below, so that whenever a job is added,
# a decision is made about whether it must pass for PRs to merge.
all-pass-meta:
runs-on: ubuntu-latest
env:
# List all jobs that are intended NOT to block PR auto-merge here.
EXPECTED_NONBLOCKING_JOBS: |-
all-pass
defaults:
run:
shell: bash
steps:
- name: Find this workflow
run: |
relative_workflow_with_ref="${GITHUB_WORKFLOW_REF#"$GITHUB_REPOSITORY/"}"
echo "WORKFLOW_PATH=${relative_workflow_with_ref%@*}" >> "$GITHUB_ENV"
- uses: actions/checkout@v4
with:
sparse-checkout: ${{ env.WORKFLOW_PATH }}
- name: Get all jobs
run: yq '.jobs | keys.[]' -- "$WORKFLOW_PATH" | sort | tee all-jobs.txt
- name: Get blocking jobs
run: yq '.jobs.all-pass.needs.[]' -- "$WORKFLOW_PATH" | sort | tee blocking-jobs.txt
- name: Get jobs we intend do not block
run: sort <<<"$EXPECTED_NONBLOCKING_JOBS" | tee expected-nonblocking-jobs.txt
- name: Each job must block PRs or be declared not to
run: |
sort -m blocking-jobs.txt expected-nonblocking-jobs.txt |
diff --color=always -U1000 - all-jobs.txt
all-pass:
name: All tests pass
needs:
- pytest-conda
- pytest-pipenv-lock
- pytest-pipenv
- lint
- shellcheck
- all-pass-meta
runs-on: ubuntu-latest
# Don't skip `all-pass` on cancellation, since a skipped required check won't block auto-merge.
if: always()
steps:
- name: Some failed
if: contains(needs.*.result, 'cancelled') || contains(needs.*.result, 'failure')
run: |
false
- name: All passed
run: |
true