-
Notifications
You must be signed in to change notification settings - Fork 0
128 lines (108 loc) · 3.39 KB
/
Copy pathci.yml
File metadata and controls
128 lines (108 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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
name: CI
on:
push:
branches: [main, develop]
pull_request:
branches: [main]
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
jobs:
backend:
runs-on: ubuntu-latest
defaults:
run:
working-directory: backend
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: pip
cache-dependency-path: backend/requirements.txt
- name: Install deps
run: |
pip install --upgrade pip
pip install -r requirements.txt
pip install ruff mypy pytest pytest-cov
- name: Lint (ruff)
run: ruff check . --output-format=github
- name: Tests
env:
JWT_SECRET_KEY: ci-test-secret-key-at-least-32-characters-long-xxxx
APP_ENV: test
DATABASE_URL: sqlite:///./test.db
ENABLE_DEV_PAYMENT: "1"
SCHEDULER_ENABLED: "0"
run: pytest -v --cov=. --cov-report=xml --cov-report=term
- name: Upload coverage
if: success()
uses: actions/upload-artifact@v4
with:
name: backend-coverage
path: backend/coverage.xml
frontend:
runs-on: ubuntu-latest
defaults:
run:
working-directory: frontend
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "20"
cache: npm
cache-dependency-path: frontend/package-lock.json
- name: Install
run: npm ci
- name: TypeScript
run: npx tsc --noEmit
- name: ESLint
run: npm run lint --if-present
- name: Build
env:
NEXT_PUBLIC_API_URL: http://localhost:8000
NEXT_PUBLIC_SITE_URL: http://localhost:3000
run: npm run build
docker:
runs-on: ubuntu-latest
needs: [backend, frontend]
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Compute lowercase image repo
id: repo
run: echo "name=$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" >> "$GITHUB_OUTPUT"
- name: Build & push backend
uses: docker/build-push-action@v5
with:
context: ./backend
push: true
tags: |
ghcr.io/${{ steps.repo.outputs.name }}/backend:latest
ghcr.io/${{ steps.repo.outputs.name }}/backend:${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Build & push frontend
uses: docker/build-push-action@v5
with:
context: ./frontend
push: true
tags: |
ghcr.io/${{ steps.repo.outputs.name }}/frontend:latest
ghcr.io/${{ steps.repo.outputs.name }}/frontend:${{ github.sha }}
build-args: |
NEXT_PUBLIC_API_URL=${{ secrets.NEXT_PUBLIC_API_URL }}
NEXT_PUBLIC_SITE_URL=${{ secrets.NEXT_PUBLIC_SITE_URL }}
NEXT_PUBLIC_TURNSTILE_SITE_KEY=${{ secrets.NEXT_PUBLIC_TURNSTILE_SITE_KEY }}
cache-from: type=gha
cache-to: type=gha,mode=max
permissions:
contents: read
packages: write