forked from 1lck/Lithe-IDEA
-
Notifications
You must be signed in to change notification settings - Fork 0
220 lines (187 loc) · 5.98 KB
/
Copy pathci-macos.yml
File metadata and controls
220 lines (187 loc) · 5.98 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
name: macOS CI
on:
pull_request:
push:
branches:
- main
workflow_dispatch:
permissions:
contents: read
concurrency:
group: macos-ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
changes:
name: Classify changes
runs-on: ubuntu-latest
outputs:
full: ${{ steps.classify.outputs.full }}
steps:
- name: Check out source
uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Classify changed paths
id: classify
env:
EVENT_NAME: ${{ github.event_name }}
PR_BASE_SHA: ${{ github.event.pull_request.base.sha }}
PUSH_BASE_SHA: ${{ github.event.before }}
shell: bash
run: |
if [[ "$EVENT_NAME" == "workflow_dispatch" ]]; then
echo "full=true" >> "$GITHUB_OUTPUT"
exit 0
fi
base_sha="$PUSH_BASE_SHA"
if [[ "$EVENT_NAME" == "pull_request" ]]; then
base_sha="$PR_BASE_SHA"
fi
full=false
while IFS= read -r path; do
case "$path" in
README.md|README.zh-CN.md|docs/*|Casks/*)
;;
*)
full=true
break
;;
esac
done < <(git diff --name-only "$base_sha" "$GITHUB_SHA")
echo "full=$full" >> "$GITHUB_OUTPUT"
- name: Validate lightweight changes
if: steps.classify.outputs.full == 'false'
shell: bash
run: |
git diff --check "${{ github.event.pull_request.base.sha || github.event.before }}" "$GITHUB_SHA"
ruby -c Casks/lithe.rb
ruby -c scripts/update-homebrew-cask.rb
swift-tests:
name: Swift tests
needs: changes
if: needs.changes.outputs.full == 'true'
runs-on: macos-14
timeout-minutes: 20
steps:
- name: Check out source
uses: actions/checkout@v7
- name: Set up Swift
uses: swift-actions/setup-swift@v2
with:
swift-version: "6.2"
- name: Restore SwiftPM dependencies
uses: actions/cache@v6
with:
path: |
.build/checkouts
.build/repositories
~/.cache/org.swift.swiftpm
key: swiftpm-${{ runner.os }}-6.2-${{ hashFiles('Package.resolved') }}
- name: Run Swift tests
run: ./scripts/test-macos.sh
rust-tests:
name: Rust Core and database tests
needs: changes
if: needs.changes.outputs.full == 'true'
runs-on: macos-14
timeout-minutes: 20
steps:
- name: Check out source
uses: actions/checkout@v7
- name: Set up Swift
uses: swift-actions/setup-swift@v2
with:
swift-version: "6.2"
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- name: Restore Cargo dependencies
uses: actions/cache@v6
with:
path: |
~/.cargo/git
~/.cargo/registry
key: cargo-dependencies-${{ runner.os }}-${{ hashFiles('rust/Cargo.lock') }}
- name: Run Rust Core tests and verify the Swift bridge
run: ./scripts/verify-rust-core.sh
- name: Test database helpers
run: |
cargo fmt --manifest-path rust/Cargo.toml --all -- --check
cargo test --manifest-path rust/Cargo.toml -p lithe-db-sidecar
cargo test --manifest-path rust/Cargo.toml -p lithe-db-mcp
release-build:
name: Release configuration
needs: changes
if: needs.changes.outputs.full == 'true'
runs-on: macos-14
timeout-minutes: 20
steps:
- name: Check out source
uses: actions/checkout@v7
- name: Set up Swift
uses: swift-actions/setup-swift@v2
with:
swift-version: "6.2"
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: aarch64-apple-darwin,x86_64-apple-darwin
- name: Restore SwiftPM dependencies
uses: actions/cache@v6
with:
path: |
.build/checkouts
.build/repositories
~/.cache/org.swift.swiftpm
key: swiftpm-${{ runner.os }}-6.2-${{ hashFiles('Package.resolved') }}
- name: Restore Cargo dependencies
uses: actions/cache@v6
with:
path: |
~/.cargo/git
~/.cargo/registry
key: cargo-dependencies-${{ runner.os }}-${{ hashFiles('rust/Cargo.lock') }}
- name: Resolve host architecture
shell: zsh {0}
run: |
case "$(uname -m)" in
arm64) swift_triple="arm64-apple-macosx" ;;
x86_64) swift_triple="x86_64-apple-macosx" ;;
*) print -u2 -- "Unsupported host architecture: $(uname -m)"; exit 1 ;;
esac
print -r -- "LITHE_SWIFT_TRIPLE=$swift_triple" >> "$GITHUB_ENV"
- name: Check packaging scripts and metadata
shell: zsh {0}
run: |
for script in scripts/*.sh; do
if [[ "$(head -n 1 "$script")" == "#!/bin/zsh" ]]; then
zsh -n "$script"
fi
done
ruby -c scripts/update-homebrew-cask.rb
plutil -lint Resources/Info.plist
- name: Build release configuration
run: ./scripts/build-macos.sh --configuration release --triple "$LITHE_SWIFT_TRIPLE"
gate:
name: macOS CI gate
needs:
- changes
- swift-tests
- rust-tests
- release-build
if: always()
runs-on: ubuntu-latest
steps:
- name: Verify required jobs
env:
CHANGES_RESULT: ${{ needs.changes.result }}
SWIFT_RESULT: ${{ needs.swift-tests.result }}
RUST_RESULT: ${{ needs.rust-tests.result }}
RELEASE_RESULT: ${{ needs.release-build.result }}
shell: bash
run: |
[[ "$CHANGES_RESULT" == "success" ]]
for result in "$SWIFT_RESULT" "$RUST_RESULT" "$RELEASE_RESULT"; do
[[ "$result" == "success" || "$result" == "skipped" ]]
done