-
Notifications
You must be signed in to change notification settings - Fork 1
202 lines (167 loc) · 4.96 KB
/
Copy pathci.yml
File metadata and controls
202 lines (167 loc) · 4.96 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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
name: CI/CD Pipeline
on:
push:
branches: [ main, develop ]
paths-ignore:
- 'README.md'
- 'CONTRIBUTING.md'
- 'DEVELOPMENT.md'
- 'IMPROVEMENTS.md'
- 'docs/**'
- '**/*.md'
- '.dockerignore'
- '.gitignore'
pull_request:
branches: [ main, develop ]
paths-ignore:
- 'README.md'
- 'CONTRIBUTING.md'
- 'DEVELOPMENT.md'
- 'IMPROVEMENTS.md'
- 'docs/**'
- '**/*.md'
- '.dockerignore'
- '.gitignore'
env:
CARGO_TERM_COLOR: always
DATABASE_URL: postgres://postgres:password@localhost:5432/keylo_test
TEST_DATABASE_URL: postgres://postgres:password@localhost:5432/keylo_test
jobs:
test:
name: Run Tests
runs-on: ubuntu-latest
services:
postgres:
image: postgres:15
env:
POSTGRES_PASSWORD: password
POSTGRES_DB: keylo_test
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
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 24
cache: npm
cache-dependency-path: web/package-lock.json
- name: Cache dependencies
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Check code formatting
run: cargo fmt --all -- --check
- name: Build setup web UI
working-directory: web
run: |
npm ci
npm run build
- name: Wait for Postgres
env:
PGPASSWORD: password
run: |
until pg_isready -h localhost -p 5432 -U postgres; do
echo "Waiting for postgres..."
sleep 1
done
- name: Apply DB migrations for SQLx compile-time checks
env:
PGPASSWORD: password
run: |
for f in $(find migrations -maxdepth 1 -name '*.sql' | sort); do
echo "Applying migration: $f"
psql -h localhost -U postgres -d keylo_test -v ON_ERROR_STOP=1 -f "$f"
done
psql -h localhost -U postgres -d keylo_test -v ON_ERROR_STOP=1 -c "SELECT to_regclass('public.users') AS users_table;"
- name: Run clippy
run: cargo clippy -- -D warnings
- name: Run unit tests
run: cargo test --lib
- name: Run integration tests
run: cargo test --test integration_test
- name: Run user integration tests
run: cargo test --test user_integration_test
- name: Run RBAC integration tests
run: cargo test --test rbac_integration_test
- name: Run OAuth integration tests
run: cargo test --test oauth_integration_test
- name: Run database integration tests
run: cargo test --test database_integration_test
- name: Run load tests
run: cargo test --test load_test
- name: Build release binary
run: cargo build --release
security-audit:
name: Security Audit
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Install cargo-audit
run: cargo install cargo-audit
- name: Run security audit
run: cargo audit --ignore RUSTSEC-2023-0071
coverage:
name: Code Coverage
runs-on: ubuntu-latest
services:
postgres:
image: postgres:15
env:
POSTGRES_PASSWORD: password
POSTGRES_DB: keylo_test
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
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Install cargo-tarpaulin
run: cargo install cargo-tarpaulin
- name: Wait for Postgres
env:
PGPASSWORD: password
run: |
until pg_isready -h localhost -p 5432 -U postgres; do
echo "Waiting for postgres..."
sleep 1
done
- name: Apply DB migrations for SQLx compile-time checks
env:
PGPASSWORD: password
run: |
for f in $(find migrations -maxdepth 1 -name '*.sql' | sort); do
echo "Applying migration: $f"
psql -h localhost -U postgres -d keylo_test -v ON_ERROR_STOP=1 -f "$f"
done
psql -h localhost -U postgres -d keylo_test -v ON_ERROR_STOP=1 -c "SELECT to_regclass('public.users') AS users_table;"
- name: Run tests with coverage
run: cargo tarpaulin --out Xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
file: cobertura.xml
fail_ci_if_error: false