Build and publish docker on every commit. #1790
Workflow file for this run
This file contains 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: Tests | |
on: | |
pull_request: | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
PRIVATE_REPO_ACCESS_TOKEN: ${{ secrets.ACTIONS_PRIVATE_REPO_RO_TOKEN }} | |
STATA_LICENSE: ${{ secrets.STATA_LICENSE }} | |
jobs: | |
check: | |
runs-on: ubuntu-20.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: "actions/setup-python@v5" | |
with: | |
python-version: "3.8" | |
cache: "pip" | |
cache-dependency-path: requirements.*.txt | |
- uses: extractions/setup-just@69d82fb0233557aec017ef13706851d0694e0f1d | |
- name: Check formatting, linting and import sorting | |
run: just check | |
test-job: | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-20.04, ubuntu-22.04, windows-2019, macos-14] | |
# Python 3.8 is what we currently support for running cohortextractor | |
# locally, and 3.9 is what we required for databuilder so we need to make | |
# sure we can run with those | |
python: ["3.8", "3.9", "3.10"] | |
runs-on: ${{ matrix.os }} | |
name: Run test suite | |
env: | |
PYTHON_VERSION: "python${{ matrix.python }}" | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
- name: Set up Python ${{ matrix.python }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python }} | |
cache: "pip" | |
cache-dependency-path: requirements.*.txt | |
- uses: extractions/setup-just@69d82fb0233557aec017ef13706851d0694e0f1d | |
- name: Run actual tests on ${{ matrix.os }} | |
if: ${{ matrix.os == 'ubuntu-20.04' || matrix.os == 'ubuntu-22.04' }} | |
run: | | |
echo "$PYTHON_VERSION" | |
just test -vvv | |
- name: Run actual tests on windows | |
if: ${{ matrix.os == 'windows-2019' }} | |
run: | | |
# windows powershell: set to executable w/o version, as it doesn't have one on windows | |
$Env:PYTHON_VERSION = "python" | |
just test-no-docker -vvv | |
- name: Run actual tests on macos | |
if: ${{ matrix.os == 'macos-14' }} | |
run: just test-no-docker -vvv | |
test-package-build: | |
runs-on: ubuntu-20.04 | |
name: Test we can build PyPI package | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up Python 3.8 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.8 | |
cache: "pip" | |
cache-dependency-path: requirements.*.txt | |
# We need to set this to a valid version string in order to keep pip happy, | |
# but it doesn't really matter what version we use | |
- name: Set version | |
run: echo '1.0' > VERSION | |
- uses: extractions/setup-just@69d82fb0233557aec017ef13706851d0694e0f1d | |
- name: Check the wheel installs and runs | |
run: just package-test wheel | |
- name: Check the sdist installs and runs | |
run: just package-test sdist | |
test-docker: | |
runs-on: ubuntu-20.04 | |
name: Test docker image | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
- name: Set up Just | |
uses: extractions/setup-just@69d82fb0233557aec017ef13706851d0694e0f1d | |
- name: Build image | |
run: just docker/build | |
- name: Run tests in docker-image | |
run: just docker/test | |
test-github-workflow-output: | |
runs-on: ubuntu-20.04 | |
name: Inspect test runner output in the context of a Github Workflow | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up Python 3.8 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.8 | |
cache: "pip" | |
cache-dependency-path: requirements.*.txt | |
- uses: extractions/setup-just@69d82fb0233557aec017ef13706851d0694e0f1d | |
- name: Install dependencies | |
run: just devenv | |
- name: Run equivalent command used by test runner | |
# We don't care if this command succeeds or not, we just want to be able | |
# to look at the output | |
run: | | |
python -m jobrunner.local_run run_all \ | |
--project-dir=tests/fixtures/full_project \ | |
--continue-on-error --timestamps --format-output-for-github \ | |
|| true | |
required-checks: | |
if: always() | |
needs: | |
- check | |
- test-job | |
- test-package-build | |
- test-github-workflow-output | |
runs-on: Ubuntu-latest | |
steps: | |
- name: Decide whether the needed jobs succeeded or failed | |
uses: re-actors/alls-green@05ac9388f0aebcb5727afa17fcccfecd6f8ec5fe # v1.2.2 | |
with: | |
jobs: ${{ toJSON(needs) }} |