-
Notifications
You must be signed in to change notification settings - Fork 1.7k
175 lines (151 loc) · 5.41 KB
/
build-test.yml
File metadata and controls
175 lines (151 loc) · 5.41 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
name: Build Test
# Trigger on every push and pull request
on:
push:
branches: [main, develop, "release/**", "feature/**"]
pull_request:
branches: [main, develop]
types: [opened, synchronize, reopened]
# Cancel in-progress workflows when a new commit is pushed
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
jobs:
build-test:
name: Build Test (${{ matrix.platform.name }})
strategy:
fail-fast: false
matrix:
platform:
- name: Linux
os: ubuntu-latest
rust-target: x86_64-unknown-linux-gnu
- name: Linux ARM64
os: ubuntu-24.04-arm64
rust-target: aarch64-unknown-linux-gnu
- name: Windows
os: windows-latest
rust-target: x86_64-pc-windows-msvc
- name: macOS
os: macos-latest
rust-target: x86_64-apple-darwin
runs-on: ${{ matrix.platform.os }}
steps:
# Checkout the repository
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
# Install system dependencies for Linux
- name: Install Linux dependencies
if: matrix.platform.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y \
libwebkit2gtk-4.1-dev \
libgtk-3-dev \
libayatana-appindicator3-dev \
librsvg2-dev \
libssl-dev \
libglib2.0-dev \
libjavascriptcoregtk-4.1-dev \
libsoup-3.0-dev \
libxdo-dev \
libxcb-shape0-dev \
libxcb-xfixes0-dev
# Setup Rust with caching
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.platform.rust-target }}
# Cache Rust dependencies
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@v2
with:
workspaces: "./src-tauri -> target"
key: ${{ matrix.platform.os }}-rust-${{ hashFiles('**/Cargo.lock') }}
# Setup Bun
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
# Cache Bun dependencies
- name: Cache Bun dependencies
uses: actions/cache@v4
with:
path: |
~/.bun
node_modules
key: ${{ matrix.platform.os }}-bun-${{ hashFiles('bun.lockb', 'package.json') }}
restore-keys: |
${{ matrix.platform.os }}-bun-
# Install frontend dependencies
- name: Install frontend dependencies
run: bun install --frozen-lockfile
# Build frontend
- name: Build frontend
run: bun run build
# Build Tauri application
- name: Build Tauri application
run: bun run tauri build --no-bundle -d
env:
TAURI_SIGNING_PRIVATE_KEY: ""
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ""
# Upload build artifacts for debugging (optional)
- name: Upload build logs on failure
if: failure()
uses: actions/upload-artifact@v4
with:
name: build-logs-${{ matrix.platform.name }}
path: |
src-tauri/target/release/build/*/output
src-tauri/target/debug/build/*/output
retention-days: 3
# Summary job to ensure all builds pass
build-test-summary:
name: Build Test Summary
runs-on: ubuntu-latest
needs: [build-test]
if: always()
steps:
- name: Check build results
run: |
if [[ "${{ needs.build-test.result }}" == "failure" ]]; then
echo "❌ One or more build tests failed"
exit 1
elif [[ "${{ needs.build-test.result }}" == "cancelled" ]]; then
echo "⚠️ Build tests were cancelled"
exit 1
else
echo "✅ All build tests passed successfully"
fi
- name: Create status comment (PR only)
if: github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
script: |
const result = '${{ needs.build-test.result }}';
const emoji = result === 'success' ? '✅' : '❌';
const status = result === 'success' ? 'All build tests passed!' : 'Build tests failed';
// Create a comment summarizing the build status
const comment = `## ${emoji} Build Test Results
**Status**: ${status}
**Commit**: ${{ github.event.pull_request.head.sha || github.sha }}
| Platform | Status |
|----------|--------|
| Linux | ${{ contains(needs.build-test.result, 'success') && '✅' || '❌' }} |
| Windows | ${{ contains(needs.build-test.result, 'success') && '✅' || '❌' }} |
| macOS | ${{ contains(needs.build-test.result, 'success') && '✅' || '❌' }} |
[View full workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})`;
// Only post comment if it's a PR
if (context.eventName === 'pull_request') {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: comment
});
}