-
Notifications
You must be signed in to change notification settings - Fork 0
91 lines (75 loc) · 2.34 KB
/
Copy pathbackend-tests.yaml
File metadata and controls
91 lines (75 loc) · 2.34 KB
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
name: Backend Tests
on:
pull_request:
jobs:
check_paths:
runs-on: ubuntu-latest
outputs:
should_run: ${{ steps.filter.outputs.backend }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3.0.2
id: filter
with:
filters: |
backend:
- 'src/backend/**'
- '.github/workflows/backend-tests.yaml'
test:
name: Test Backend
needs: check_paths
if: ${{ needs.check_paths.outputs.should_run == 'true' }}
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./src/backend
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install UV
uses: astral-sh/setup-uv@v5
- name: Set up Python
run: uv python install
- name: Install dependencies
run: |
uv sync --locked --dev
- name: Lint with Ruff
run: |
uv run ruff check --output-format=github --target-version=py313 src tests
uv run ruff format --diff --check --target-version=py313 src tests
- name: Run tests with coverage
run: |
uv run pytest tests/ -v --cov=src/backend --cov-report=xml --cov-fail-under=80
- name: Upload coverage report
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: ./src/backend/coverage.xml
retention-days: 7
if: ${{ always() }}
- name: Coverage Report
uses: irongut/CodeCoverageSummary@v1.3.0
with:
filename: ./src/backend/coverage.xml
badge: true
format: markdown
output: both
- name: Add Coverage PR Comment
uses: marocchino/sticky-pull-request-comment@v2
if: github.event_name == 'pull_request'
with:
header: test-coverage
recreate: true
path: code-coverage-results.md
- name: Build Docker image
run: docker build -t backend-app:latest .
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@0.30.0
with:
image-ref: "backend-app:latest"
format: "table"
exit-code: "0"
# exit-code: '1' # Fail the workflow if vulnerabilities are found.
ignore-unfixed: true
vuln-type: "os,library"
severity: "CRITICAL,HIGH"