1+ name : Build Test
2+
3+ # Trigger on every push and pull request
4+ on :
5+ push :
6+ branches : [ main, develop, 'release/**', 'feature/**' ]
7+ pull_request :
8+ branches : [ main, develop ]
9+ types : [opened, synchronize, reopened]
10+
11+ # Cancel in-progress workflows when a new commit is pushed
12+ concurrency :
13+ group : ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
14+ cancel-in-progress : true
15+
16+ env :
17+ CARGO_TERM_COLOR : always
18+ RUST_BACKTRACE : 1
19+
20+ jobs :
21+ build-test :
22+ name : Build Test (${{ matrix.platform.name }})
23+
24+ strategy :
25+ fail-fast : false
26+ matrix :
27+ platform :
28+ - name : Linux
29+ os : ubuntu-latest
30+ rust-target : x86_64-unknown-linux-gnu
31+ - name : Windows
32+ os : windows-latest
33+ rust-target : x86_64-pc-windows-msvc
34+ - name : macOS
35+ os : macos-latest
36+ rust-target : x86_64-apple-darwin
37+
38+ runs-on : ${{ matrix.platform.os }}
39+
40+ steps :
41+ # Checkout the repository
42+ - name : Checkout repository
43+ uses : actions/checkout@v4
44+ with :
45+ fetch-depth : 0
46+
47+ # Install system dependencies for Linux
48+ - name : Install Linux dependencies
49+ if : matrix.platform.os == 'ubuntu-latest'
50+ run : |
51+ sudo apt-get update
52+ sudo apt-get install -y \
53+ libwebkit2gtk-4.1-dev \
54+ libgtk-3-dev \
55+ libayatana-appindicator3-dev \
56+ librsvg2-dev \
57+ libssl-dev \
58+ libglib2.0-dev \
59+ libjavascriptcoregtk-4.1-dev \
60+ libsoup-3.0-dev \
61+ libxdo-dev \
62+ libxcb-shape0-dev \
63+ libxcb-xfixes0-dev
64+
65+ # Setup Rust with caching
66+ - name : Setup Rust
67+ uses : dtolnay/rust-toolchain@stable
68+ with :
69+ targets : ${{ matrix.platform.rust-target }}
70+
71+ # Cache Rust dependencies
72+ - name : Cache Rust dependencies
73+ uses : Swatinem/rust-cache@v2
74+ with :
75+ workspaces : ' ./src-tauri -> target'
76+ key : ${{ matrix.platform.os }}-rust-${{ hashFiles('**/Cargo.lock') }}
77+
78+ # Setup Bun
79+ - name : Setup Bun
80+ uses : oven-sh/setup-bun@v2
81+ with :
82+ bun-version : latest
83+
84+ # Cache Bun dependencies
85+ - name : Cache Bun dependencies
86+ uses : actions/cache@v4
87+ with :
88+ path : |
89+ ~/.bun
90+ node_modules
91+ key : ${{ matrix.platform.os }}-bun-${{ hashFiles('bun.lockb', 'package.json') }}
92+ restore-keys : |
93+ ${{ matrix.platform.os }}-bun-
94+
95+ # Install frontend dependencies
96+ - name : Install frontend dependencies
97+ run : bun install --frozen-lockfile
98+
99+ # Build frontend
100+ - name : Build frontend
101+ run : bun run build
102+
103+ # Check Rust formatting
104+ - name : Check Rust formatting
105+ if : matrix.platform.os == 'ubuntu-latest'
106+ working-directory : ./src-tauri
107+ run : |
108+ rustup component add rustfmt
109+ cargo fmt -- --check
110+
111+ # Run Rust linter
112+ - name : Run Rust linter
113+ if : matrix.platform.os == 'ubuntu-latest'
114+ working-directory : ./src-tauri
115+ run : |
116+ rustup component add clippy
117+ cargo clippy -- -D warnings
118+
119+ # Build Tauri application (no bundle for faster CI)
120+ - name : Build Tauri application
121+ run : bun run tauri build --no-bundle -d
122+ env :
123+ TAURI_SIGNING_PRIVATE_KEY : " "
124+ TAURI_SIGNING_PRIVATE_KEY_PASSWORD : " "
125+
126+ # Upload build artifacts for debugging (optional)
127+ - name : Upload build logs on failure
128+ if : failure()
129+ uses : actions/upload-artifact@v4
130+ with :
131+ name : build-logs-${{ matrix.platform.name }}
132+ path : |
133+ src-tauri/target/release/build/*/output
134+ src-tauri/target/debug/build/*/output
135+ retention-days : 3
136+
137+ # Summary job to ensure all builds pass
138+ build-test-summary :
139+ name : Build Test Summary
140+ runs-on : ubuntu-latest
141+ needs : [build-test]
142+ if : always()
143+
144+ steps :
145+ - name : Check build results
146+ run : |
147+ if [[ "${{ needs.build-test.result }}" == "failure" ]]; then
148+ echo "❌ One or more build tests failed"
149+ exit 1
150+ elif [[ "${{ needs.build-test.result }}" == "cancelled" ]]; then
151+ echo "⚠️ Build tests were cancelled"
152+ exit 1
153+ else
154+ echo "✅ All build tests passed successfully"
155+ fi
156+
157+ - name : Create status comment (PR only)
158+ if : github.event_name == 'pull_request'
159+ uses : actions/github-script@v7
160+ with :
161+ script : |
162+ const result = '${{ needs.build-test.result }}';
163+ const emoji = result === 'success' ? '✅' : '❌';
164+ const status = result === 'success' ? 'All build tests passed!' : 'Build tests failed';
165+
166+ // Create a comment summarizing the build status
167+ const comment = `## ${emoji} Build Test Results
168+
169+ **Status**: ${status}
170+ **Commit**: ${{ github.event.pull_request.head.sha || github.sha }}
171+
172+ | Platform | Status |
173+ |----------|--------|
174+ | Linux | ${{ contains(needs.build-test.result, 'success') && '✅' || '❌' }} |
175+ | Windows | ${{ contains(needs.build-test.result, 'success') && '✅' || '❌' }} |
176+ | macOS | ${{ contains(needs.build-test.result, 'success') && '✅' || '❌' }} |
177+
178+ [View full workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})`;
179+
180+ // Only post comment if it's a PR
181+ if (context.eventName === 'pull_request') {
182+ await github.rest.issues.createComment({
183+ owner: context.repo.owner,
184+ repo: context.repo.repo,
185+ issue_number: context.issue.number,
186+ body: comment
187+ });
188+ }
0 commit comments