forked from xtclang/xvm
-
Notifications
You must be signed in to change notification settings - Fork 0
352 lines (317 loc) · 17.4 KB
/
commit.yml
File metadata and controls
352 lines (317 loc) · 17.4 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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
# GitHub runner workflow for building, verifying and testing the XVM repo.
#
# This is the main CI workflow that runs on every push. It builds the XDK,
# runs tests, and uploads build artifacts. After a successful build, publishing
# workflows (snapshot-release, docker-build, homebrew-update) are automatically
# triggered on master branch or when manually run with test-publishing=true.
#
# PLATFORM NOTES:
# - Ubuntu: ubuntu-latest (currently Ubuntu 22.04)
# - Windows: windows-latest
#
name: Verify Commit
permissions:
contents: write
actions: write
on:
push:
# Only run on master (after PRs are merged)
branches: [master]
pull_request:
# Test all PRs before merging
branches: [master]
# Manual trigger - optionally triggers publishing workflows after successful completion
# This allows testing the full publishing pipeline (snapshot, docker, homebrew) from any branch
# without pushing to master. Set publish-snapshots=true to trigger publishing workflows.
workflow_dispatch:
inputs:
publish-snapshots:
description: 'Trigger publishing workflows after build (snapshot, docker, homebrew)'
type: boolean
required: false
default: false
platforms:
description: 'Run only single platform (ubuntu-latest, windows-latest, or all platforms)'
type: choice
required: false
default: 'ubuntu-latest'
options:
- 'ubuntu-latest'
- 'windows-latest'
- 'all'
extra-gradle-options:
description: 'Extra Gradle options to pass to the build'
required: false
skip-tests:
description: 'Skip manual tests'
type: boolean
required: false
default: false
parallel-test-mode:
description: 'Run manual tests in parallel mode'
type: boolean
required: false
default: true
env:
# Add manual tests as an included build to the composite build configuration
ORG_GRADLE_PROJECT_includeBuildManualTests: true
ORG_GRADLE_PROJECT_includeBuildAttachManualTests: true
ORG_GRADLE_PROJECT_xtcPluginOverrideVerboseLogging: true
skip_manual_tests: ${{ github.event.inputs.skip-tests == true || github.event.inputs.skip-tests == 'true' }}
run_manual_tests_parallel: ${{ github.event.inputs.parallel-test-mode == true || github.event.inputs.parallel-test-mode == 'true' }}
trigger_publishing: ${{ github.event.inputs.publish-snapshots == true || github.event.inputs.publish-snapshots == 'true' }}
# Gradle cache inspection function
GRADLE_CACHE_INSPECT: |
inspect_gradle_cache() {
local label="${1:-}"
local gradle_home="${GRADLE_USER_HOME:-$HOME/.gradle}"
echo "🔍 Gradle Cache Inspection${label:+ ($label)}:"
echo " Cache location: $gradle_home"
if [ ! -d "$gradle_home" ]; then
echo " Cache exists: ❌"
return 0
fi
echo " Cache exists: ✅"
local total_size=$(du -sh "$gradle_home" 2>/dev/null | cut -f1 || echo "unknown")
echo " Cache size: $total_size"
for dir in caches wrapper build-cache; do
if [ -d "$gradle_home/$dir" ]; then
local dir_size=$(du -sh "$gradle_home/$dir" 2>/dev/null | cut -f1 || echo "unknown")
echo " $dir: $dir_size"
fi
done
}
# Concurrency settings: group by workflow and ref to prevent duplicate runs
# Push and pull_request for the same branch will cancel each other (keeping latest)
concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}
jobs:
build-and-test:
strategy:
matrix:
os: ${{ github.event.inputs.platforms == 'ubuntu-latest' && fromJSON('["ubuntu-latest"]') || github.event.inputs.platforms == 'windows-latest' && fromJSON('["windows-latest"]') || github.event.inputs.platforms == 'all' && fromJSON('["ubuntu-latest", "windows-latest"]') || fromJSON('["ubuntu-latest"]') }}
runs-on: ${{ matrix.os }}
steps:
- name: Fetch Sources
uses: actions/checkout@v6
with:
fetch-depth: 1
show-progress: true
- name: 🚀 Publishing Configuration
shell: bash
run: |
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
# Determine if publishing will be triggered
WILL_PUBLISH=false
# Check if this is a Dependabot merge (always skip)
if [ "${{ github.actor }}" = "dependabot[bot]" ]; then
echo "::notice::⏭️ PUBLISHING DISABLED: Dependabot merge detected"
echo -e "\033[1;33m"
echo " ⏭️ NO PUBLISHING WORKFLOWS WILL BE TRIGGERED"
echo -e "\033[0m"
echo " 📋 Reason: Dependabot merges don't trigger publishing"
echo " 📋 Actor: ${{ github.actor }}"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
exit 0
fi
# Check if this is master + push
if [ "${{ github.ref }}" = "refs/heads/master" ] && [ "${{ github.event_name }}" = "push" ]; then
WILL_PUBLISH=true
TRIGGER_REASON="Push to master branch"
fi
# Check if this is manual trigger with publish-snapshots=true
if [ "${{ github.event_name }}" = "workflow_dispatch" ] && [ "${{ github.event.inputs.publish-snapshots }}" = "true" ]; then
WILL_PUBLISH=true
TRIGGER_REASON="Manual trigger with publish-snapshots=true"
fi
if [ "$WILL_PUBLISH" = "true" ]; then
echo "::notice::📦 PUBLISHING ENABLED: Snapshot publishing workflows will be triggered after successful build"
echo -e "\033[1;32m"
echo " 🚀 PUBLISHING WORKFLOWS WILL BE TRIGGERED"
echo -e "\033[0m"
echo " 📋 Reason: $TRIGGER_REASON"
echo " 📦 Workflows: Publish Snapshots, Publish Docker Images, Update Homebrew"
else
echo "::notice::⏭️ PUBLISHING DISABLED: No publishing workflows will be triggered"
echo -e "\033[1;33m"
echo " ⏭️ NO PUBLISHING WORKFLOWS WILL BE TRIGGERED"
echo -e "\033[0m"
echo " 📋 Branch: ${{ github.ref_name }}"
echo " 📋 Event: ${{ github.event_name }}"
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo " 📋 publish-snapshots: ${{ github.event.inputs.publish-snapshots }}"
fi
fi
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
- name: Setup XVM Project
id: versions
uses: ./.github/actions/setup-xvm-project
with:
setup-build: true
cache-read-only: false
enable-debug: false
- name: Debug Environment (Windows)
if: runner.os == 'Windows'
shell: bash
run: |
echo "=== Windows Debug Information ==="
echo "OS: $RUNNER_OS"
echo "Operating System: $(uname -a 2>/dev/null || echo 'N/A')"
echo "Java version:"
java -version 2>&1 || echo "Java not available"
echo "=== End Debug Information ==="
- name: Dump environment info
shell: bash
run: |
echo "*** Branch (github.ref) : ${{ github.ref }}"
echo "*** Commit (github.sha) : ${{ github.sha }}"
echo "*** Runner OS : ${{ runner.os }}"
echo "*** XDK Version : ${{ steps.versions.outputs.xdk-version }}"
echo "*** Java Version : ${{ steps.versions.outputs.java-version }}"
- name: Build the XDK and create a distribution
shell: bash
env:
GRADLE_OPTS: ${{ steps.versions.outputs.gradle-jvm-opts }}
run: |
${{ env.GRADLE_CACHE_INSPECT }}
# Combine standard options with optional extra options
GRADLE_OPTIONS="${{ steps.versions.outputs.gradle-options }} ${{ github.event.inputs.extra-gradle-options }}"
cwd_path=$(pwd)
echo "Executing Gradle 'clean', 'check', and 'distZip' tasks from: '$cwd_path'"
ls -la build/ 2>/dev/null && echo "Build directory exists - will be cleaned" || echo "✅ No previous build outputs"
inspect_gradle_cache "before build"
./gradlew $GRADLE_OPTIONS clean
./gradlew $GRADLE_OPTIONS distZip check -Porg.xtclang.java.lint=true -Porg.xtclang.java.warningsAsErrors=false -Porg.xtclang.java.test.stdout=true
# Run manual tests inline if enabled (avoids cache rebuild)
if [ "${{ env.skip_manual_tests }}" == "true" ]; then
echo "⏭️ Manual tests skipped (disabled)"
exit 0
fi
echo "🧪 Running manual tests inline (cache still hot)..."
inspect_gradle_cache "before manual tests"
manual_task_main=$( [ "${{ env.run_manual_tests_parallel }}" = "true" ] && echo "runParallel" || echo "runAllTestTasks" )
echo "Running manual tests (main task: $manual_task_main)"
./gradlew $GRADLE_OPTIONS manualTests:runXtc manualTests:runOne -PtestName=TestMisc manualTests:runTwoTestsInSequence "manualTests:$manual_task_main"
inspect_gradle_cache "after manual tests"
echo "✅ Manual tests completed"
- name: Upload XDK distribution artifact
if: success() && matrix.os == 'ubuntu-latest'
uses: actions/upload-artifact@v5
with:
name: xdk-dist-${{ github.sha }}
path: xdk/build/distributions/xdk-*.zip
retention-days: 10
- name: Summary
if: success()
shell: bash
run: |
echo "### ✅ Build and Test Completed" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "- **Version:** ${{ steps.versions.outputs.xdk-version }}" >> $GITHUB_STEP_SUMMARY
echo "- **Java Version:** ${{ steps.versions.outputs.java-version }}" >> $GITHUB_STEP_SUMMARY
echo "- **Commit:** ${{ github.sha }}" >> $GITHUB_STEP_SUMMARY
echo "- **Branch:** ${{ github.ref_name }}" >> $GITHUB_STEP_SUMMARY
# Summary job that always succeeds if build-and-test completes
# Use this for branch protection instead of individual matrix jobs
build-complete:
name: All builds complete
needs: build-and-test
runs-on: ubuntu-latest
if: always()
steps:
- name: Check build status
run: |
if [ "${{ needs.build-and-test.result }}" != "success" ]; then
echo "❌ Build failed or was cancelled"
exit 1
fi
echo "✅ All builds completed successfully"
# Trigger publishing workflows for snapshots
# Runs when:
# 1. Push to master (automatic snapshot publishing) - BUT NOT for release merges or Dependabot merges
# 2. Manual trigger with publish-snapshots=true (testing from any branch)
#
# Release merges are handled by promote-release.yml workflow instead
# Dependabot merges are skipped to avoid permission issues
trigger-publishing:
name: Trigger snapshot publishing workflows
needs: build-and-test
runs-on: ubuntu-latest
if: |
success() &&
github.actor != 'dependabot[bot]' &&
(
(github.ref == 'refs/heads/master' && github.event_name == 'push')
||
(github.event_name == 'workflow_dispatch' &&
(github.event.inputs.publish-snapshots == true || github.event.inputs.publish-snapshots == 'true'))
)
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 10 # Need history to check for release tags
- name: Check if this is a release merge
id: check-release
run: |
# Check if current commit has a release tag (v*.*.*)
# Release merges should use promote-release.yml, not snapshot publishing
RELEASE_TAG=$(git tag --points-at HEAD | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' || true)
if [ -n "$RELEASE_TAG" ]; then
echo "is-release=true" >> $GITHUB_OUTPUT
echo "release-tag=$RELEASE_TAG" >> $GITHUB_OUTPUT
echo "🏷️ Detected release tag: $RELEASE_TAG"
echo "⏭️ Skipping snapshot publishing (will be handled by promote-release.yml)"
else
echo "is-release=false" >> $GITHUB_OUTPUT
echo "✅ No release tag detected - proceeding with snapshot publishing"
fi
- name: Trigger snapshot publishing
if: steps.check-release.outputs.is-release != 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "🚀 Triggering Publish Snapshots workflow..."
gh workflow run "Publish Snapshots" --repo ${{ github.repository }} --ref ${{ github.ref_name }} --field ci-run-id=${{ github.run_id }}
echo "✅ Snapshot publishing triggered"
- name: Trigger Docker publishing
if: steps.check-release.outputs.is-release != 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "🚀 Triggering Publish Docker Images workflow..."
gh workflow run "Publish Docker Images" --repo ${{ github.repository }} --ref ${{ github.ref_name }} --field ci-run-id=${{ github.run_id }}
echo "✅ Docker publishing triggered"
- name: Trigger Homebrew update
if: steps.check-release.outputs.is-release != 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "🚀 Triggering Update Homebrew workflow..."
gh workflow run "Update Homebrew" --repo ${{ github.repository }} --ref ${{ github.ref_name }} --field ci-run-id=${{ github.run_id }}
echo "✅ Homebrew update triggered"
- name: Summary - Snapshots Triggered
if: steps.check-release.outputs.is-release != 'true'
run: |
echo "### 🚀 Publishing Workflows Triggered" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "The following workflows have been triggered:" >> $GITHUB_STEP_SUMMARY
echo "- ✅ Snapshot publishing" >> $GITHUB_STEP_SUMMARY
echo "- ✅ Docker publishing" >> $GITHUB_STEP_SUMMARY
echo "- ✅ Homebrew update" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Check the [Actions tab](https://github.com/${{ github.repository }}/actions) for workflow status." >> $GITHUB_STEP_SUMMARY
- name: Summary - Release Detected
if: steps.check-release.outputs.is-release == 'true'
run: |
echo "### 🏷️ Release Merge Detected" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Release Tag:** ${{ steps.check-release.outputs.release-tag }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Snapshot publishing skipped - release promotion will be handled by promote-release.yml workflow." >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Check the [Actions tab](https://github.com/${{ github.repository }}/actions) for promote-release workflow status." >> $GITHUB_STEP_SUMMARY