-
Notifications
You must be signed in to change notification settings - Fork 0
117 lines (108 loc) · 3.27 KB
/
Copy pathci.yml
File metadata and controls
117 lines (108 loc) · 3.27 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
name: CI
on:
push:
branches: [main]
pull_request:
permissions:
contents: read
packages: write
jobs:
backend:
runs-on: ubuntu-latest
defaults:
run:
working-directory: backend
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v2
with:
workspaces: backend
- name: Check formatting
run: cargo fmt --check
- name: Run clippy
run: cargo clippy --locked -- -D warnings
- name: Run tests
run: cargo test --locked
web:
runs-on: ubuntu-latest
defaults:
run:
working-directory: web
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v5
- name: Install dependencies
run: npm ci
- name: Audit dependencies
run: npm audit --audit-level=moderate
- name: Run lint
run: npm run lint -- --max-warnings 0
- name: Run typecheck
run: npm run typecheck
- name: Run tests
run: npm test
- name: Build
run: npm run build
codegen:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
workspaces: backend
- uses: actions/setup-node@v5
- name: Install dependencies
working-directory: web
run: npm ci
- name: Regenerate schema and types
run: |
cargo run --manifest-path backend/Cargo.toml --bin schema-export 2>/dev/null > web/schema.graphql
cd web && npm run codegen
- name: Check for uncommitted changes
run: git diff --exit-code web/schema.graphql web/src/gql/types.ts
docker-backend:
runs-on: ubuntu-latest
needs:
- backend
- web
- codegen
steps:
- uses: actions/checkout@v4
- name: Compute git version
id: git-version
run: |
VERSION=$(git describe --tags --exact-match 2>/dev/null || echo "${GITHUB_SHA::7}")
echo "value=$VERSION" >> $GITHUB_OUTPUT
- uses: docker/login-action@v3
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/setup-buildx-action@v3
- name: Docker metadata
id: backend-meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository_owner }}/siniscalco
flavor: |
latest=false
tags: |
type=raw,value=${{ github.sha }}
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
type=ref,event=tag
- name: Build and push backend image
uses: docker/build-push-action@v6
with:
context: .
file: backend/Dockerfile
push: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') }}
build-args: |
VITE_API_BASE_URL=/api
GIT_VERSION=${{ steps.git-version.outputs.value }}
tags: ${{ steps.backend-meta.outputs.tags }}
labels: ${{ steps.backend-meta.outputs.labels }}