-
Notifications
You must be signed in to change notification settings - Fork 47
147 lines (114 loc) · 4 KB
/
ci.yml
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
# Run all tests, linters, code analysis and other QA tasks on
# every push to master and PRs.
name: CI
on:
workflow_dispatch:
pull_request:
push:
branches:
- main
tags:
- '*'
# To SSH into the runner to debug a failure, add the following step before
# the failing step
# - uses: lhotari/action-upterm@v1
# with:
# limit-access-to-actor: true
# Prevent multiple jobs running after fast subsequent pushes
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
test_312:
name: "Python 3.12 Tests"
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/nix-shell
with:
cachix_auth_token: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- name: Run linters and unit tests
run: |
nix-shell --run "make lint all=true"
nix-shell --run "make types"
nix-shell --run "make unit"
- name: Run tests for the singlefile example
run: |
cd examples/singlefile
nix-shell --run "python -m unittest app.py"
- name: Run tests for the todoapp example
run: |
cd examples/todoapp
nix-shell --run "python -m unittest tests.py"
- name: Run tests for the splitfile example
run: |
cd examples/splitfile
nix-shell --run "python -m unittest tests.py"
- name: Save coverage report
uses: actions/upload-artifact@v4
with:
name: htmlcov
path: htmlcov/
test_310:
name: "Python 3.10 Tests"
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/nix-shell
with:
cachix_auth_token: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- name: Run linters and unit tests
run: |
nix-shell --run "PYTHON=python3.10 make lint all=true"
nix-shell --run "PYTHON=python3.10 make types"
nix-shell --run "PYTHON=python3.10 make unit"
- name: Run tests for the singlefile example
run: |
cd examples/singlefile
nix-shell --run "python3.10 -m unittest app.py"
- name: Run tests for the todoapp example
run: |
cd examples/todoapp
nix-shell --run "python3.10 -m unittest tests.py"
- name: Run tests for the splitfile example
run: |
cd examples/splitfile
nix-shell --run "python3.10 -m unittest tests.py"
- name: Save coverage report
uses: actions/upload-artifact@v4
with:
name: htmlcov-py310
path: htmlcov/
release:
name: "Release to PyPI"
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
needs: [test_312, test_310]
runs-on: ubuntu-22.04
# To test publishing to testpypi:
# * change version in pyproject.toml to 0.16.1-alpha.1 or similar
# * uncomment POETRY_REPOSITORIES_TESTPYPI_URL and POETRY_PYPI_TOKEN_TESTPYPI
# * append `-r testpypi` to poetry publish command
# * `git ci && git tag 0.16.1-alpha.1 && git push --tags`
env:
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.POETRY_PYPI_TOKEN_PYPI }}
# POETRY_PYPI_TOKEN_TESTPYPI: ${{ secrets.POETRY_PYPI_TOKEN_TESTPYPI }}
# POETRY_REPOSITORIES_TESTPYPI_URL: https://test.pypi.org/legacy/
permissions:
contents: write
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/nix-shell
with:
cachix_auth_token: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- name: verify git tag matches pyproject.toml version
run: |
echo "$GITHUB_REF_NAME"
POETRY_VERSION=$(nix-shell --run "poetry version --short")
echo $POETRY_VERSION
[[ "$GITHUB_REF_NAME" == "$POETRY_VERSION" ]] && exit 0 || exit 1
- run: nix-shell --run "poetry publish --build"
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
make_latest: true