-
Notifications
You must be signed in to change notification settings - Fork 11
161 lines (131 loc) · 4.07 KB
/
ci.yaml
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
156
157
158
159
160
161
# GitHub Actions Workflow for Continuous Integration
name: CI
on:
workflow_call:
permissions:
contents: read
env:
PYTHON_VIRTUALENV_ACTIVATE: venv/bin/activate
jobs:
pre-build:
name: Pre-Build
runs-on: ubuntu-22.04
steps:
- run: "true"
build:
name: Build
needs:
- pre-build
runs-on: ubuntu-22.04
strategy:
matrix:
python_version:
- "3.8"
- "3.9"
- "3.10"
steps:
- name: Check Out VCS Repository
uses: actions/[email protected]
- name: Set Up Python ${{ matrix.python_version }}
id: set_up_python
uses: actions/[email protected]
with:
python-version: "${{ matrix.python_version }}"
check-latest: true
- name: Create Python Virtual Environment
run: make python-virtualenv PYTHON_VIRTUALENV_DIR="venv"
- name: Restoring/Saving Cache
uses: actions/[email protected]
with:
path: |
.tox
venv
key: py-v1-deps-${{ runner.os }}-${{ steps.set_up_python.outputs.python-version }}-${{ hashFiles('pyproject.toml', 'requirements.txt', 'requirements-dev.txt', 'Makefile', 'make/**.mk') }}
- name: Install Dependencies
run: |
source "$PYTHON_VIRTUALENV_ACTIVATE"
make install-deps-dev
- name: Install Library
run: |
source "$PYTHON_VIRTUALENV_ACTIVATE"
make install-dev
test:
name: Test
needs:
- build
runs-on: ubuntu-22.04
strategy:
matrix:
python_version:
- "3.8"
- "3.9"
- "3.10"
steps:
- name: Check Out VCS Repository
uses: actions/[email protected]
- name: Set Up Python ${{ matrix.python_version }}
id: set_up_python
uses: actions/[email protected]
with:
python-version: "${{ matrix.python_version }}"
check-latest: true
- name: Restoring/Saving Cache
uses: actions/[email protected]
with:
path: |
.tox
venv
key: py-v1-deps-${{ runner.os }}-${{ steps.set_up_python.outputs.python-version }}-${{ hashFiles('pyproject.toml', 'requirements.txt', 'requirements-dev.txt', 'Makefile', 'make/**.mk') }}
fail-on-cache-miss: true
- name: Set Tox Environment
id: set_tox_environment
run: |
# Set Tox environment to the installed Python version.
tox_env=$(
python -c 'import sys; v = sys.version_info; print("py{}{}".format(v.major, v.minor))'
)
echo "tox_env=${tox_env:?}" >> "$GITHUB_OUTPUT"
- name: Test
run: |
source "$PYTHON_VIRTUALENV_ACTIVATE"
make test
env:
TOXENV: ${{ steps.set_tox_environment.outputs.tox_env }}
- name: Lint
run: |
source "$PYTHON_VIRTUALENV_ACTIVATE"
make lint
- name: Test Coverage
run: |
source "$PYTHON_VIRTUALENV_ACTIVATE"
make test-coverage
- name: Test Coverage Report
run: |
source "$PYTHON_VIRTUALENV_ACTIVATE"
make test-coverage-report
- name: Upload coverage reports to Codecov
uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}
directory: ./test-reports/coverage/
fail_ci_if_error: true
- name: Check that compiled Python dependency manifests are up-to-date with their sources
# FIXME: There are issues related to testing with multiple Python versions.
if: ${{ startsWith(steps.set_up_python.outputs.python-version, '3.8.') }}
run: |
source "$PYTHON_VIRTUALENV_ACTIVATE"
make python-deps-sync-check
- name: Store Artifacts
if: ${{ always() }}
uses: actions/[email protected]
with:
name: test_reports_${{ matrix.python_version }}
path: test-reports/
if-no-files-found: warn
post-test:
name: Post-Test
needs:
- test
runs-on: ubuntu-22.04
steps:
- run: "true"