-
Notifications
You must be signed in to change notification settings - Fork 5
155 lines (132 loc) · 4.55 KB
/
tests.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
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) }}