-
Notifications
You must be signed in to change notification settings - Fork 0
102 lines (94 loc) · 2.76 KB
/
Copy pathci.yml
File metadata and controls
102 lines (94 loc) · 2.76 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
100
101
102
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
permissions:
contents: read
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
env:
UV_VERSION: "0.11.8"
PYTHON_VERSION: "3.12"
jobs:
lint-type:
name: Lint, format & type-check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
version: ${{ env.UV_VERSION }}
enable-cache: true
- run: uv python install ${{ env.PYTHON_VERSION }}
- run: uv sync --extra dev --python ${{ env.PYTHON_VERSION }}
- name: Format check
run: uv run ruff format --check .
- name: Lint
run: uv run ruff check .
- name: Type-check
run: uv run mypy app
test:
name: Tests
runs-on: ubuntu-latest
services:
postgres:
image: postgres:16-alpine
env:
POSTGRES_USER: ghostmon
POSTGRES_PASSWORD: ghostmon
POSTGRES_DB: ghostmon_test
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U ghostmon -d ghostmon_test"
--health-interval 5s
--health-timeout 5s
--health-retries 10
env:
DATABASE_URL: postgresql+asyncpg://ghostmon:ghostmon@localhost:5432/ghostmon_test
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
version: ${{ env.UV_VERSION }}
enable-cache: true
- run: uv python install ${{ env.PYTHON_VERSION }}
- run: uv sync --extra dev --python ${{ env.PYTHON_VERSION }}
- name: Generate ephemeral app secret
run: echo "APP_SECRET_KEY=$(openssl rand -hex 24)" >> "$GITHUB_ENV"
- name: Run tests
run: uv run pytest --cov=app --cov-report=term-missing
build:
name: Build OCI image
runs-on: ubuntu-latest
needs: [lint-type, test]
steps:
- uses: actions/checkout@v4
- name: Build image with Podman
run: podman build -t ghostmon:${{ github.sha }} .
security:
name: Security scan
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
version: ${{ env.UV_VERSION }}
- name: Audit dependencies (pip-audit / OSV database)
run: |
uv export --frozen --no-emit-project --format requirements-txt -o requirements.txt
uvx pip-audit -r requirements.txt --strict
- name: Scan for secrets (gitleaks)
run: |
podman run --rm -v "$PWD:/repo:ro,Z" ghcr.io/gitleaks/gitleaks:v8.21.2 \
detect --source=/repo --no-banner --redact