@@ -5,6 +5,14 @@ on: [push, pull_request]
55jobs :
66
77 static-analysis :
8+ # We want to run on external PRs, but not on our own internal PRs as they'll
9+ # be run by the push to the branch. Without this if check, checks are
10+ # duplicated since internal PRs match both the push and pull_request events.
11+ # https://github.com/psf/black/blob/f51e53726b39a177355a7917c91c56f390dda7ef/.github/workflows/lint.yml#L7-L12
12+ if :
13+ github.event_name == 'push' ||
14+ github.event.pull_request.head.repo.full_name != github.repository
15+
816 runs-on : ubuntu-latest
917
1018 steps :
@@ -32,15 +40,22 @@ jobs:
3240
3341
3442 test :
43+ # We want to run on external PRs, but not on our own internal PRs as they'll
44+ # be run by the push to the branch. Without this if check, checks are
45+ # duplicated since internal PRs match both the push and pull_request events.
46+ if :
47+ github.event_name == 'push' ||
48+ github.event.pull_request.head.repo.full_name != github.repository
49+
3550 strategy :
3651 matrix :
3752 os : ['ubuntu-latest']
38- python : [3.7, 3.8, 3.9 ]
39- # Works around the depreciation of python 3.6 for ubuntu
53+ python : ['3.8', '3.9', '3.10', '3.11' ]
54+ # Works around the depreciation of python 3.6, 3.7 for ubuntu
4055 # https://github.com/actions/setup-python/issues/544
4156 include :
42- - os : ' ubuntu-20 .04'
43- python : 3.6
57+ - os : ' ubuntu-22 .04'
58+ python : ' 3.7 '
4459
4560 runs-on : ${{ matrix.os }}
4661
@@ -60,4 +75,115 @@ jobs:
6075
6176 - name : Run Tox
6277 run : |
63- tox -e py
78+ tox -e begin,py -- --tb short
79+
80+ - name : Upload coverage
81+ uses : actions/upload-artifact@v4
82+ with :
83+ name : coverage-${{ matrix.os }}-${{ matrix.python }}
84+ path : .coverage/*
85+ include-hidden-files : true
86+ retention-days : 1
87+
88+
89+ coverage :
90+ # We want to run on external PRs, but not on our own internal PRs as they'll
91+ # be run by the push to the branch. Without this if check, checks are
92+ # duplicated since internal PRs match both the push and pull_request events.
93+ if :
94+ github.event_name == 'push' ||
95+ github.event.pull_request.head.repo.full_name != github.repository
96+
97+ needs : test
98+
99+ runs-on : ubuntu-latest
100+ steps :
101+ - name : Checkout code
102+ uses : actions/checkout@v4
103+
104+ - name : Setup Python
105+ uses : actions/setup-python@v5
106+ with :
107+ python-version : " 3.x"
108+
109+ - name : Install dependencies
110+ run : |
111+ python -m pip install --upgrade pip
112+ python -m pip install tox coverage[toml]
113+
114+ # Ensure version.py is created so coverage can read it's source
115+ - name : Run begin
116+ run : |
117+ tox -e begin
118+
119+ - name : Download coverage artifacts
120+ uses : actions/download-artifact@v4
121+ with :
122+ path : .coverage/
123+ pattern : coverage-*
124+ merge-multiple : true
125+
126+ # Tox runs `coverage combine` and `coverage xml`
127+ - name : Combine coverage and report
128+ run : |
129+ tox -e end
130+
131+ # Report and write to summary.
132+ python -m coverage report --format=markdown >> $GITHUB_STEP_SUMMARY
133+
134+ # Write html coverage report to upload as an artifact
135+ python -m coverage html
136+
137+ # # Report again and fail if under 100%.
138+ # python -m coverage report --fail-under=100
139+
140+ - name : Upload HTML report if check failed.
141+ uses : actions/upload-artifact@v4
142+ with :
143+ name : html-report
144+ path : htmlcov
145+ # # TODO: If we get 100% coverage we can re-enable this and the
146+ # # `--fail-under` check so pull requests fail if the dev doesn't
147+ # # add tests for new code.
148+ # if: ${{ failure() }}
149+
150+
151+ pip-package :
152+ # We want to run on external PRs, but not on our own internal PRs as they'll
153+ # be run by the push to the branch. Without this if check, checks are
154+ # duplicated since internal PRs match both the push and pull_request events.
155+ if :
156+ github.event_name == 'push' ||
157+ github.event.pull_request.head.repo.full_name != github.repository
158+
159+ # Build and upload pip packages as artifacts so we can inspect them and
160+ # ensure they are correct for actual release
161+ runs-on : ubuntu-latest
162+
163+ steps :
164+ - name : Checkout code
165+ uses : actions/checkout@v4
166+ with :
167+ fetch-depth : 0
168+
169+ - name : Setup Python
170+ uses : actions/setup-python@v5
171+ with :
172+ python-version : " 3.x"
173+
174+ - name : Install dependencies
175+ run : |
176+ python -m pip install --upgrade pip
177+ python -m pip install --upgrade build setuptools wheel twine
178+
179+ - name : Build wheel
180+ run : |
181+ python -m build --wheel --sdist
182+
183+ - name : Upload packages.
184+ uses : actions/upload-artifact@v4
185+ with :
186+ name : pip-packages
187+ path : |
188+ dist/preditor-*.whl
189+ dist/preditor-*.tar.gz
0 commit comments