Skip to content

Commit 58a99a1

Browse files
committed
Add Github Actions configuration
This was shamelessly ripped from https://github.com/twisted/klein/blob/7256d04caf3860e6f3703c02440f4088b545fd18/.github/workflows/cicd.yml with minor modifications.
1 parent 22bf592 commit 58a99a1

File tree

1 file changed

+240
-0
lines changed

1 file changed

+240
-0
lines changed

.github/workflows/cicd.yml

Lines changed: 240 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,240 @@
1+
# Docs:
2+
# https://help.github.com/en/actions/automating-your-workflow-with-github-actions
3+
4+
5+
6+
name: CI/CD
7+
8+
9+
on:
10+
push:
11+
branches: ["master"]
12+
pull_request:
13+
branches: ["master"]
14+
15+
16+
jobs:
17+
18+
info:
19+
20+
name: Workflow information
21+
runs-on: ubuntu-latest
22+
timeout-minutes: 1
23+
24+
steps:
25+
26+
- name: Print GitHub Context
27+
env:
28+
GITHUB_CONTEXT: ${{ toJson(github) }}
29+
run: echo "${GITHUB_CONTEXT}";
30+
31+
- name: Print Job Context
32+
env:
33+
JOB_CONTEXT: ${{ toJson(job) }}
34+
run: echo "${JOB_CONTEXT}";
35+
36+
- name: Print Steps Context
37+
env:
38+
STEPS_CONTEXT: ${{ toJson(steps) }}
39+
run: echo "${STEPS_CONTEXT}";
40+
41+
- name: Print Runner Context
42+
env:
43+
RUNNER_CONTEXT: ${{ toJson(runner) }}
44+
run: echo "${RUNNER_CONTEXT}";
45+
46+
- name: Print Strategy Context
47+
env:
48+
STRATEGY_CONTEXT: ${{ toJson(strategy) }}
49+
run: echo "${STRATEGY_CONTEXT}";
50+
51+
- name: Print Matrix Context
52+
env:
53+
MATRIX_CONTEXT: ${{ toJson(matrix) }}
54+
run: echo "${MATRIX_CONTEXT}";
55+
56+
57+
flake8:
58+
59+
name: Flake8 (linter)
60+
61+
runs-on: ubuntu-latest
62+
timeout-minutes: 5
63+
64+
steps:
65+
66+
- name: Checkout source code
67+
uses: actions/checkout@v2
68+
69+
- name: Install Python
70+
uses: actions/setup-python@v1
71+
with:
72+
python-version: "3.9"
73+
74+
- name: Install Tox
75+
run: pip install tox;
76+
77+
- name: Run Flake8
78+
run: tox -e flake8;
79+
80+
81+
black:
82+
83+
name: Black (linter)
84+
85+
runs-on: ubuntu-latest
86+
timeout-minutes: 5
87+
88+
steps:
89+
90+
- name: Checkout source code
91+
uses: actions/checkout@v2
92+
93+
- name: Install Python
94+
uses: actions/setup-python@v1
95+
with:
96+
python-version: "3.9"
97+
98+
- name: Install Tox
99+
run: pip install tox;
100+
101+
- name: Run Black
102+
run: tox -e black;
103+
104+
105+
mypy:
106+
name: Mypy (static type checker)
107+
108+
runs-on: ubuntu-latest
109+
timeout-minutes: 5
110+
111+
steps:
112+
113+
- name: Checkout source code
114+
uses: actions/checkout@v2
115+
116+
- name: Install Python
117+
uses: actions/setup-python@v1
118+
with:
119+
python-version: "3.9"
120+
121+
- name: Install Tox
122+
run: pip install tox;
123+
124+
- name: Run Mypy
125+
run: tox -e mypy;
126+
127+
128+
docs:
129+
130+
name: Build documentation
131+
132+
runs-on: ubuntu-latest
133+
timeout-minutes: 5
134+
135+
steps:
136+
137+
- name: Checkout source code
138+
uses: actions/checkout@v2
139+
140+
- name: Install Python
141+
uses: actions/setup-python@v1
142+
with:
143+
python-version: "3.9"
144+
145+
- name: Install Tox
146+
run: pip install tox;
147+
148+
- name: Build documentation
149+
run: tox -e docs;
150+
151+
152+
packaging:
153+
name: Packaging
154+
155+
runs-on: ubuntu-latest
156+
timeout-minutes: 5
157+
158+
steps:
159+
160+
- name: Checkout source code
161+
uses: actions/checkout@v2
162+
163+
- name: Install Python
164+
uses: actions/setup-python@v1
165+
with:
166+
python-version: "3.9"
167+
168+
- name: Install Tox
169+
run: pip install tox;
170+
171+
- name: Check packaging
172+
run: tox -e packaging;
173+
174+
175+
unit:
176+
name: Unit Tests using Python ${{ matrix.python }} on Ubuntu
177+
178+
needs: [flake8, black, mypy, docs, packaging]
179+
180+
runs-on: ubuntu-latest
181+
timeout-minutes: 30
182+
strategy:
183+
matrix:
184+
python: ["2.7", "3.4", "3.5", "3.6", "3.7", "3.8", "3.9", "pypy-2.7", "pypy-3.7"]
185+
186+
steps:
187+
188+
- name: Checkout source code
189+
uses: actions/checkout@v2
190+
191+
- name: Install Python
192+
uses: actions/setup-python@v1
193+
with:
194+
python-version: ${{ matrix.python }}
195+
196+
- name: Install Tox
197+
run: pip install tox;
198+
199+
- name: Run unit tests
200+
shell: bash
201+
# This hairy shell code is here to map the Python versions
202+
# specified above to the equivalents used in Tox environments.
203+
run: |
204+
set -eux
205+
py="${{ matrix.python }}";
206+
if [[ $py =~ pypy ]]; then # PyPy
207+
py_test="pypy${py:5:1}"; # Add "pypy" prefix, select major version
208+
else # CPython
209+
py_test="py${py/./}"; # Add "py" prefix, remove "."
210+
fi;
211+
env_test="test-${py_test},codecov";
212+
echo "Test environment: ${env_test}";
213+
ln -s ".tox/${env_test}" testenv; # Fixed location for upload step below
214+
tox -e "${env_test}";
215+
216+
# Use the latest supported Python version for combining coverage to
217+
# prevent parsing errors in older versions when looking at modern code.
218+
- uses: "actions/setup-python@v2"
219+
with:
220+
python-version: "3.9"
221+
222+
- name: "Combine coverage"
223+
run: |
224+
set -eux
225+
pip install coverage[toml];
226+
coverage combine;
227+
coverage xml;
228+
env:
229+
COVERAGE_FILE: .tox/coverage
230+
231+
- name: "Upload coverage to Codecov"
232+
uses: "codecov/codecov-action@v1"
233+
with:
234+
env_vars: GITHUB_REF,GITHUB_COMMIT,GITHUB_USER,GITHUB_WORKFLOW
235+
fail_ci_if_error: true
236+
env:
237+
GITHUB_REF: ${{ github.ref }}
238+
GITHUB_COMMIT: ${{ github.sha }}
239+
GITHUB_USER: ${{ github.actor }}
240+
GITHUB_WORKFLOW: ${{ github.workflow }}

0 commit comments

Comments
 (0)