Skip to content

Commit be21f5f

Browse files
committed
Add test execution to GitHub Actions workflow with best practices
- Run tests before building Docker image - Use latest action versions (checkout@v4, setup-python@v5, upload-artifact@v4) - Enable pip dependency caching for faster builds - Generate both XML coverage and JUnit test reports - Upload test results as artifacts for debugging - Tests must pass before Docker build proceeds Follows GitHub's recommended Python testing practices for CI/CD.
1 parent 2d903d6 commit be21f5f

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

.github/workflows/main.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,34 @@ jobs:
1717
contents: read
1818
packages: write
1919
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@v4
22+
23+
- name: Set up Python
24+
uses: actions/setup-python@v5
25+
with:
26+
python-version: '3.11'
27+
cache: 'pip'
28+
29+
- name: Install dependencies
30+
run: |
31+
python -m pip install --upgrade pip
32+
pip install -e .
33+
pip install pytest pytest-asyncio pytest-mock pytest-cov
34+
35+
- name: Run tests
36+
run: |
37+
python -m pytest src/tests/ -v --cov=src --cov-report=term-missing --cov-report=xml --junitxml=junit/test-results.xml
38+
39+
- name: Upload test results
40+
uses: actions/upload-artifact@v4
41+
if: always()
42+
with:
43+
name: pytest-results
44+
path: |
45+
junit/test-results.xml
46+
coverage.xml
47+
2048
- name: Set up Docker Buildx
2149
uses: docker/setup-buildx-action@v2
2250
- name: Docker meta

0 commit comments

Comments
 (0)