Skip to content

Commit ccf1baa

Browse files
committed
refactor: enhance CI/CD workflow with improved change detection and system dependencies
1 parent 0bc294c commit ccf1baa

File tree

1 file changed

+183
-36
lines changed

1 file changed

+183
-36
lines changed

.github/workflows/ci.yml

Lines changed: 183 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,127 @@
1-
name: Full Stack CI
1+
name: Full Stack CI/CD
22

33
on:
44
push:
5-
branches: [ "main" ]
5+
branches: [ "main", "1.0.4" ]
6+
paths-ignore:
7+
- '**.md'
8+
- '.gitignore'
9+
- 'LICENSE'
610
pull_request:
711
branches: [ "main" ]
12+
paths-ignore:
13+
- '**.md'
14+
- '.gitignore'
15+
- 'LICENSE'
816
workflow_dispatch:
917

1018
env:
1119
CARGO_TERM_COLOR: always
20+
RUST_BACKTRACE: 1
1221

1322
jobs:
14-
# Backend Rust tests
15-
rust-tests:
16-
name: Rust Backend Tests
17-
runs-on: macos-latest
23+
# Check if we should skip CI
24+
changes:
25+
name: Detect Changes
26+
runs-on: ubuntu-latest
27+
outputs:
28+
backend: ${{ steps.changes.outputs.backend }}
29+
frontend: ${{ steps.changes.outputs.frontend }}
30+
tauri: ${{ steps.changes.outputs.tauri }}
31+
steps:
32+
- name: Checkout Repository
33+
uses: actions/checkout@v4
34+
35+
- name: Check for changes
36+
uses: dorny/paths-filter@v3
37+
id: changes
38+
with:
39+
filters: |
40+
backend:
41+
- 'src-tauri/**'
42+
- 'Cargo.toml'
43+
- 'Cargo.lock'
44+
frontend:
45+
- 'src/**'
46+
- 'public/**'
47+
- 'package.json'
48+
- 'pnpm-lock.yaml'
49+
- 'vite.config.*'
50+
- 'tsconfig.json'
51+
- 'tailwind.config.*'
52+
tauri:
53+
- 'src-tauri/tauri.conf.json'
54+
- 'src-tauri/capabilities/**'
55+
- 'src-tauri/icons/**'
56+
57+
# Backend Rust tests and checks
58+
rust-backend:
59+
name: Rust Backend
60+
runs-on: ${{ matrix.os }}
61+
needs: changes
62+
if: needs.changes.outputs.backend == 'true' || needs.changes.outputs.tauri == 'true'
63+
64+
strategy:
65+
fail-fast: false
66+
matrix:
67+
os: [ ubuntu-latest, macos-latest, windows-latest ]
1868

1969
steps:
20-
- name: Fetch Repository
70+
- name: Checkout Repository
2171
uses: actions/checkout@v4
2272

23-
- name: Install stable Rust toolchain
73+
- name: Install Rust Toolchain
2474
uses: actions-rust-lang/setup-rust-toolchain@v1
2575
with:
2676
toolchain: stable
27-
target: x86_64-unknown-linux-gnu
77+
components: rustfmt, clippy
78+
cache: true
2879

29-
- name: Cache Cargo dependencies
30-
uses: actions/cache@v4
80+
- name: Install System Dependencies (Ubuntu)
81+
if: matrix.os == 'ubuntu-latest'
82+
run: |
83+
sudo apt-get update
84+
sudo apt-get install -y \
85+
libwebkit2gtk-4.0-dev \
86+
libwebkit2gtk-4.1-dev \
87+
libappindicator3-dev \
88+
librsvg2-dev \
89+
patchelf \
90+
libssl-dev \
91+
pkg-config
92+
93+
- name: Install System Dependencies (macOS)
94+
if: matrix.os == 'macos-latest'
95+
run: |
96+
# Most dependencies are already available on macOS runners
97+
echo "macOS dependencies already installed"
98+
99+
- name: Cache Rust Dependencies
100+
uses: Swatinem/rust-cache@v2
31101
with:
32-
path: |
33-
~/.cargo/bin/
34-
~/.cargo/registry/index/
35-
~/.cargo/registry/cache/
36-
~/.cargo/git/db/
37-
src-tauri/target/
38-
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
39-
restore-keys: |
40-
${{ runner.os }}-cargo-
102+
workspaces: src-tauri
103+
cache-on-failure: true
104+
shared-key: ${{ matrix.os }}-rust-cache
41105

