-
Notifications
You must be signed in to change notification settings - Fork 0
230 lines (197 loc) · 6.95 KB
/
unit-tests.yml
File metadata and controls
230 lines (197 loc) · 6.95 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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
name: Unit Tests
on:
workflow_dispatch: # Manual triggering only (all auto-triggers disabled)
# push:
# branches: [main, master, develop]
# paths-ignore:
# - '**.md'
# - 'docs/**'
# - 'LICENSE'
# - '.gitignore'
# - '.vscode/**'
# pull_request:
# branches: [main, master, develop]
# paths-ignore:
# - '**.md'
# - 'docs/**'
# - 'LICENSE'
# - '.gitignore'
# - '.vscode/**'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
test:
name: Unit Tests (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
steps:
- name: Checkout code
uses: actions/checkout@v6
# Rust setup with caching
- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Install Linux dependencies
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y \
pkg-config \
libwebkit2gtk-4.1-dev \
build-essential \
curl \
wget \
file \
libxdo-dev \
libssl-dev \
libayatana-appindicator3-dev \
librsvg2-dev \
libglib2.0-dev \
libgtk-3-dev \
libfuse2
- name: Cache Rust dependencies
uses: actions/cache@v6
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
src-tauri/target/
key: ${{ runner.os }}-rust-${{ hashFiles('src-tauri/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-rust-
# Node/pnpm setup with caching
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: 22
cache: "pnpm"
- name: Install frontend dependencies
run: pnpm install --frozen-lockfile
# Build frontend (required by Tauri build script)
- name: Build frontend
env:
NODE_OPTIONS: --max-old-space-size=4096
run: pnpm build
# Run tests
- name: Run Rust unit tests
id: rust_tests
working-directory: src-tauri
run: |
OUTPUT=$(cargo test --lib --bins -- --nocapture 2>&1) || { echo "$OUTPUT"; exit 1; }
echo "$OUTPUT"
RUST_COUNT=$(echo "$OUTPUT" | grep -oP '\d+ test(s)? passed' | grep -oP '^\d+' || echo "0")
if [ "$RUST_COUNT" = "0" ]; then
RUST_COUNT=$(echo "$OUTPUT" | grep 'test result:' | grep -oP '\d+ passed' | grep -oP '^\d+' || echo "?")
fi
echo "count=$RUST_COUNT" >> $GITHUB_OUTPUT
- name: Run Rust doc tests
working-directory: src-tauri
run: cargo test --doc
- name: Run frontend unit tests
id: frontend_tests
run: |
OUTPUT=$(pnpm test:unit 2>&1) || { echo "$OUTPUT"; exit 1; }
echo "$OUTPUT"
FE_COUNT=$(echo "$OUTPUT" | grep -oP 'Tests\s+\d+' | grep -oP '\d+' | tail -1 || echo "?")
if [ -z "$FE_COUNT" ]; then
FE_COUNT=$(echo "$OUTPUT" | grep -oP '\d+ test(s)? passed' | grep -oP '^\d+' || echo "?")
fi
echo "count=$FE_COUNT" >> $GITHUB_OUTPUT
# Linting (only on Linux to save time)
- name: Run Rust clippy
if: matrix.os == 'ubuntu-latest'
working-directory: src-tauri
run: cargo clippy --all-targets --all-features -- -D warnings
- name: Check Rust formatting
if: matrix.os == 'ubuntu-latest'
working-directory: src-tauri
run: cargo fmt -- --check
- name: Run frontend linter
if: matrix.os == 'ubuntu-latest'
run: pnpm lint
- name: TypeScript type check
if: matrix.os == 'ubuntu-latest'
run: pnpm typecheck
# Code Coverage
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- name: Generate frontend coverage
run: pnpm test:coverage
- name: Generate Rust coverage
working-directory: src-tauri
run: cargo llvm-cov --lib --lcov --output-path ../coverage/lcov.info
- name: Upload frontend coverage to Codecov
uses: codecov/codecov-action@v5
with:
files: ./coverage/coverage-final.json
flags: frontend
name: frontend-coverage
token: ${{ secrets.CODECOV_TOKEN }}
continue-on-error: true
- name: Upload Rust coverage to Codecov
uses: codecov/codecov-action@v5
with:
files: ./coverage/lcov.info
flags: rust
name: rust-coverage
token: ${{ secrets.CODECOV_TOKEN }}
continue-on-error: true
- name: Upload coverage report
uses: actions/upload-artifact@v6
with:
name: coverage-report
path: coverage/
retention-days: 7
# Test summary
- name: Test Summary
if: always()
env:
RUST_COUNT: ${{ steps.rust_tests.outputs.count || '?' }}
FE_COUNT: ${{ steps.frontend_tests.outputs.count || '?' }}
run: |
echo "## Test Results" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Tests" >> $GITHUB_STEP_SUMMARY
echo "- Rust unit tests ($RUST_COUNT tests)" >> $GITHUB_STEP_SUMMARY
echo "- Frontend unit tests ($FE_COUNT tests)" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Code Quality" >> $GITHUB_STEP_SUMMARY
echo "- Rust clippy" >> $GITHUB_STEP_SUMMARY
echo "- Rust formatting" >> $GITHUB_STEP_SUMMARY
echo "- Frontend linting" >> $GITHUB_STEP_SUMMARY
echo "- TypeScript type check" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Coverage" >> $GITHUB_STEP_SUMMARY
echo "- Frontend & Rust coverage uploaded to Codecov" >> $GITHUB_STEP_SUMMARY
echo "- Coverage report available in artifacts" >> $GITHUB_STEP_SUMMARY
shell: bash
integration-ssh:
name: SSH Tunnel Integration Tests
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Generate SSH test keys
run: make test-ssh-setup
- name: Run SSH integration tests
run: make test-ssh
- name: Clean up SSH integration environment
if: always()
run: make test-ssh-clean
- name: Summary
if: always()
run: |
echo "## ✅ SSH integration tests" >> $GITHUB_STEP_SUMMARY
echo "- Containers started via docker-compose" >> $GITHUB_STEP_SUMMARY
echo "- SSH tunnel verified against postgres-private" >> $GITHUB_STEP_SUMMARY