Skip to content

Commit c374572

Browse files
committed
updated GitHub ci
1 parent 6a00d6c commit c374572

File tree

3 files changed

+136
-84
lines changed

3 files changed

+136
-84
lines changed

.github/workflows/ci.yaml

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
# GitHub Actions configuration **EXAMPLE**,
2+
# MODIFY IT ACCORDING TO YOUR NEEDS!
3+
# Reference: https://docs.github.com/en/actions
4+
5+
name: ci
6+
7+
on:
8+
release:
9+
types: [published]
10+
push:
11+
# Avoid using all the resources/limits available by checking only
12+
# relevant branches and tags. Other branches can be checked via PRs.
13+
branches: [main]
14+
tags: ['v?[0-9]+.[0-9]+.?[0-9]?*'] # Match tags that resemble a version
15+
pull_request: # Run in every PR
16+
workflow_dispatch: # Allow manually triggering the workflow
17+
schedule:
18+
# Run roughly every 15 days at 00:00 UTC
19+
# (useful to check if updates on dependencies break the package)
20+
- cron: '0 0 1,16 * *'
21+
22+
permissions:
23+
contents: read
24+
25+
concurrency:
26+
group: >-
27+
${{ github.workflow }}-${{ github.ref_type }}-
28+
${{ github.event.pull_request.number || github.sha }}
29+
cancel-in-progress: true
30+
31+
jobs:
32+
prepare:
33+
runs-on: ubuntu-latest
34+
outputs:
35+
wheel-distribution: ${{ steps.wheel-distribution.outputs.path }}
36+
steps:
37+
- uses: actions/checkout@v3
38+
with: {fetch-depth: 0} # deep clone for setuptools-scm
39+
- uses: actions/setup-python@v4
40+
id: setup-python
41+
with: {python-version: "3.11"}
42+
- name: Run static analysis and format checkers
43+
run: pipx run pre-commit run --all-files --show-diff-on-failure
44+
- name: Build package distribution files
45+
run: >-
46+
pipx run --python '${{ steps.setup-python.outputs.python-path }}'
47+
tox -e clean,build
48+
- name: Record the path of wheel distribution
49+
id: wheel-distribution
50+
run: echo "path=$(ls dist/*.whl)" >> $GITHUB_OUTPUT
51+
- name: Store the distribution files for use in other stages
52+
# `tests` and `publish` will use the same pre-built distributions,
53+
# so we make sure to release the exact same package that was tested
54+
uses: actions/upload-artifact@v3
55+
with:
56+
name: python-distribution-files
57+
path: dist/
58+
retention-days: 1
59+
60+
test:
61+
needs: prepare
62+
strategy:
63+
matrix:
64+
python:
65+
- "3.9" # oldest Python supported by PSF
66+
- "3.11" # newest Python that is stable
67+
platform:
68+
- ubuntu-latest
69+
- macos-latest
70+
- windows-latest
71+
runs-on: ${{ matrix.platform }}
72+
steps:
73+
- uses: actions/checkout@v3
74+
- uses: actions/setup-python@v4
75+
id: setup-python
76+
with:
77+
python-version: ${{ matrix.python }}
78+
- name: Retrieve pre-built distribution files
79+
uses: actions/download-artifact@v3
80+
with: {name: python-distribution-files, path: dist/}
81+
- name: Run tests
82+
run: >-
83+
pipx run --python '${{ steps.setup-python.outputs.python-path }}'
84+
tox --installpkg '${{ needs.prepare.outputs.wheel-distribution }}'
85+
-- -rFEx --durations 10 --color yes # pytest args
86+
- name: Generate coverage report
87+
run: pipx run coverage[toml] lcov -o coverage.lcov
88+
- name: Upload partial coverage report
89+
uses: coverallsapp/github-action@master
90+
with:
91+
path-to-lcov: coverage.lcov
92+
github-token: ${{ secrets.github_token }}
93+
flag-name: ${{ matrix.platform }} - py${{ matrix.python }}
94+
parallel: true
95+
96+
finalize:
97+
needs: test
98+
runs-on: ubuntu-latest
99+
steps:
100+
- name: Finalize coverage report
101+
uses: coverallsapp/github-action@master
102+
with:
103+
github-token: ${{ secrets.GITHUB_TOKEN }}
104+
parallel-finished: true
105+
106+
publish:
107+
needs: finalize
108+
if: ${{ (github.event_name == 'push' && contains(github.ref, 'refs/tags/')) || (github.event_name == 'release' && github.event.action == 'published') }}
109+
runs-on: ubuntu-latest
110+
permissions:
111+
contents: write
112+
steps:
113+
- uses: actions/checkout@v3
114+
- uses: actions/setup-python@v4
115+
with: {python-version: "3.11"}
116+
- name: Retrieve pre-built distribution files
117+
uses: actions/download-artifact@v3
118+
with: {name: python-distribution-files, path: dist/}
119+
# - name: Publish Package (TEST)
120+
# env:
121+
# # TODO: Set your PYPI_TOKEN as a secret using GitHub UI
122+
# # - https://pypi.org/help/#apitoken
123+
# # - https://docs.github.com/en/actions/security-guides/encrypted-secrets
124+
# TWINE_REPOSITORY: pypi
125+
# TWINE_USERNAME: __token__
126+
# TWINE_PASSWORD: ${{ secrets.PYPI_TEST_TOKEN }}
127+
# run: pipx run tox -e publish
128+
- name: Publish Package
129+
env:
130+
# TODO: Set your PYPI_TOKEN as a secret using GitHub UI
131+
# - https://pypi.org/help/#apitoken
132+
# - https://docs.github.com/en/actions/security-guides/encrypted-secrets
133+
TWINE_REPOSITORY: pypi
134+
TWINE_USERNAME: __token__
135+
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
136+
run: pipx run tox -e publish

.github/workflows/pythonapp.yml

Lines changed: 0 additions & 44 deletions
This file was deleted.

.github/workflows/release_to_pypi.yml

Lines changed: 0 additions & 40 deletions
This file was deleted.

0 commit comments

Comments
 (0)