This repository has been archived by the owner on Dec 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
148 lines (127 loc) · 3.69 KB
/
main.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
148
name: ci-cd
on:
push:
branches:
- main
- "feature/**"
paths:
- 'src/**.py'
pull_request:
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Python & Dependencies
uses: packetcoders/action-setup-cache-python-poetry@main
with:
python-version: 3.12.1
poetry-version: 1.8.2
- name: Run Tests
run: |
poetry install --only-root
poetry run pytest
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Python 3.12
uses: packetcoders/action-setup-cache-python-poetry@main
with:
python-version: 3.12.1
poetry-version: 1.8.2
- name: Install dev dependencies
run: poetry install --only-root
- name: Format with ruff
run: |
poetry run ruff check src/ --diff --output-format=full --exit-non-zero-on-fix
- name: Typecheck with mypy
run: poetry run mypy --ignore-missing-imports src/
beautify:
name: Beautify
runs-on: ubuntu-latest
needs: [test, lint]
concurrency: push
permissions:
id-token: write
contents: write
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
- name: Setup Python 3.12
uses: packetcoders/action-setup-cache-python-poetry@main
with:
python-version: 3.12.1
poetry-version: 1.8.2
- name: Install dev dependencies
run: poetry install --only-root
- name: Format with ruff
run: poetry run ruff format src/
- name: Commit and push changes
uses: stefanzweifel/git-auto-commit-action@v5
id: auto-commit-action
with:
commit_message: "style: beautify ${{ github.sha }}"
release:
name: Semantic Release
runs-on: ubuntu-latest
concurrency: push
needs: [test, lint, beautify]
if: github.ref == 'refs/heads/main'
permissions:
id-token: write
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Python 3.12
uses: packetcoders/action-setup-cache-python-poetry@main
with:
python-version: 3.12.1
poetry-version: 1.8.2
- name: Python Semantic Release
id: release
uses: python-semantic-release/python-semantic-release@composite-github-action
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
root_options: "-vv"
- name: Publish GitHub Release
uses: python-semantic-release/upload-to-gh-release@main
if: ${{ steps.release.outputs.released }} == 'true'
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ steps.release.outputs.version }}
outputs:
released: ${{ steps.release.outputs.released }}
docs:
name: Build Documentation
runs-on: ubuntu-latest
needs: [release]
if: needs.release.outputs.released == 'true' && github.ref == 'refs/heads/main'
permissions:
id-token: write
contents: write
steps:
- uses: actions/checkout@v4
- name: Setup Python 3.12
uses: packetcoders/action-setup-cache-python-poetry@main
with:
python-version: 3.12.1
poetry-version: 1.8.2
- name: Add Poetry's bin directory to the PATH
run: echo "$(poetry env info --path)/bin" >> $GITHUB_PATH
- name: Build HTML
run: |
cd docs/
make html
- name: Run ghp-import
run: |
ghp-import -n -p -f docs/_build/html