-
Notifications
You must be signed in to change notification settings - Fork 3
99 lines (77 loc) · 2.27 KB
/
ci.yml
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]
pull_request:
env:
CARGO_INCREMENTAL: 0
RUSTFLAGS: "-D warnings"
jobs:
build-lint:
name: Build & Lint
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Setup rust cache
uses: Swatinem/rust-cache@v2
- name: Install cargo-cyclonedx
run: cargo install [email protected]
- name: Install just
run: cargo install [email protected]
- run: cargo build --release
env:
SQLX_OFFLINE: true
- run: just format
- run: just lint
- run: just generate-sbom
- name: Check for file changes
run: |
if [[ -n "$(git status --porcelain)" ]]; then
echo "::error::Detected changes in the following files:"
git status --porcelain
exit 1
fi
- name: podman login
env:
USER: ${{ github.actor }}
PASSWORD: ${{ secrets.GITHUB_TOKEN }}
run: podman login --username "$USER" --password "$PASSWORD" ghcr.io
- name: podman build linux/amd64
run: podman build --format docker --platform linux/amd64 --manifest linkblocks -f Containerfile target/release
- name: podman manifest push latest
run: podman manifest push linkblocks ghcr.io/raffomania/linkblocks:latest
if: github.ref == 'refs/heads/main'
test:
name: Test
runs-on: ubuntu-latest
services:
postgres:
image: postgres:16
env:
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Setup rust cache
uses: Swatinem/rust-cache@v2
- name: cargo test
run: cargo test
env:
DATABASE_URL: postgres://postgres:postgres@localhost:5432
SQLX_OFFLINE: true