1+ name : CI/CD Pipeline
2+
3+ on :
4+ push :
5+ branches : [ main ]
6+ pull_request :
7+ branches : [ main ]
8+ workflow_dispatch :
9+
10+ permissions :
11+ contents : read
12+
13+ concurrency :
14+ group : ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
15+ cancel-in-progress : true
16+
17+ env :
18+ FORCE_COLOR : 1
19+ RUFF_FORMAT : github
20+
21+ jobs :
22+ dependencies :
23+ name : Install Dependencies
24+ runs-on : ubuntu-latest
25+ steps :
26+ - name : Checkout repository
27+ uses : actions/checkout@v4
28+ with :
29+ persist-credentials : false
30+
31+ - name : Set up Python
32+ uses : actions/setup-python@v5
33+ with :
34+ python-version : " 3.x"
35+ cache : pip
36+
37+ - name : Install dependencies from requirements.txt
38+ run : |
39+ python -m pip install --upgrade pip
40+ python -m pip install -r requirements.txt
41+
42+ - name : Install tox for testing
43+ run : |
44+ python -m pip install tox
45+
46+ - name : Verify installations
47+ run : |
48+ python -m pip list
49+ python -m pytest --version
50+ python -m tox --version
51+
52+ pre-commit-validation :
53+ name : Validate Pre-commit Hooks
54+ runs-on : ubuntu-latest
55+ needs : dependencies
56+ steps :
57+ - name : Checkout repository
58+ uses : actions/checkout@v4
59+ with :
60+ persist-credentials : false
61+
62+ - name : Set up Python
63+ uses : actions/setup-python@v5
64+ with :
65+ python-version : " 3.x"
66+
67+ - name : Install dependencies
68+ run : |
69+ python -m pip install --upgrade pip
70+ python -m pip install -r requirements.txt
71+
72+ - name : Run pre-commit hooks
73+ uses : tox-dev/action-pre-commit-uv@v1
74+
75+ - name : Check spelling (manual hook)
76+ uses : tox-dev/action-pre-commit-uv@v1
77+ with :
78+ extra_args : --all-files --hook-stage manual codespell || true
79+
80+ test :
81+ name : Run Tests with Tox and Pytest
82+ runs-on : ubuntu-latest
83+ needs : dependencies
84+ strategy :
85+ fail-fast : false
86+ matrix :
87+ python-version : ["3.9", "3.10", "3.11", "3.12", "3.13"]
88+
89+ steps :
90+ - name : Checkout repository
91+ uses : actions/checkout@v4
92+ with :
93+ persist-credentials : false
94+
95+ - name : Set up Python ${{ matrix.python-version }}
96+ uses : actions/setup-python@v5
97+ with :
98+ python-version : ${{ matrix.python-version }}
99+ allow-prereleases : true
100+
101+ - name : Install dependencies
102+ run : |
103+ python -m pip install --upgrade pip
104+ python -m pip install -r requirements.txt
105+ python -m pip install tox
106+
107+ - name : Install uv for faster testing
108+ uses : hynek/setup-cached-uv@v2
109+ with :
110+ cache-dependency-path : |
111+ requirements.txt
112+
113+ - name : Run tests with tox
114+ run : |
115+ uvx --with tox-uv tox -e py -- -v --cov-report term
116+
117+ - name : Run pytest directly (fallback)
118+ if : failure()
119+ run : |
120+ python -bb -X dev -W error -m pytest -v
121+
122+ build :
123+ name : Build Project with Makefile
124+ runs-on : ubuntu-latest
125+ needs : dependencies
126+ steps :
127+ - name : Checkout repository
128+ uses : actions/checkout@v4
129+ with :
130+ fetch-depth : 0 # fetch all history for accurate last modified date-times
131+
132+ - name : Set up Python
133+ uses : actions/setup-python@v5
134+ with :
135+ python-version : " 3.x"
136+ cache : pip
137+
138+ - name : Install dependencies
139+ run : |
140+ python -m pip install --upgrade pip
141+ python -m pip install -r requirements.txt
142+
143+ - name : Build project using Makefile
144+ run : |
145+ make html JOBS=$(nproc)
146+
147+ - name : Build dirhtml (for deployment)
148+ run : |
149+ make dirhtml JOBS=$(nproc)
150+
151+ - name : Verify build artifacts
152+ run : |
153+ ls -la build/
154+ echo "Build completed successfully"
155+
156+ - name : Clean up .doctrees for deployment
157+ run : |
158+ rm -rf build/.doctrees/ || true
159+
160+ - name : Upload build artifacts
161+ uses : actions/upload-artifact@v4
162+ with :
163+ name : built-peps
164+ path : build/
165+ retention-days : 7
166+
167+ summary :
168+ name : CI/CD Summary
169+ runs-on : ubuntu-latest
170+ needs : [dependencies, pre-commit-validation, test, build]
171+ if : always()
172+ steps :
173+ - name : Check all jobs status
174+ run : |
175+ echo "Dependencies: ${{ needs.dependencies.result }}"
176+ echo "Pre-commit validation: ${{ needs.pre-commit-validation.result }}"
177+ echo "Tests: ${{ needs.test.result }}"
178+ echo "Build: ${{ needs.build.result }}"
179+
180+ if [[ "${{ needs.dependencies.result }}" != "success" || \
181+ "${{ needs.pre-commit-validation.result }}" != "success" || \
182+ "${{ needs.test.result }}" != "success" || \
183+ "${{ needs.build.result }}" != "success" ]]; then
184+ echo "❌ One or more CI/CD steps failed"
185+ exit 1
186+ else
187+ echo "✅ All CI/CD steps completed successfully"
188+ fi
0 commit comments