Skip to content

Fix docker image to actually work #1731

Fix docker image to actually work

Fix docker image to actually work #1731

Workflow file for this run

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-22.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:
matrix:
os: [ubuntu-22.04, windows-2019, macos-12]
# 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
- name: Set up default Python 3.8 for MacOS
if: ${{ matrix.os == 'macos-12' && matrix.python != '3.8' }}
uses: actions/setup-python@v5
with:
python-version: 3.8
cache: "pip"
cache-dependency-path: requirements.*.txt
- name: install Docker/Colima on MacOS
if: ${{ matrix.os == 'macos-12' }}
run: brew install docker
- name: start Colima on MacOS
if: ${{ matrix.os == 'macos-12' }}
run: colima start
- uses: extractions/setup-just@69d82fb0233557aec017ef13706851d0694e0f1d
- name: Run actual tests on linux
if: ${{ matrix.os == 'ubuntu-22.04' }}
run: |
echo "$PYTHON_VERSION"
just test -vvv
- name: Run actual tests on windows
if: ${{ matrix.os == 'windows-2019' }}
run: |
# multiple versions not supported
export PYTHON_VERSION=python
just test-no-docker -vvv
- name: Run actual tests on macos
if: ${{ matrix.os == 'macos-12' }}
run: |
echo "$PYTHON_VERSION"
just test-no-docker -vvv
test-package-build:
runs-on: ubuntu-22.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-22.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
- name: Run functional test
run: just docker/functional-test
test-github-workflow-output:
runs-on: ubuntu-22.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) }}