Skip to content

Commit e6879c4

Browse files
authored
Merge pull request #149 from python-hyper/gh-actions
GitHub Actions CI
2 parents a451f3d + b571b3a commit e6879c4

File tree

3 files changed

+269
-5
lines changed

3 files changed

+269
-5
lines changed

.github/workflows/cicd.yml

Lines changed: 238 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,238 @@
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.5", "3.6", "3.7", "3.8", "3.9", "pypy2", "pypy3"]
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="${py}";
208+
else # CPython
209+
py_test="py${py/./}"; # Add "py" prefix, remove "."
210+
fi;
211+
env_test="test-${py_test}-coverage_xml";
212+
echo "Test environment: ${env_test}";
213+
tox -e "${env_test}";
214+
tar cvzf pytest-logs.tgz ".tox/${env_test}/log";
215+
216+
- name: Upload pytest log artifact
217+
if: failure()
218+
uses: actions/upload-artifact@v1
219+
with:
220+
name: pytest-logs
221+
path: pytest-logs.tgz
222+
223+
# Use the latest supported Python version for combining coverage to
224+
# prevent parsing errors in older versions when looking at modern code.
225+
- uses: "actions/setup-python@v2"
226+
with:
227+
python-version: "3.9"
228+
229+
- name: "Upload coverage to Codecov"
230+
uses: "codecov/codecov-action@v1"
231+
with:
232+
env_vars: GITHUB_REF,GITHUB_COMMIT,GITHUB_USER,GITHUB_WORKFLOW
233+
fail_ci_if_error: true
234+
env:
235+
GITHUB_REF: ${{ github.ref }}
236+
GITHUB_COMMIT: ${{ github.sha }}
237+
GITHUB_USER: ${{ github.actor }}
238+
GITHUB_WORKFLOW: ${{ github.workflow }}

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Hyperlink Changelog
22

3+
## Next
4+
5+
* CPython 3.9 added to test matrix
6+
37
## 21.0.0
48

59
*(January 7, 2021)*

tox.ini

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
[tox]
22

33
envlist =
4-
flake8, mypy, black
5-
test-py{26,27,34,35,36,37,38,py2,py3}
4+
flake8, black, mypy
5+
test-py{26,27,34,35,36,37,38,39,py2,py3}
66
coverage_report
77
docs
88
packaging
@@ -12,10 +12,10 @@ skip_missing_interpreters = {tty:True:False}
1212

1313
[default]
1414

15-
basepython = python3.8
15+
basepython = python3.9
1616

1717
deps =
18-
idna==2.9
18+
idna==2.9 # rq.filter: <3
1919

2020
setenv =
2121
PY_MODULE=hyperlink
@@ -32,6 +32,8 @@ setenv =
3232
description = run tests
3333

3434
basepython =
35+
py: python
36+
3537
py26: python2.6
3638
py27: python2.7
3739
py34: python3.4
@@ -40,6 +42,7 @@ basepython =
4042
py37: python3.7
4143
py38: python3.8
4244
py39: python3.9
45+
py310: python3.10
4346

4447
pypy2: pypy
4548
pypy3: pypy3
@@ -74,6 +77,7 @@ passenv = CI
7477

7578
commands =
7679
pytest --cov={env:PY_MODULE} --cov-report=term-missing:skip-covered --doctest-modules {posargs:src/{env:PY_MODULE}}
80+
coverage_xml: coverage xml
7781

7882

7983
##
@@ -292,7 +296,7 @@ passenv =
292296
setenv =
293297
{[testenv:coverage_report]setenv}
294298

295-
COVERAGE_XML={envlogdir}/coverage_report.xml
299+
COVERAGE_XML={envlogdir}/coverage.xml
296300

297301
commands =
298302
# Note documentation for CI variables in passenv above
@@ -367,3 +371,21 @@ commands =
367371
check-manifest
368372
pip wheel --wheel-dir "{envtmpdir}/dist" --no-deps {toxinidir}
369373
twine check "{envtmpdir}/dist/"*
374+
375+
376+
##
377+
# Print dependencies
378+
##
379+
380+
[testenv:dependencies]
381+
382+
description = print dependencies
383+
384+
basepython = {[default]basepython}
385+
386+
recreate = true
387+
388+
deps =
389+
390+
commands =
391+
pip freeze --exclude={env:PY_MODULE}

0 commit comments

Comments
 (0)