-
Notifications
You must be signed in to change notification settings - Fork 0
99 lines (86 loc) · 2.37 KB
/
pipeline.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
name: pipeline
on: [push, pull_request]
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: "pages"
cancel-in-progress: false
jobs:
toolchain:
runs-on: ubuntu-22.04
strategy:
matrix:
python: ['3.10', '3.11']
steps:
# setup
- uses: actions/checkout@v3
- uses: pdm-project/setup-pdm@v3
with:
python-version: ${{ matrix.python }}
enable-pep582: true
- name: install dependencies
run: pdm install
# lint
- name: format imports
run: pdm run isort src tests --check
- name: format code
run: pdm run black src tests --check
# test
- name: unit test
run: pdm run pytest tests --cov
- name: static typing
run: pdm run mypy src
# security
- name: source code vulnerabilities
run: pdm run bandit -r src
- name: 3rd party vulnerabilities
run: pdm export --prod -f requirements | pdm run safety check --stdin
# build
- name: build docs
run: pdm run mkdocs build
- name: build distribution
run: pdm build
# keep artifacts for publish or debugging
- uses: actions/upload-artifact@v3
with:
name: ${{ matrix.python }}-build
path: pdm.lock
- uses: actions/upload-artifact@v3
with:
name: docs
path: site/
- uses: actions/upload-artifact@v3
with:
name: distribution
path: dist/
deploy:
if: github.ref == 'refs/heads/main'
needs: [toolchain]
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-22.04
steps:
# publish pages, surprisingly complex
- uses: actions/checkout@v3
- uses: actions/configure-pages@v3
- uses: actions/download-artifact@v3
with:
name: docs
path: site/
- uses: actions/upload-pages-artifact@v1
with:
path: site/
- name: deploy github pages
id: deployment
uses: actions/deploy-pages@v2
# publish distribution to pypi
- uses: pdm-project/setup-pdm@v3
- uses: actions/download-artifact@v3
with:
name: distribution
path: dist/
- name: publish package
run: pdm publish --no-build -u __token__ -P ${{ secrets.PYPI_TOKEN }}