-
Notifications
You must be signed in to change notification settings - Fork 1
210 lines (188 loc) · 7.12 KB
/
ci.yml
File metadata and controls
210 lines (188 loc) · 7.12 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
name: CI
on:
push:
branches: [main]
paths:
- 'packages/**'
- 'tests/**'
- '.github/**'
- '.xlings.json'
pull_request:
branches: [main]
paths:
- 'packages/**'
- 'tests/**'
- '.github/**'
- '.xlings.json'
env:
XLINGS_NON_INTERACTIVE: 1
jobs:
detect-changes:
runs-on: ubuntu-24.04
outputs:
packages: ${{ steps.detect.outputs.packages }}
build_all: ${{ steps.detect.outputs.build_all }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Detect changed packages
id: detect
run: |
if [ "${{ github.event_name }}" = "pull_request" ]; then
BASE="${{ github.event.pull_request.base.sha }}"
else
BASE="${{ github.event.before }}"
fi
CI_CHANGED=$(git diff --name-only "$BASE" HEAD -- .github/ .xlings.json || true)
if [ -n "$CI_CHANGED" ]; then
echo "build_all=true" >> "$GITHUB_OUTPUT"
echo "CI config changed, will build all packages"
else
echo "build_all=false" >> "$GITHUB_OUTPUT"
fi
CHANGED_DIRS=$(git diff --name-only "$BASE" HEAD -- packages/ tests/ | \
sed -n 's|^packages/./\([^/]*\)/.*|\1|p; s|^tests/./\([^/]*\)/.*|\1|p' | \
sort -u)
JSON="["
FIRST=true
for pkg in $CHANGED_DIRS; do
if [ "$FIRST" = true ]; then FIRST=false; else JSON="$JSON,"; fi
JSON="$JSON\"$pkg\""
done
JSON="$JSON]"
echo "packages=$JSON" >> "$GITHUB_OUTPUT"
echo "Changed packages: $JSON"
build:
needs: detect-changes
if: needs.detect-changes.outputs.build_all == 'true' || needs.detect-changes.outputs.packages != '[]'
strategy:
fail-fast: false
matrix:
include:
- { os: ubuntu-24.04, shell: bash }
- { os: macos-15, shell: bash }
- { os: windows-latest, shell: pwsh }
runs-on: ${{ matrix.os }}
name: build (${{ matrix.os }})
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-toolchain
- name: Configure (linux)
if: runner.os == 'Linux'
working-directory: tests
run: |
MUSL_VER=$(python3 -c "import json; print(json.load(open('../.xlings.json'))['workspace']['musl-gcc']['linux'])")
MUSL_SDK="$HOME/.xlings/data/xpkgs/xim-x-musl-gcc/${MUSL_VER}"
xmake f -P . -y -vv \
--sdk="${MUSL_SDK}" \
--cross=x86_64-linux-musl- \
--cc="${MUSL_SDK}/bin/x86_64-linux-musl-gcc" \
--cxx="${MUSL_SDK}/bin/x86_64-linux-musl-g++"
- name: Configure (macos)
if: runner.os == 'macOS'
working-directory: tests
run: |
LLVM_VER=$(python3 -c "import json; print(json.load(open('../.xlings.json'))['workspace']['llvm']['macosx'])")
LLVM_SDK="$HOME/.xlings/data/xpkgs/xim-x-llvm/${LLVM_VER}"
xmake f -P . -y -vv --toolchain=llvm --sdk="${LLVM_SDK}"
- name: Configure (windows)
if: runner.os == 'Windows'
working-directory: tests
run: xmake f -P . -y -vv
- name: Build and test (unix)
if: runner.os != 'Windows'
working-directory: tests
env:
BUILD_ALL: ${{ needs.detect-changes.outputs.build_all }}
CHANGED_PACKAGES: ${{ needs.detect-changes.outputs.packages }}
run: |
TARGETS=""
if [ "$BUILD_ALL" = "true" ]; then
TARGETS=$(grep -r 'target("' */*/xmake.lua 2>/dev/null | sed 's/.*target("\([^"]*\)").*/\1/' | sort -u)
echo "Building ALL targets: $TARGETS"
else
for pkg in $(echo "$CHANGED_PACKAGES" | tr -d '[]"' | tr ',' ' '); do
TARGET="${pkg}_test"
if grep -rq "target(\"$TARGET\")" */*/xmake.lua 2>/dev/null; then
TARGETS="$TARGETS $TARGET"
else
echo "Warning: no test target '$TARGET' found for package '$pkg', skipping"
fi
done
echo "Building changed targets: $TARGETS"
fi
# Skip known-incompatible targets:
# - llmapi_test: requires API key, xmake module transitive dep issue
# - mo_yanxi-react_flow_test: uses TU-local lambdas in type aliases,
# GCC rejects per C++23 [basic.link]/15 (Clang-only for now)
TARGETS=$(echo "$TARGETS" | tr ' ' '\n' | grep -v -E 'llmapi_test|mo_yanxi-react_flow_test' | tr '\n' ' ')
FAILED=""
for target in $TARGETS; do
echo "=== Building $target ==="
if ! xmake build -P . -y "$target"; then
echo "FAILED to build $target"
FAILED="$FAILED $target"
continue
fi
echo "=== Running $target ==="
if [ "$target" = "cmdline_test" ]; then
xmake run -P . "$target" test_input
else
xmake run -P . "$target"
fi
done
if [ -n "$FAILED" ]; then
echo "::error::Failed targets:$FAILED"
exit 1
fi
- name: Build and test (windows)
if: runner.os == 'Windows'
working-directory: tests
env:
BUILD_ALL: ${{ needs.detect-changes.outputs.build_all }}
CHANGED_PACKAGES: ${{ needs.detect-changes.outputs.packages }}
run: |
$targets = @()
if ($env:BUILD_ALL -eq "true") {
$targets = Get-ChildItem -Recurse -Filter "xmake.lua" -Path "*/*" |
Select-String 'target\("([^"]+)"\)' |
ForEach-Object { $_.Matches[0].Groups[1].Value } |
Sort-Object -Unique
Write-Host "Building ALL targets: $($targets -join ', ')"
} else {
$packages = $env:CHANGED_PACKAGES | ConvertFrom-Json
foreach ($pkg in $packages) {
$target = "${pkg}_test"
$found = Get-ChildItem -Recurse -Filter "xmake.lua" -Path "*/*" |
Select-String "target\(`"$target`"\)" -Quiet
if ($found) {
$targets += $target
} else {
Write-Host "Warning: no test target '$target' found for package '$pkg', skipping"
}
}
Write-Host "Building changed targets: $($targets -join ', ')"
}
# Skip llmapi_test (same reason as unix)
$targets = $targets | Where-Object { $_ -ne "llmapi_test" }
$failed = @()
foreach ($target in $targets) {
Write-Host "=== Building $target ==="
xmake build -P . -y $target
if ($LASTEXITCODE -ne 0) {
Write-Host "FAILED to build $target"
$failed += $target
continue
}
Write-Host "=== Running $target ==="
if ($target -eq "cmdline_test") {
xmake run -P . $target test_input
} else {
xmake run -P . $target
}
}
if ($failed.Count -gt 0) {
Write-Host "::error::Failed targets: $($failed -join ', ')"
exit 1
}