42-
- name: Run Rust tests
106+
- name: Run Rust Tests
43107
run: |
44108
cd src-tauri
45-
cargo test --verbose
109+
cargo test --verbose --all-features
46110
47-
- name: Check Rust formatting
111+
- name: Check Rust Build
48112
run: |
49113
cd src-tauri
50-
cargo fmt --all -- --check
114+
cargo check --release
51115
52-
# Frontend tests
53-
frontend-tests:
54-
name: Frontend Tests
55-
runs-on: macos-latest
116+
# Frontend tests and checks
117+
frontend:
118+
name: Frontend
119+
runs-on: ubuntu-latest
120+
needs: changes
121+
if: needs.changes.outputs.frontend == 'true' || needs.changes.outputs.tauri == 'true'
56122

57123
steps:
58-
- name: Fetch Repository
124+
- name: Checkout Repository
59125
uses: actions/checkout@v4
60126

61127
- name: Setup pnpm
@@ -69,20 +135,101 @@ jobs:
69135
node-version: '20'
70136
cache: 'pnpm'
71137

138+
- name: Get pnpm store directory
139+
shell: bash
140+
run: |
141+
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
142+
72143
- name: Cache pnpm dependencies
144+
uses: actions/cache@v4
145+
with:
146+
path: ${{ env.STORE_PATH }}
147+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
148+
restore-keys: |
149+
${{ runner.os }}-pnpm-store-
150+
151+
- name: Install Dependencies
152+
run: pnpm install --frozen-lockfile
153+
154+
- name: Run Frontend Tests
155+
run: pnpm test
156+
env:
157+
NODE_ENV: test
158+
159+
- name: Build Frontend
160+
run: pnpm run build
161+
162+
- name: Upload Build Artifacts
163+
uses: actions/upload-artifact@v4
164+
with:
165+
name: frontend-dist
166+
path: dist/
167+
retention-days: 1
168+
169+
# Integration tests with Tauri
170+
tauri-test-build:
171+
name: Tauri Build Development
172+
runs-on: ${{ matrix.os }}
173+
needs: [ changes, frontend ]
174+
if: needs.changes.outputs.tauri == 'true' || (needs.changes.outputs.backend == 'true' && needs.changes.outputs.frontend == 'true')
175+
176+
strategy:
177+
fail-fast: false
178+
matrix:
179+
os: [ ubuntu-latest, macos-latest, windows-latest ]
180+
181+
steps:
182+
- name: Checkout Repository
183+
uses: actions/checkout@v4
184+
185+
- name: Setup pnpm
186+
uses: pnpm/action-setup@v4
187+
with:
188+
version: 9
189+
190+
- name: Setup Node.js
191+
uses: actions/setup-node@v4
192+
with:
193+
node-version: '20'
194+
cache: 'pnpm'
195+
196+
- name: Install Rust Toolchain
197+
uses: actions-rust-lang/setup-rust-toolchain@v1
198+
with:
199+
toolchain: stable
200+
cache: true
201+
202+
- name: Install System Dependencies (Ubuntu)
203+
if: matrix.os == 'ubuntu-latest'
204+
run: |
205+
sudo apt-get update
206+
sudo apt-get install -y \
207+
libwebkit2gtk-4.0-dev \
208+
libwebkit2gtk-4.1-dev \
209+
libappindicator3-dev \
210+
librsvg2-dev \
211+
patchelf \
212+
libssl-dev \
213+
pkg-config
214+
215+
- name: Cache Dependencies
73216
uses: actions/cache@v4
74217
with:
75218
path: |
76-
~/.pnpm-store
219+
~/.cargo/bin/
220+
~/.cargo/registry/index/
221+
~/.cargo/registry/cache/
222+
~/.cargo/git/db/
223+
src-tauri/target/
77224
node_modules
78-
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
225+
key: ${{ runner.os }}-tauri-${{ hashFiles('**/Cargo.lock', '**/pnpm-lock.yaml') }}
79226
restore-keys: |
80-
${{ runner.os }}-pnpm-
227+
${{ runner.os }}-tauri-
81228
82-
- name: Install dependencies
229+
- name: Install Dependencies
83230
run: pnpm install --frozen-lockfile
84231

85-
- name: Run frontend tests
86-
run: pnpm test
232+
- name: Build Tauri Application
233+
run: pnpm tauri build --verbose
87234
env:
88-
NODE_ENV: test
235+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)