Skip to content

chore: set safer bash config #1594

chore: set safer bash config

chore: set safer bash config #1594

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-20.04
steps:
- uses: actions/checkout@v3
- uses: "actions/setup-python@v4"
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-20.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]
runs-on: ${{ matrix.os }}
name: Run test suite
steps:
- name: Checkout
uses: actions/checkout@v3
with:
persist-credentials: false
- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v4
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@v4
with:
python-version: 3.8
cache: "pip"
cache-dependency-path: requirements.*.txt
- name: install Docker/Colima on MacOS
if: ${{ matrix.os == 'macos-12' }}
run: |
# https://github.com/opensafely-core/job-server/issues/3429
brew remove --ignore-dependencies qemu
curl -o ./qemu.rb https://raw.githubusercontent.com/Homebrew/homebrew-core/dc0669eca9479e9eeb495397ba3a7480aaa45c2e/Formula/qemu.rb
brew install ./qemu.rb
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 ${{ matrix.os }}
if: ${{ matrix.os == 'ubuntu-20.04' }}
run: just test -vvv
- name: Run actual tests on ${{ matrix.os }}
if: ${{ matrix.os == 'windows-2019' || matrix.os == 'macos-12' }}
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@v3
with:
fetch-depth: 0
- name: Set up Python 3.8
uses: actions/setup-python@v4
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@v3
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@v3
- name: Set up Python 3.8
uses: actions/setup-python@v4
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) }}