-
Notifications
You must be signed in to change notification settings - Fork 0
99 lines (91 loc) · 2.63 KB
/
ci.yml
File metadata and controls
99 lines (91 loc) · 2.63 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
92
93
94
95
96
97
98
99
name: CI
on:
push:
branches: [main]
paths-ignore:
- '**.md'
- '**.csv'
pull_request:
branches: [main]
paths-ignore:
- '**.md'
- '**.csv'
permissions:
contents: read
packages: write
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: "3.12"
- run: pip install ruff
- run: ruff check app/ scripts/
- run: ruff format --check app/ scripts/
import-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: "3.12"
- run: pip install -r requirements.txt
- run: python -c "from app.main import app; print('imports OK')"
security:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: "3.12"
- run: pip install -r requirements.txt
- name: Dependency audit
run: pip install pip-audit && pip-audit -r requirements.lock
- name: Static security analysis
run: pip install bandit && bandit -r app/ -c pyproject.toml
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: "3.12"
- run: pip install -r requirements-dev.txt
- run: pytest tests/ -v
docker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Build image
run: docker build -t postalcode2nuts .
- name: Verify non-root user
run: |
user=$(docker run --rm postalcode2nuts whoami)
echo "Container user: $user"
[ "$user" = "appuser" ] || exit 1
publish:
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
needs: [lint, import-check, test, security, docker]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/metadata-action@v6
id: meta
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=raw,value=latest
type=sha
- uses: docker/build-push-action@v7
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}