-
Notifications
You must be signed in to change notification settings - Fork 0
112 lines (106 loc) · 3.39 KB
/
Copy pathci.yml
File metadata and controls
112 lines (106 loc) · 3.39 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
103
104
105
106
107
108
109
110
111
112
name: FastAPI CI/CD
on:
push:
branches: [main, dev]
pull_request:
branches: [main]
env:
PYTHON_VERSION: "3.12"
IMAGE_NAME: ghcr.io/zyntroai/fastapi-boilerplate
REGISTRY: ghcr.io
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@f548e57c3d3c42e288026812cd22362661c4e8d4
- uses: actions/setup-python@5fda3b9c709277f8cf4290f3a0094ab7e95c1338
with:
python-version: ${{ env.PYTHON_VERSION }}
- run: python -m pip install ruff black isort
- run: ruff check .
- run: black --check .
test:
needs: lint
runs-on: ubuntu-latest
services:
postgres:
image: postgres:16-alpine
env:
POSTGRES_USER: test
POSTGRES_PASSWORD: test
POSTGRES_DB: test
ports: ["5432:5432"]
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@f548e57c3d3c42e288026812cd22362661c4e8d4
- uses: actions/setup-python@5fda3b9c709277f8cf4290f3a0094ab7e95c1338
with:
python-version: ${{ env.PYTHON_VERSION }}
- run: pip install -r requirements.txt
- name: Run Tests with Coverage
run: |
pytest tests/ -v --cov=app --cov-report=term-missing --cov-report=xml
env:
DATABASE_URL: postgresql://test:test@localhost:5432/test
- name: Upload Coverage to Codecov
uses: codecov/codecov-action@<pin-latest-sha>
with:
files: ./coverage.xml
flags: unittests
name: codecov-coverage
fail_ci_if_error: false
verbose: true
security:
needs: test
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
steps:
- uses: actions/checkout@f548e57c3d3c42e288026812cd22362661c4e8d4
with:
fetch-depth: 2
- name: Set up Python
uses: actions/setup-python@5fda3b9c709277f8cf4290f3a0094ab7e95c1338
with:
python-version: ${{ env.PYTHON_VERSION }}
- run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Initialize CodeQL
uses: github/codeql-action/init@977e6ce40888f41234c9b3252437dcf2331daaa2
with:
languages: python
build-mode: none
- name: Autobuild
uses: github/codeql-action/autobuild@977e6ce40888f41234c9b3252437dcf2331daaa2
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@977e6ce40888f41234c9b3252437dcf2331daaa2
with:
category: "/language:python"
build:
needs: security
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@f548e57c3d3c42e288026812cd22362661c4e8d4
- name: Log in to GHCR
uses: docker/login-action@<pin-latest-sha>
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build & Push
uses: docker/build-push-action@<pin-latest-sha>
with:
context: .
push: true
tags: ${{ env.IMAGE_NAME }}:latest