Repository navigation
858 lines (814 loc) · 35.9 KB
/
Copy pathcurrent.yml
File metadata and controls
858 lines (814 loc) · 35.9 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
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
name: Current
permissions:
contents: read
on:
push:
branches:
- 'main'
- '*-stable'
tags:
- '!*'
pull_request:
branches:
- '*'
workflow_dispatch:
concurrency:
group: '${{ github.workflow }}-${{ github.ref }}'
cancel-in-progress: true
jobs:
detect:
name: Detect changed gems
runs-on: ubuntu-latest
outputs:
count: ${{ steps.changed-gems.outputs.count }}
matrix: ${{ steps.changed-gems.outputs.matrix }}
summary: ${{ steps.changed-gems.outputs.summary }}
release_mode: ${{ steps.changed-gems.outputs.release_mode }}
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
- name: Install nomono for Gemfile evaluation
# The contract tests evaluate real Gemfiles, which bootstrap nomono for *_DEV wiring.
run: gem install --user-install nomono --version '>= 1.1.18'
- name: Validate typed core workflow contract
run: python3 -m unittest discover -s .github/tests -v
- name: Detect changed gems
id: changed-gems
shell: bash
env:
BASE_SHA: ${{ github.event.pull_request.base.sha || github.event.before }}
run: |
set -euo pipefail
base_sha="${BASE_SHA:-}"
if [[ -z "${base_sha}" || "${base_sha}" =~ ^0+$ ]]; then
base_sha="$(git rev-parse HEAD^ 2>/dev/null || git rev-list --max-parents=0 HEAD)"
fi
changed_files="${RUNNER_TEMP}/changed-files.txt"
git diff --name-only "${base_sha}...HEAD" > "${changed_files}"
python3 - "${changed_files}" "${GITHUB_OUTPUT}" "${GITHUB_EVENT_PATH}" <<'PY'
import json
import pathlib
import sys
changed_files_path = pathlib.Path(sys.argv[1])
github_output = pathlib.Path(sys.argv[2])
event_path = pathlib.Path(sys.argv[3])
changed = [line.strip() for line in changed_files_path.read_text().splitlines() if line.strip()]
event = json.loads(event_path.read_text())
message = event.get("head_commit", {}).get("message", "")
release_mode = (
"validation" if "[kettle-family:aggregate-ci]" in message else
"member" if "[kettle-family:aggregate-member]" in message else
""
)
all_gems = sorted(
str(path)
for path in pathlib.Path("gems").iterdir()
if path.is_dir() and any(path.glob("*.gemspec"))
)
gems = sorted(
{
"/".join(path.split("/")[:2])
for path in changed
if path.startswith("gems/") and len(path.split("/")) > 2
}
)
gems = [gem for gem in gems if gem in all_gems]
family_input_changed = any(
path.startswith(".github/") or path in {
"Gemfile",
"Gemfile.lock",
".structuredmerge/fixtures.lock",
".structuredmerge/benchmark-fixtures.lock",
".github/workflows/current.yml",
}
for path in changed
)
if family_input_changed and not release_mode:
gems = all_gems
# Aggregate family releases validate the root suite once before
# publishing members. The marker is written only by kettle-family;
# ordinary and independent releases retain the changed-gem matrix.
if release_mode:
gems = []
matrix = {"gem": gems}
summary = ", ".join(gems) if gems else "No changed gem suites selected"
with github_output.open("a", encoding="utf-8") as output:
output.write(f"count={len(gems)}\n")
output.write(f"matrix={json.dumps(matrix, separators=(',', ':'))}\n")
output.write(f"summary={summary}\n")
output.write(f"release_mode={release_mode}\n")
print(f"Changed files: {len(changed)}")
print(f"Selected gem suites: {summary}")
print(f"Aggregate release mode: {release_mode or 'none'}")
PY
gem-suite:
name: Gem suite with core artifact (${{ matrix.gem }})
needs: [detect, typed-core]
if: ${{ needs.detect.outputs.count != '0' && needs.detect.outputs.release_mode == '' }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.detect.outputs.matrix) }}
env:
BUNDLE_GEMFILE: ${{ github.workspace }}/${{ matrix.gem }}/ci_core.gemfile
KETTLE_FAMILY_BUNDLE_GEMFILE: ${{ github.workspace }}/${{ matrix.gem }}/ci_core.gemfile
STRUCTUREDMERGE_CI_GEM_DIR: ${{ github.workspace }}/${{ matrix.gem }}
STRUCTUREDMERGE_CI_DEP_HEADS: "false"
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Clone sibling fixtures repo
shell: bash
run: |
set -euo pipefail
fixtures_repository="$(ruby -ryaml -e 'puts YAML.load_file(".structuredmerge/fixtures.lock").fetch("repository")')"
fixtures_branch="$(ruby -ryaml -e 'puts YAML.load_file(".structuredmerge/fixtures.lock").fetch("branch")')"
fixtures_revision="$(ruby -ryaml -e 'puts YAML.load_file(".structuredmerge/fixtures.lock").fetch("revision")')"
git clone --filter=blob:none --no-checkout "${fixtures_repository}" ../fixtures
git -C ../fixtures fetch origin "refs/heads/${fixtures_branch}:refs/remotes/origin/${fixtures_branch}"
git -C ../fixtures checkout --detach "${fixtures_revision}"
test "$(git -C ../fixtures rev-parse HEAD)" = "${fixtures_revision}"
git -C ../fixtures merge-base --is-ancestor "${fixtures_revision}" "refs/remotes/origin/${fixtures_branch}"
- name: Setup Ruby
uses: appraisal-rb/setup-ruby-flash@6f8ad36ba7488db591541483afb5464d01e8861b # v2.14
with:
ruby-version: "4.0"
bundler: latest
bundler-cache: false
working-directory: ${{ matrix.gem }}
pre-bundle-gems: |
nomono --source https://gem.coop --source https://rubygems.org
- name: Install verified typed core artifact
uses: ./.github/actions/typed-core
- name: Install dependencies
working-directory: ${{ matrix.gem }}
env:
K_JEM_TEMPLATING: true
STRUCTUREDMERGE_DEV: ${{ github.workspace }}/gems
run: |
bundle config set frozen false
for attempt in 1 2 3; do
if bundle install --jobs 4 --retry 8; then
exit 0
fi
if [[ "${attempt}" -lt 3 ]]; then
sleep "$((attempt * 5))"
fi
done
exit 1
- name: Verify installed typed core loads
env:
K_JEM_TEMPLATING: true
STRUCTUREDMERGE_DEV: ${{ github.workspace }}/gems
run: bundle exec ruby .github/verify_typed_core.rb
- name: Run checks
working-directory: ${{ matrix.gem }}
env:
K_JEM_TEMPLATING: true
K_SOUP_COV_DO: false
STRUCTUREDMERGE_DEV: ${{ github.workspace }}/gems
run: timeout 12m bundle exec kettle-test
typed-core:
name: Typed core artifact @ HEAD (pre-publication)
needs: detect
if: ${{ needs.detect.outputs.count != '0' && needs.detect.outputs.release_mode == '' }}
runs-on: ubuntu-latest
timeout-minutes: 30
env:
CARGO_BUILD_JOBS: "1"
CARGO_INCREMENTAL: "0"
CARGO_PROFILE_DEV_DEBUG: "0"
CARGO_PROFILE_TEST_DEBUG: "0"
CARGO_TARGET_DIR: ${{ github.workspace }}/kernel/tmp/typed-core-target
steps:
- name: Checkout Ruby provider candidate
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
path: native-ruby
persist-credentials: false
- name: Checkout kernel HEAD
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
repository: structuredmerge/structuredmerge
ref: main
path: kernel
persist-credentials: false
- name: Record kernel revision
working-directory: kernel
run: git rev-parse HEAD
- name: Setup Rust
uses: dtolnay/rust-toolchain@683b588c487a69d01f6c6ddf40f036ff682cc2c8
with:
toolchain: stable
- name: Setup Ruby
uses: ruby/setup-ruby@e1bd6146574da5e0795075b5319b300edb30c5b0 # v1.333.0
with:
ruby-version: "4.0"
bundler-cache: false
- name: Build committed typed bindings and export platform gem
working-directory: kernel/packages/ruby
shell: bash
run: |
set -euo pipefail
ulimit -c 0
mkdir -p ../../tmp
export TMPDIR="${GITHUB_WORKSPACE}/kernel/tmp"
bundle install --jobs 4 --retry 8
bundle exec rake compile
bundle exec ruby ../../workspace-scripts/check_core_ruby_artifact.rb --package-only ../../tmp/core-export
cp ../../workspace-scripts/verify_core_ruby_export.rb ../../tmp/core-export/
git -C ../.. rev-parse HEAD > ../../tmp/core-export/kernel-revision.txt
- name: Package candidate Psych provider without publication
working-directory: native-ruby
shell: bash
run: |
set -euo pipefail
ulimit -c 0
provider_dir="${GITHUB_WORKSPACE}/kernel/tmp/psych-provider"
support_dir="${GITHUB_WORKSPACE}/kernel/tmp/psych-provider-support"
mkdir -p "${provider_dir}" "${support_dir}"
# Package the provider plus its candidate sibling closure. Sibling gems
# pin each other to the exact checkout version, which a release-bumped
# branch has not published yet; the kernel gate installs the closure
# from these archives into its isolated gem home and validates that it
# satisfies the provider's runtime requirements.
ruby -rrubygems/package -e '
provider_root, provider_dir, support_dir = ARGV
gems_root = File.expand_path("..", provider_root)
load_spec = lambda do |dir|
Dir.chdir(dir) { Gem::Specification.load("#{File.basename(dir)}.gemspec") }
end
build_archive = lambda do |spec, dir, dest|
Dir.chdir(dir) do
target = File.join(dest, "#{spec.full_name}.gem")
abort "refusing to overwrite provider archive #{target}" if File.exist?(target)
Gem::Package.build(spec, false, false, target)
end
end
provider = load_spec.call(provider_root)
abort "unexpected provider gem" unless provider && provider.name == "psych-merge"
abort "typed parser host missing" unless provider.files.include?("lib/psych/merge/core_parser_host.rb")
build_archive.call(provider, provider_root, provider_dir)
packaged = { provider.name => true }
queue = provider.dependencies.select { |dependency| dependency.type == :runtime }.map(&:name)
until queue.empty?
name = queue.shift
next if packaged[name]
packaged[name] = true
sibling = File.join(gems_root, name)
next unless File.file?(File.join(sibling, "#{name}.gemspec"))
spec = load_spec.call(sibling)
build_archive.call(spec, sibling, support_dir)
queue.concat(spec.dependencies.select { |dependency| dependency.type == :runtime }.map(&:name))
end
' "${GITHUB_WORKSPACE}/native-ruby/gems/psych-merge" "${provider_dir}" "${support_dir}"
- name: Verify candidate through full installed Ruby kernel gates
working-directory: kernel
shell: bash
run: |
set -euo pipefail
ulimit -c 0
export TMPDIR="${GITHUB_WORKSPACE}/kernel/tmp"
mapfile -t providers < <(find tmp/psych-provider -maxdepth 1 -name '*.gem' -print)
test "${#providers[@]}" -eq 1
test -d tmp/psych-provider-support
ruby workspace-scripts/check_core_ruby_artifact.rb \
--provider-gem "${providers[0]}" \
--provider-support-dir tmp/psych-provider-support 2>&1 | tee tmp/psych-native-provider.log
- name: Upload native-provider evidence
if: always()
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: psych-native-provider-head
path: |
kernel/tmp/psych-native-provider.log
kernel/tmp/core-ruby-artifact-*/report.json
kernel/tmp/core-ruby-artifact-*/failure.json
kernel/tmp/core-ruby-artifact-*/Gemfile.lock
if-no-files-found: warn
retention-days: 7
- name: Upload typed core export
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: structuredmerge-core-head
path: kernel/tmp/core-export/*
if-no-files-found: error
retention-days: 7
- name: Remove disposable compiler output
if: always()
shell: bash
run: |
if [ -d kernel/tmp/typed-core-target ]; then
rm -r -- kernel/tmp/typed-core-target
fi
dep-heads:
name: Deps @ HEAD (${{ matrix.gem }})
needs:
- detect
- typed-core
if: ${{ needs.detect.outputs.count != '0' && needs.detect.outputs.release_mode == '' }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.detect.outputs.matrix) }}
env:
BUNDLE_GEMFILE: ${{ github.workspace }}/${{ matrix.gem }}/ci_core.gemfile
KETTLE_FAMILY_BUNDLE_GEMFILE: ${{ github.workspace }}/${{ matrix.gem }}/ci_core.gemfile
STRUCTUREDMERGE_CI_GEM_DIR: ${{ github.workspace }}/${{ matrix.gem }}
STRUCTUREDMERGE_CI_DEP_HEADS: "true"
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Clone sibling fixtures repo
shell: bash
run: |
set -euo pipefail
fixtures_repository="$(ruby -ryaml -e 'puts YAML.load_file(".structuredmerge/fixtures.lock").fetch("repository")')"
fixtures_branch="$(ruby -ryaml -e 'puts YAML.load_file(".structuredmerge/fixtures.lock").fetch("branch")')"
fixtures_revision="$(ruby -ryaml -e 'puts YAML.load_file(".structuredmerge/fixtures.lock").fetch("revision")')"
git clone --filter=blob:none --no-checkout "${fixtures_repository}" ../fixtures
git -C ../fixtures fetch origin "refs/heads/${fixtures_branch}:refs/remotes/origin/${fixtures_branch}"
git -C ../fixtures checkout --detach "${fixtures_revision}"
test "$(git -C ../fixtures rev-parse HEAD)" = "${fixtures_revision}"
git -C ../fixtures merge-base --is-ancestor "${fixtures_revision}" "refs/remotes/origin/${fixtures_branch}"
- name: Setup Ruby
uses: appraisal-rb/setup-ruby-flash@6f8ad36ba7488db591541483afb5464d01e8861b # v2.14
with:
ruby-version: "4.0"
bundler: latest
bundler-cache: false
working-directory: ${{ matrix.gem }}
pre-bundle-gems: |
nomono --source https://gem.coop --source https://rubygems.org
- name: Install verified typed core artifact
uses: ./.github/actions/typed-core
- name: Install dependencies
working-directory: ${{ matrix.gem }}
env:
K_JEM_TEMPLATING: true
STRUCTUREDMERGE_DEV: ${{ github.workspace }}/gems
run: |
bundle config set frozen false
for attempt in 1 2 3; do
if bundle install --jobs 4 --retry 8; then
exit 0
fi
if [[ "${attempt}" -lt 3 ]]; then
sleep "$((attempt * 5))"
fi
done
exit 1
- name: Verify installed typed core loads
env:
K_JEM_TEMPLATING: true
STRUCTUREDMERGE_DEV: ${{ github.workspace }}/gems
run: bundle exec ruby .github/verify_typed_core.rb
- name: Run checks
working-directory: ${{ matrix.gem }}
env:
K_JEM_TEMPLATING: true
K_SOUP_COV_DO: false
STRUCTUREDMERGE_DEV: ${{ github.workspace }}/gems
run: timeout 12m bundle exec kettle-test
coverage:
name: Coverage with core artifact (${{ matrix.gem }})
needs: [detect, typed-core]
if: ${{ needs.detect.outputs.count != '0' && needs.detect.outputs.release_mode == '' }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.detect.outputs.matrix) }}
env:
BUNDLE_GEMFILE: ${{ github.workspace }}/${{ matrix.gem }}/ci_core.gemfile
KETTLE_FAMILY_BUNDLE_GEMFILE: ${{ github.workspace }}/${{ matrix.gem }}/ci_core.gemfile
STRUCTUREDMERGE_CI_GEM_DIR: ${{ github.workspace }}/${{ matrix.gem }}
STRUCTUREDMERGE_CI_DEP_HEADS: "false"
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Clone sibling fixtures repo
shell: bash
run: |
set -euo pipefail
fixtures_repository="$(ruby -ryaml -e 'puts YAML.load_file(".structuredmerge/fixtures.lock").fetch("repository")')"
fixtures_branch="$(ruby -ryaml -e 'puts YAML.load_file(".structuredmerge/fixtures.lock").fetch("branch")')"
fixtures_revision="$(ruby -ryaml -e 'puts YAML.load_file(".structuredmerge/fixtures.lock").fetch("revision")')"
git clone --filter=blob:none --no-checkout "${fixtures_repository}" ../fixtures
git -C ../fixtures fetch origin "refs/heads/${fixtures_branch}:refs/remotes/origin/${fixtures_branch}"
git -C ../fixtures checkout --detach "${fixtures_revision}"
test "$(git -C ../fixtures rev-parse HEAD)" = "${fixtures_revision}"
git -C ../fixtures merge-base --is-ancestor "${fixtures_revision}" "refs/remotes/origin/${fixtures_branch}"
- name: Setup Ruby
uses: appraisal-rb/setup-ruby-flash@6f8ad36ba7488db591541483afb5464d01e8861b # v2.14
with:
ruby-version: "4.0"
bundler: latest
bundler-cache: false
working-directory: ${{ matrix.gem }}
pre-bundle-gems: |
nomono --source https://gem.coop --source https://rubygems.org
- name: Install verified typed core artifact
uses: ./.github/actions/typed-core
- name: Install dependencies
working-directory: ${{ matrix.gem }}
env:
K_JEM_TEMPLATING: true
STRUCTUREDMERGE_DEV: ${{ github.workspace }}/gems
run: |
bundle config set frozen false
for attempt in 1 2 3; do
if bundle install --jobs 4 --retry 8; then
exit 0
fi
if [[ "${attempt}" -lt 3 ]]; then
sleep "$((attempt * 5))"
fi
done
exit 1
- name: Verify installed typed core loads
env:
K_JEM_TEMPLATING: true
STRUCTUREDMERGE_DEV: ${{ github.workspace }}/gems
run: bundle exec ruby .github/verify_typed_core.rb
- name: Load coverage thresholds
shell: bash
working-directory: ${{ matrix.gem }}
run: |
set -euo pipefail
for key in K_SOUP_COV_MIN_BRANCH K_SOUP_COV_MIN_LINE K_SOUP_COV_MIN_HARD; do
value="$(sed -nE "s/^${key}[[:space:]]*=[[:space:]]*\"([^\"]*)\".*/\\1/p" mise.toml 2>/dev/null | head -1)"
if [[ -n "${value}" ]]; then
echo "${key}=${value}" >> "${GITHUB_ENV}"
fi
done
- name: Run checks with coverage
working-directory: ${{ matrix.gem }}
env:
K_JEM_TEMPLATING: true
K_SOUP_COV_COMMAND_NAME: Test Coverage
K_SOUP_COV_DO: true
K_SOUP_COV_FORMATTERS: xml,rcov,lcov,tty
K_SOUP_COV_MULTI_FORMATTERS: true
STRUCTUREDMERGE_DEV: ${{ github.workspace }}/gems
run: timeout 20m bundle exec kettle-test
- name: Verify coverage reports
working-directory: ${{ matrix.gem }}
run: |
test -s coverage/lcov.info
test -s coverage/coverage.xml
family-suite:
name: StructuredMerge family suite
needs: detect
if: ${{ needs.detect.outputs.release_mode == 'validation' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Clone sibling fixtures repo
shell: bash
run: |
set -euo pipefail
fixtures_repository="$(ruby -ryaml -e 'puts YAML.load_file(".structuredmerge/fixtures.lock").fetch("repository")')"
fixtures_branch="$(ruby -ryaml -e 'puts YAML.load_file(".structuredmerge/fixtures.lock").fetch("branch")')"
fixtures_revision="$(ruby -ryaml -e 'puts YAML.load_file(".structuredmerge/fixtures.lock").fetch("revision")')"
git clone --filter=blob:none --no-checkout "${fixtures_repository}" ../fixtures
git -C ../fixtures fetch origin "refs/heads/${fixtures_branch}:refs/remotes/origin/${fixtures_branch}"
git -C ../fixtures checkout --detach "${fixtures_revision}"
test "$(git -C ../fixtures rev-parse HEAD)" = "${fixtures_revision}"
git -C ../fixtures merge-base --is-ancestor "${fixtures_revision}" "refs/remotes/origin/${fixtures_branch}"
- name: Setup Ruby
uses: appraisal-rb/setup-ruby-flash@6f8ad36ba7488db591541483afb5464d01e8861b # v2.14
with:
ruby-version: ruby
bundler: latest
bundler-cache: false
pre-bundle-gems: |
nomono --source https://gem.coop --source https://rubygems.org
- name: Install dependencies
env:
K_JEM_TEMPLATING: true
STRUCTUREDMERGE_DEV: ${{ github.workspace }}/gems
run: |
bundle config set frozen false
for attempt in 1 2 3; do
if bundle install --jobs 4 --retry 8; then
exit 0
fi
if [[ "${attempt}" -lt 3 ]]; then
sleep "$((attempt * 5))"
fi
done
exit 1
- name: Run family suite
env:
K_JEM_TEMPLATING: true
KETTLE_FAMILY_BUNDLE_GEMFILE: ${{ github.workspace }}/Gemfile
STRUCTUREDMERGE_DEV: ${{ github.workspace }}/gems
run: timeout 20m bundle exec kettle-test
benchmark-dev:
name: StructuredMerge dev benchmark
needs: detect
if: ${{ needs.detect.outputs.release_mode == '' }}
runs-on: ubuntu-latest
env:
BUNDLE_GEMFILE: ${{ github.workspace }}/gems/ast-merge-git/Appraisal.root.gemfile
K_JEM_TEMPLATING: true
STRUCTUREDMERGE_DEV: ${{ github.workspace }}/gems
STRUCTUREDMERGE_CORE_DEV: ${{ github.workspace }}/kernel
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
- name: Checkout kernel for the local core override
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
repository: structuredmerge/structuredmerge
ref: main
path: kernel
persist-credentials: false
- name: Clone benchmark corpus
shell: bash
run: |
set -euo pipefail
lock=".structuredmerge/benchmark-fixtures.lock"
repository="$(ruby -ryaml -e 'puts YAML.safe_load_file(ARGV.fetch(0)).fetch("repository")' "${lock}")"
tag="$(ruby -ryaml -e 'puts YAML.safe_load_file(ARGV.fetch(0)).fetch("tag")' "${lock}")"
revision="$(ruby -ryaml -e 'puts YAML.safe_load_file(ARGV.fetch(0)).fetch("revision")' "${lock}")"
git clone --filter=blob:none --no-checkout "${repository}" ../benchmark-fixtures
git -C ../benchmark-fixtures fetch --depth 1 origin "refs/tags/${tag}:refs/tags/${tag}"
git -C ../benchmark-fixtures checkout --detach "${revision}"
test "$(git -C ../benchmark-fixtures rev-parse HEAD)" = "${revision}"
test "$(git -C ../benchmark-fixtures rev-parse "refs/tags/${tag}^{commit}")" = "${revision}"
- name: Setup Ruby
uses: appraisal-rb/setup-ruby-flash@6f8ad36ba7488db591541483afb5464d01e8861b # v2.14
env:
BUNDLE_GEMFILE: ${{ github.workspace }}/gems/ast-merge-git/Appraisal.root.gemfile
K_JEM_TEMPLATING: true
STRUCTUREDMERGE_DEV: ${{ github.workspace }}/gems
STRUCTUREDMERGE_CORE_DEV: ${{ github.workspace }}/kernel
with:
ruby-version: ruby
bundler: latest
bundler-cache: false
main-bundle-install: false
working-directory: gems/ast-merge-git
appraisal-name: benchmark-dev
appraisal-root-gemfile: Appraisal.root.gemfile
pre-bundle-gems: |
nomono --source https://gem.coop --source https://rubygems.org
- name: Compile the kernel Ruby binding
working-directory: kernel/packages/ruby
shell: bash
env:
BUNDLE_GEMFILE: ${{ github.workspace }}/kernel/packages/ruby/Gemfile
run: |
set -euo pipefail
ulimit -c 0
export CARGO_BUILD_JOBS="1" CARGO_INCREMENTAL="0"
export CARGO_TARGET_DIR="${GITHUB_WORKSPACE}/kernel/tmp/benchmark-core-target"
mkdir -p ../../tmp
bundle install --jobs 4 --retry 8
bundle exec rake compile
- name: Run affected-capability benchmark
working-directory: gems/ast-merge-git
env:
BASE_SHA: ${{ github.event.pull_request.base.sha || github.event.before }}
K_JEM_TEMPLATING: true
STRUCTUREDMERGE_DEV: ${{ github.workspace }}/gems
STRUCTUREDMERGE_CORE_DEV: ${{ github.workspace }}/kernel
run: |
set -euo pipefail
base_sha="${BASE_SHA:-}"
if [[ -z "${base_sha}" || "${base_sha}" =~ ^0+$ ]]; then
base_sha="$(git -C "${GITHUB_WORKSPACE}" rev-parse HEAD^ 2>/dev/null || git -C "${GITHUB_WORKSPACE}" rev-list --max-parents=0 HEAD)"
fi
mapfile -t changed_paths < <(git -C "${GITHUB_WORKSPACE}" diff --name-only "${base_sha}...HEAD")
changed_path_args=()
for path in "${changed_paths[@]}"; do
changed_path_args+=(--changed-path "${path}")
done
lock="${GITHUB_WORKSPACE}/.structuredmerge/benchmark-fixtures.lock"
corpus_relative="$(ruby -ryaml -e 'puts YAML.safe_load_file(ARGV.fetch(0)).fetch("corpus")' "${lock}")"
corpus="${GITHUB_WORKSPACE}/../benchmark-fixtures/${corpus_relative}"
report="${PWD}/tmp/ci-benchmark/report.json"
raw_report="${report}.raw"
mkdir -p "$(dirname "${report}")"
set +e
timeout 5m bundle exec appraisal benchmark-dev bundle exec ast-merge-git benchmark report \
--corpus "${corpus}" \
--profile dev \
--tmp-root "${PWD}/tmp/ci-benchmark/run" \
"${changed_path_args[@]}" > "${raw_report}"
benchmark_status=$?
set -e
test -s "${raw_report}"
# Appraisal prints its Bundler version and command before the child's
# stdout. Keep the artifact as the benchmark's JSON report.
# shellcheck disable=SC2016
ruby -rjson -e '
raw = File.read(ARGV.fetch(0))
schema_marker = /"schema_version"\s*:\s*"structuredmerge\.benchmark\.report\/v1"/
marker_match = schema_marker.match(raw)
unless marker_match
warn "Benchmark stdout tail:\n#{raw.lines.last(30).join}"
abort "Benchmark report JSON was not found in Appraisal output"
end
report_start = raw.rindex("{", marker_match.begin(0))
report = JSON.parse(raw[report_start..])
File.write(ARGV.fetch(1), JSON.pretty_generate(report))
selected = report.dig("selection", "selected_case_ids")
effectiveness = report.dig("dimensions", "effectiveness")
coverage = report.dig("dimensions", "coverage")
File.open(ENV.fetch("GITHUB_STEP_SUMMARY"), "a") do |summary|
summary.puts "## StructuredMerge dev benchmark"
summary.puts
summary.puts "- Selected cases: #{selected.length}"
summary.puts "- Executed candidate cases: #{coverage.fetch("executed_candidate_cases")}"
summary.puts "- Candidate safety gate: #{report.dig("dimensions", "safety", "gate")}"
summary.puts "- Hard gate failed: #{report.fetch("hard_gate_failed")}"
summary.puts "- Scalar score: none"
summary.puts
summary.puts "| Outcome | Results |"
summary.puts "| --- | ---: |"
effectiveness.each { |outcome, count| summary.puts "| `#{outcome}` | #{count} |" }
end
' "${raw_report}" "${report}"
exit "${benchmark_status}"
- name: Upload benchmark report
if: ${{ always() }}
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: structuredmerge-dev-benchmark-${{ github.sha }}
path: gems/ast-merge-git/tmp/ci-benchmark/report.json
if-no-files-found: warn
retention-days: 30
rbs:
name: RBS
needs: detect
if: ${{ needs.detect.outputs.release_mode == '' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Setup Ruby
uses: ruby/setup-ruby@e1bd6146574da5e0795075b5319b300edb30c5b0 # v1.333.0
with:
ruby-version: ruby
bundler-cache: false
- name: Validate RBS Environment
shell: bash
run: |
ruby -rrbs -rpathname -e '
failures = []
sig_dirs = Dir.glob("gems/*/sig").select { |path| File.directory?(path) }.sort
sig_dirs.each do |sig_dir|
gem_dir = File.dirname(sig_dir)
print "Validating #{gem_dir}... "
loader = RBS::EnvironmentLoader.new
loader.add(path: Pathname(sig_dir))
RBS::Environment.from_loader(loader).resolve_type_names
puts "OK"
rescue StandardError => error
puts "FAILED"
failures << [gem_dir, error]
end
failures.each do |gem_dir, error|
warn "#{gem_dir}: #{error.class}: #{error.message}"
end
abort "RBS validation failed for #{failures.length} gem(s)" unless failures.empty?
'
tslp-cold-start:
name: TSLP cold-start
needs: detect
if: ${{ needs.detect.outputs.release_mode == '' }}
runs-on: ubuntu-latest
env:
BUNDLE_GEMFILE: ${{ github.workspace }}/gems/tree_haver/Appraisal.root.gemfile
K_JEM_TEMPLATING: true
STRUCTUREDMERGE_DEV: ${{ github.workspace }}/gems
STRUCTUREDMERGE_CORE_DEV: ${{ github.workspace }}/kernel
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Checkout kernel for the local core override
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
repository: structuredmerge/structuredmerge
ref: main
path: kernel
persist-credentials: false
- name: Setup Ruby
uses: appraisal-rb/setup-ruby-flash@6f8ad36ba7488db591541483afb5464d01e8861b # v2.14
env:
BUNDLE_GEMFILE: ${{ github.workspace }}/gems/tree_haver/Appraisal.root.gemfile
K_JEM_TEMPLATING: true
STRUCTUREDMERGE_DEV: ${{ github.workspace }}/gems
STRUCTUREDMERGE_CORE_DEV: ${{ github.workspace }}/kernel
with:
ruby-version: ruby
bundler: latest
bundler-cache: false
main-bundle-install: false
working-directory: gems/tree_haver
appraisal-name: tslp-cold-start
appraisal-root-gemfile: Appraisal.root.gemfile
pre-bundle-gems: |
nomono --source https://gem.coop --source https://rubygems.org
- name: Compile the kernel Ruby binding
working-directory: kernel/packages/ruby
shell: bash
env:
BUNDLE_GEMFILE: ${{ github.workspace }}/kernel/packages/ruby/Gemfile
run: |
set -euo pipefail
ulimit -c 0
export CARGO_BUILD_JOBS="1" CARGO_INCREMENTAL="0"
export CARGO_TARGET_DIR="${GITHUB_WORKSPACE}/kernel/tmp/tslp-core-target"
mkdir -p ../../tmp
bundle install --jobs 4 --retry 8
bundle exec rake compile
- name: Run cold-start TSLP checks
working-directory: gems/tree_haver
env:
K_JEM_TEMPLATING: true
K_SOUP_COV_DO: false
STRUCTUREDMERGE_DEV: ${{ github.workspace }}/gems
STRUCTUREDMERGE_CORE_DEV: ${{ github.workspace }}/kernel
run: |
set -euo pipefail
export TREE_SITTER_LANGUAGE_PACK_CACHE_DIR
TREE_SITTER_LANGUAGE_PACK_CACHE_DIR="$(mktemp -d "${RUNNER_TEMP}/tslp-cold-start.XXXXXX")"
bundle exec appraisal tslp-cold-start bundle exec rspec spec/grammar_finder_spec.rb spec/backends/tslp_spec.rb --format progress
check:
name: Check
needs:
- detect
- gem-suite
- typed-core
- dep-heads
- coverage
- family-suite
- benchmark-dev
- rbs
- tslp-cold-start
if: ${{ always() }}
runs-on: ubuntu-latest
steps:
- name: Summarize changed-gem checks
shell: bash
env:
SELECTED_GEMS: ${{ needs.detect.outputs.summary }}
RELEASE_MODE: ${{ needs.detect.outputs.release_mode }}
DETECT_RESULT: ${{ needs.detect.result }}
GEM_SUITE_RESULT: ${{ needs.gem-suite.result }}
TYPED_CORE_RESULT: ${{ needs.typed-core.result }}
DEP_HEADS_RESULT: ${{ needs.dep-heads.result }}
COVERAGE_RESULT: ${{ needs.coverage.result }}
FAMILY_SUITE_RESULT: ${{ needs.family-suite.result }}
BENCHMARK_DEV_RESULT: ${{ needs.benchmark-dev.result }}
RBS_RESULT: ${{ needs.rbs.result }}
TSLP_COLD_START_RESULT: ${{ needs.tslp-cold-start.result }}
run: |
set -euo pipefail
echo "Selected gem suites: ${SELECTED_GEMS}"
echo "Detect result: ${DETECT_RESULT}"
echo "Gem suite result: ${GEM_SUITE_RESULT}"
echo "Typed core artifact result: ${TYPED_CORE_RESULT}"
echo "Deps @ HEAD result: ${DEP_HEADS_RESULT}"
echo "Coverage result: ${COVERAGE_RESULT}"
echo "Family suite result: ${FAMILY_SUITE_RESULT}"
echo "Dev benchmark result: ${BENCHMARK_DEV_RESULT}"
echo "RBS result: ${RBS_RESULT}"
echo "TSLP cold-start result: ${TSLP_COLD_START_RESULT}"
if [[ "${DETECT_RESULT}" != "success" ]]; then
exit 1
fi
if [[ "${RELEASE_MODE}" == "member" ]]; then
echo "Aggregate member release: CI validation completed before publishing."
exit 0
fi
if [[ "${FAMILY_SUITE_RESULT}" == "success" ]]; then
[[ "${GEM_SUITE_RESULT}" == "skipped" ]] || exit 1
[[ "${TYPED_CORE_RESULT}" == "skipped" ]] || exit 1
[[ "${DEP_HEADS_RESULT}" == "skipped" ]] || exit 1
[[ "${COVERAGE_RESULT}" == "skipped" ]] || exit 1
[[ "${RBS_RESULT}" == "skipped" ]] || exit 1
[[ "${BENCHMARK_DEV_RESULT}" == "skipped" ]] || exit 1
[[ "${TSLP_COLD_START_RESULT}" == "skipped" ]] || exit 1
exit 0
fi
for result in "${RBS_RESULT}" "${BENCHMARK_DEV_RESULT}" "${TSLP_COLD_START_RESULT}"; do
[[ "${result}" == "success" ]] || exit 1
done
for result in "${GEM_SUITE_RESULT}" "${TYPED_CORE_RESULT}" "${DEP_HEADS_RESULT}" "${COVERAGE_RESULT}"; do
case "${result}" in
success|skipped)
;;
*)
exit 1
;;
esac
done