Repository navigation
Range#max(n): 24 GB to return two integers #2105
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: ci | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| permissions: | |
| contents: read | |
| # Track the latest stable Go (org convention). go.mod floor is 1.26.4. | |
| jobs: | |
| # Build, vet, race-test, and enforce 100% coverage. The interpreter is | |
| # ordinary architecture-independent Go; the `internal/ast` package is excluded | |
| # from the gate because it holds only statement-free interface witnesses | |
| # (empty marker methods, which the cover tool cannot attribute). The full suite | |
| # runs under -race on all three OS lanes, but the 100% coverage gate is enforced | |
| # on the POSIX lanes (ubuntu, macOS) only: windows cannot execute a few POSIX-only | |
| # paths (e.g. the "/dev/null" character device), so its coverage is structurally | |
| # below 100% — see the gate step below. | |
| test: | |
| name: test (${{ matrix.os }}) | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, macos-latest, windows-latest] | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - uses: actions/setup-go@v7 | |
| with: | |
| go-version: 1.27.3 | |
| - run: go version | |
| - run: go vet ./... | |
| - run: go build ./... | |
| - name: Test + 100% coverage gate | |
| shell: bash | |
| run: | | |
| COVERPKG=$(go list ./internal/... | paste -sd, -) | |
| # -race roughly doubles wall-clock, and the windows runner is the slowest | |
| # of the three OS lanes; the growing vm suite tips it past go test's 10m | |
| # default. macOS/ubuntu finish ~20m; windows runs ~2x so needs more room. | |
| # Bumped 30m->50m (Puppet ecosystem wave), then 50m->90m: the windows | |
| # binary hit the 50m alarm at 3007s with the running test at 0s — the | |
| # budget ran out, nothing hung — and each conformance wave adds to it. | |
| go test -timeout=90m -race -coverpkg="$COVERPKG" -coverprofile=cover.out ./... | |
| go tool cover -func=cover.out > cover.txt | |
| echo "coverage: $(tail -1 cover.txt | awk '{print $3}') (reported, NOT gated -- see below)" | |
| # The gate is the SET of functions below 100%, recorded per lane in | |
| # scripts/coverage/BELOW100.<lane>, and it may not grow. | |
| # | |
| # It used to be the ROUNDED total, which could not be calibrated. On | |
| # main both POSIX lanes printed "coverage: 100.0%" and passed while | |
| # listing 19 (ubuntu) and 16 (macOS) functions below 100%, the lowest | |
| # at 75.0%. The tolerance was whatever %.1f absorbs at the current | |
| # repository size: nobody chose it, nothing stated it, and it SHRINKS | |
| # as the codebase grows -- so a function falling to 75% was free until | |
| # it was suddenly fatal, and the commit that tripped the gate was not | |
| # the one that created the debt. | |
| # | |
| # Which lane you believed was arbitrary too. On PR #727 the same commit | |
| # read 99.9% on ubuntu (FAIL) and 100.0% on macOS (pass): ubuntu carries | |
| # three filesystem-dependent functions macOS does not, so one further | |
| # dead function tipped only one lane over the rounding edge. Recording | |
| # per lane makes each answerable for its own measurement. | |
| # | |
| # Percentages are reported but not gated: coverage is measured under | |
| # -race, where a percentage jitters and a set does not, and a gate that | |
| # flakes is a gate people learn to rerun. See issue #733. | |
| # | |
| # Windows is not gated at all: it cannot execute a hundred POSIX-only | |
| # code paths -- opening "/dev/null" as a character device, and so on -- | |
| # so its set is structurally different. The suite still RUNS in full | |
| # under -race there, to catch real platform-specific failures. | |
| if [ "${{ matrix.os }}" = "windows-latest" ]; then | |
| echo "coverage ratchet not enforced on windows (POSIX-only paths unreachable)" | |
| go tool cover -func=cover.out | grep -vE '100\.0%$' | head -20 || true | |
| else | |
| go build -o /tmp/covratchet ./scripts/coverage/cmd/covratchet | |
| /tmp/covratchet -record "scripts/coverage/BELOW100.${{ matrix.os }}" \ | |
| -lane "${{ matrix.os }}" -profile cover.txt | |
| fi | |
| # Per-PR arch gate: the two GitHub-hosted NATIVE targets only. amd64 and arm64 | |
| # both have real runners, so these lanes stay fast and block merges. rbgo is | |
| # pure-Go (CGO=0) with no hand-written assembly, so arch-specific risk is low | |
| # and native amd64+arm64 catches virtually all bugs. The four exotic 64-bit | |
| # targets (riscv64/loong64/ppc64le/s390x) are NOT emulated on every PR anymore: | |
| # - a scheduled nightly QEMU run keeps their coverage green | |
| # (.github/workflows/arch-qemu-nightly.yml), and | |
| # - scheduled real-hardware validation runs the suite natively on the GCC | |
| # Compile Farm + a LinuxONE s390x host (.github/workflows/native-arch.yml). | |
| # This removes the ~10 min/lane QEMU bottleneck from the per-PR critical path. | |
| arch-native: | |
| name: arch ${{ matrix.label }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - { os: ubuntu-latest, label: amd64 } | |
| - { os: ubuntu-24.04-arm, label: arm64 } | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - uses: actions/setup-go@v7 | |
| with: | |
| go-version: 1.27.3 | |
| - run: go env GOARCH && go test ./... | |
| # 32-bit gate: int is 32 bits. 386 runs natively on the amd64 runner (the | |
| # kernel executes 32-bit x86 binaries), not under qemu-i386, whose emulation | |
| # loses x87/SSE state across preemption. 32-bit arm is vetted here (a cheap | |
| # compile of every package and test) and run under qemu in the nightly | |
| # (arch-qemu-nightly.yml). The mysql2 tests are 64-bit only: their in-process | |
| # server, dolthub/go-mysql-server, does not compile for 32-bit targets. | |
| arch-386: | |
| name: arch 386 (+ vet arm) | |
| runs-on: ubuntu-latest | |
| env: | |
| CGO_ENABLED: "0" | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - uses: actions/setup-go@v7 | |
| with: | |
| go-version: 1.27.3 | |
| - name: Vet (GOARCH=386, GOARCH=arm) | |
| run: | | |
| GOARCH=386 go vet ./... | |
| GOARCH=arm go vet ./... | |
| - name: Test (GOARCH=386) | |
| run: GOARCH=386 go test -timeout=60m ./... | |
| # Every GOOS/GOARCH pair Go supports must at least compile rbgo, its tests | |
| # and the rbgo_core build: a target that does not compile is one nobody can | |
| # embed rbgo on, and nothing else here would notice (the lanes above run six | |
| # of them). go vet type-checks every package with its tests for the target. | |
| # android and ios link only through cgo, so there the library packages are | |
| # built (no link) instead. plan9 is vetted like the rest (386, amd64, arm), but | |
| # nothing RUNS there: no CI lane has a Plan 9 kernel, so its tests only | |
| # compile (see README "Platforms" for what works there). | |
| every-target: | |
| name: compile on every target (${{ matrix.goos }}) | |
| runs-on: ubuntu-latest | |
| env: | |
| CGO_ENABLED: "0" | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| goos: [aix, android, darwin, dragonfly, freebsd, illumos, ios, js, linux, netbsd, openbsd, plan9, solaris, wasip1, windows] | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - uses: actions/setup-go@v7 | |
| with: | |
| go-version: 1.27.3 | |
| - name: Vet (or build) every GOARCH of ${{ matrix.goos }}, both builds | |
| shell: bash | |
| run: | | |
| fail=0 | |
| for t in $(go tool dist list | grep "^${{ matrix.goos }}/"); do | |
| arch=${t#*/} | |
| for tags in "" rbgo_core; do | |
| case "${{ matrix.goos }}" in | |
| android|ios) cmd="go build -tags=$tags . ./internal/..." ;; | |
| *) cmd="go vet -tags=$tags ./..." ;; | |
| esac | |
| echo "== $t [$tags]: $cmd" | |
| GOOS=${{ matrix.goos }} GOARCH=$arch $cmd || { echo "::error::$t [$tags] does not compile"; fail=1; } | |
| done | |
| done | |
| exit $fail | |
| # WebAssembly (WASI preview 1) gate: the same interpreter compiled for | |
| # GOOS=wasip1 GOARCH=wasm and RUN under a real wasm runtime. The database / | |
| # search / KV / heavy-network gem backends are compiled out on wasm (their | |
| # files carry //go:build !wasm) and degrade to a clean error at require / | |
| # first-use, so this lane proves the VM + core stdlib build and execute in a | |
| # libc-free, socket-less sandbox. wazero is a pure-Go runtime, wired in as the | |
| # toolchain's WASI exec wrapper so `go build` + a real run both stay hermetic. | |
| wasm-wasip1: | |
| name: wasm (wasip1) | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - uses: actions/setup-go@v7 | |
| with: | |
| go-version: 1.27.3 | |
| - run: go version | |
| - name: Build rbgo.wasm (CGO=0, GOOS=wasip1) | |
| run: CGO_ENABLED=0 GOOS=wasip1 GOARCH=wasm go build -o rbgo.wasm ./cmd/rbgo | |
| - name: Install wazero (pure-Go wasm runtime) | |
| run: go install github.com/tetratelabs/wazero/cmd/wazero@v1.12.0 | |
| - name: Run a Ruby snippet under wazero | |
| run: | | |
| out=$("$(go env GOPATH)/bin/wazero" run rbgo.wasm -e 'puts (1..10).sum') | |
| echo "rbgo.wasm output: $out" | |
| test "$out" = "55" || { echo "::error::expected 55, got '$out'"; exit 1; } | |
| - name: Vet + filestat coverage test under wasip1 (wazero exec wrapper) | |
| env: | |
| GOWASIRUNTIME: wazero | |
| run: | | |
| GOOS=wasip1 GOARCH=wasm go vet ./cmd/rbgo ./internal/vm | |
| # Two things run as a wasm binary under wazero: the wasm build-tagged | |
| # statSys (internal/vm/filestat_wasm.go), and the end-to-end claim that | |
| # a program with an observable effect has one. The build steps above | |
| # prove the module links; only this proves it interprets. | |
| GOOS=wasip1 GOARCH=wasm go test -c -o vm.test.wasm ./internal/vm | |
| "$(go env GOPATH)/bin/wazero" run -mount=/tmp:/tmp -env TMPDIR=/tmp \ | |
| vm.test.wasm -test.run 'TestStatSysExtract|TestRunsAProgramOnThisHost' -test.v | |
| # WebAssembly (BROWSER) gate: GOOS=js GOARCH=wasm, the target behind the | |
| # playground (cmd/wasm + web/) and `rbgo build --closed --target wasm`. | |
| # | |
| # It is a SEPARATE target from the wasip1 lane above, not a variation of it, and | |
| # that is the whole reason this lane exists. GOOS=js and GOOS=wasip1 have | |
| # different syscall packages: js/wasm has no ENOTRECOVERABLE, EOWNERDEAD or | |
| # ETXTBSY, so internal/vm stopped compiling for the browser for three days | |
| # (#629 -> #682) while the wasip1 lane above stayed green the entire time. One | |
| # wasm lane is not wasm coverage. | |
| # | |
| # The lane does not stop at the compiler either. It loads the module into node | |
| # with Go's own lib/wasm/wasm_exec.js — the same glue web/index.html loads — and | |
| # asserts Ruby ran: see web/smoke.mjs. On the runner that includes the bucket rule | |
| # witnessed inside a JS host on Linux — Errno::ETXTBSY::Errno is 0 there, | |
| # Errno::ETXTBSY.equal?(Errno::NOERROR) is true, Errno.constants.size is 158 — | |
| # which is the half of #682 no compile-only check could have reached. Measured on an M-series host with a cold | |
| # GOCACHE, so these are build-from-scratch numbers, not warm ones: build ./... | |
| # 14s, vet 18s, the module 97 MB, the node run a few seconds. MEASURED ON A RUNNER: | |
| # 1.9 min end to end on ubuntu-latest, all nine smoke checks green -- the cheapest | |
| # lane in this file bar none, and cheaper than the `wasm (wasip1)` lane beside it | |
| # (2.0 min). Nothing here is -race-priced and it runs in parallel with the others. | |
| wasm-js: | |
| name: wasm (js, browser) | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - uses: actions/setup-go@v7 | |
| with: | |
| go-version: 1.27.3 | |
| - uses: actions/setup-node@v7 | |
| with: | |
| node-version: '26' | |
| - run: go version && node --version | |
| # ./... and not just ./cmd/wasm: #682 was in internal/vm, a package the | |
| # playground reaches only transitively, and the breakage was three names in | |
| # a table no browser-specific file mentions. | |
| - name: Build everything for js/wasm (the #682 regression) | |
| run: CGO_ENABLED=0 GOOS=js GOARCH=wasm go build ./... | |
| - name: Vet the js/wasm packages | |
| run: CGO_ENABLED=0 GOOS=js GOARCH=wasm go vet ./cmd/wasm ./cmd/rbgo ./internal/vm | |
| - name: Build the playground module | |
| run: CGO_ENABLED=0 GOOS=js GOARCH=wasm go build -o web/rbgo.wasm ./cmd/wasm | |
| - name: Run Ruby in a real JS host (node + Go's wasm_exec.js) | |
| run: node web/smoke.mjs web/rbgo.wasm | |
| # The rbgo_core build (README: "The rbgo_core build"): the language and the | |
| # numeric stack, no gem. It is what the go-ndarray playground loads, and it is | |
| # a build tag, so nothing else compiles it: without this lane a gem binding | |
| # that a core file starts calling directly would break it unnoticed, or pull | |
| # the gem back into the binary. The lane vets and tests it natively, builds the | |
| # browser module, refuses one that grew or links a gem again, and runs it. | |
| core: | |
| name: rbgo_core (core build) | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - uses: actions/setup-go@v7 | |
| with: | |
| go-version: 1.27.3 | |
| - uses: actions/setup-node@v7 | |
| with: | |
| node-version: '26' | |
| - run: go version && node --version | |
| - name: Vet the core build (native and js/wasm) | |
| run: | | |
| go vet -tags rbgo_core ./... | |
| CGO_ENABLED=0 GOOS=js GOARCH=wasm go vet -tags rbgo_core ./cmd/wasm ./internal/vm | |
| - name: Test the core build | |
| run: go test -tags rbgo_core -timeout=60m ./internal/vm ./cmd/wasm | |
| - name: Build the core playground module | |
| run: CGO_ENABLED=0 GOOS=js GOARCH=wasm go build -tags rbgo_core -ldflags='-s -w' -o web/rbgo-core.wasm ./cmd/wasm | |
| - name: No gem is linked, and the module stays small | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| # 23.1 MB when this lane was added, 27.5 MB once Special, Stats, | |
| # Integrate and Optimize arrived (#819): +4_284_384 in all. Measured | |
| # 2026-10-18 on one worktree, js/wasm, -s -w, go-ndarray v0.12.0 and | |
| # go-numerics/{integrate,optimize} v0.2.0. | |
| # | |
| # The cost is attributed rather than absorbed, and the two obvious ways | |
| # to attribute it DISAGREE -- which is the useful part, so both are here. | |
| # | |
| # one module added in turn | |
| # alone down the branch | |
| # Special +591_000 +591_000 | |
| # Stats +2_685_365 +2_438_092 | |
| # Integrate +267_470 +266_797 | |
| # Optimize +1_020_511 +987_989 | |
| # ---------- ---------- | |
| # +4_564_346 +4_283_878 | |
| # | |
| # Isolated OVERCOUNTS: the four share go-ndarray, the special/nd layer | |
| # and the argument helpers, so each column pays for the same code and | |
| # the sum exceeds the real +4_284_384 by 279_962 -- that residual IS | |
| # the shared part, which neither method reports on its own. Cumulative | |
| # UNDERCOUNTS all but the first, because whoever goes first pays for | |
| # the shared code and the rest ride free: Special is identical in both | |
| # columns precisely because it goes first, and its sum lands 506 bytes | |
| # from the real total. Neither is "the" per-module cost. | |
| # | |
| # What both agree on, and what to read: Stats ~59% of the growth, which | |
| # is what 36 distributions and 27_599 lines of Go cost; Optimize ~22%, | |
| # Special ~13%, Integrate ~6%; the four bindings themselves are ~1_500 | |
| # lines. | |
| # | |
| # The same two columns measured on go-ndarray v0.11.0 gave a shared | |
| # residual of 279_063 against 279_962 here -- 899 bytes apart across a | |
| # dependency upgrade, which is the method agreeing with itself. An | |
| # earlier revision of this comment presented the cumulative column as | |
| # "each module added to origin/main alone". It was not, and a session | |
| # that measured Special in isolation could only report the two as 7% | |
| # apart; they were two different quantities. | |
| # | |
| # Note also that the build is NOT byte-reproducible across worktrees: | |
| # the same commit gave 23_173_500 in one and 23_172_890 in another, 610 | |
| # bytes apart. Only same-worktree comparisons mean anything, which is | |
| # why every figure above comes from one. | |
| # | |
| # The bound leaves room for growth in the interpreter itself, not for a | |
| # gem coming back -- and a gem is caught by the module-path check BELOW, | |
| # by name and exactly. This number only has to notice growth nobody | |
| # intended, so it sits ~1.5 MB above the measurement. | |
| size=$(wc -c < web/rbgo-core.wasm) | |
| echo "rbgo-core.wasm: $size bytes" | |
| if [ "$size" -gt 29000000 ]; then | |
| echo "::error::the rbgo_core module is $size bytes, over the 29000000 bound" | |
| exit 1 | |
| fi | |
| mods=$(CGO_ENABLED=0 GOOS=js GOARCH=wasm go list -tags rbgo_core -deps -f '{{with .Module}}{{.Path}}{{end}}' ./cmd/wasm | sort -u) | |
| bad=$(echo "$mods" | grep -E 'google.golang.org/protobuf|go-scss|go-rouge|go-opentype|go-widgets|go-images|go-kramdown|go-nokogiri|go-ruby-(rails|railties|actionpack|activerecord|rack|sinatra|yaml|uri|erb|optparse)/' || true) | |
| if [ -n "$bad" ]; then | |
| echo "::error::the rbgo_core build links gem modules:" | |
| echo "$bad" | |
| exit 1 | |
| fi | |
| - name: Run the core module in a real JS host | |
| run: node web/smoke.mjs web/rbgo-core.wasm --core | |
| # The RBGO_BUILD_IT lane. Three integration tests in cmd/rbgo drive `rbgo build` | |
| # end to end — native, --closed, and --closed --target wasm — and every one of | |
| # them was behind `if os.Getenv("RBGO_BUILD_IT") == ""` with no workflow anywhere | |
| # in this repo setting it. TestClosedWasmBuildIntegration fails on the #682 | |
| # regression with exactly its three errors: the guard was correct, complete, and | |
| # unreachable for three days. | |
| # | |
| # The choice made here is to WIRE IT IN rather than delete the claim, because the | |
| # three tests cover what no other lane does: the nested `go build` the rbgo | |
| # command performs, that --closed really drops the front-end from the binary, and | |
| # that a baked program runs. The cost is what makes it its own lane rather than a | |
| # step in `test`: these are full cross-compiles of a ~97 MB module, 35s cold for | |
| # all three on an M-series host (they share the build cache, so the third is | |
| # nearly free) and MEASURED ON A RUNNER at 141s of test time, 5.3 min for the | |
| # whole job. That is the honest frame: it lands BETWEEN two lanes this file | |
| # already pays for — `arch arm64` at 5.9 min and `arch amd64` at 9.4 min on the | |
| # same commit — and well under the 20-90 min -race coverage lane. Keeping it in | |
| # its own lane is about staying off that lane's critical path, not about price. | |
| # | |
| # node is installed because TestClosedWasmBuildIntegration now RUNS the module it | |
| # builds, and it fails rather than skips if node is missing. A gate that steps | |
| # aside when a dependency is absent is the failure this lane exists to correct. | |
| # | |
| # THIS LANE IS RED ON ARRIVAL, and that is the finding, not a mistake. Turning the | |
| # env var on is what a gate nobody ran was hiding: both closed-world tests fail | |
| # their "the front-end must not be linked" assertion, on this branch and equally | |
| # on the commit it branched from. `rbgo build --closed` prints "closed-world — | |
| # front-end dropped (no lexer/parser/compiler linked)" and then ships a 172.9 MiB | |
| # binary carrying 255 github.com/go-ruby-parser/parser.(*Parser).* text symbols. | |
| # The cause is a single edge: internal/vm/rubocop.go and rubocop_bind.go have NO | |
| # build tags, and github.com/go-ruby-rubocop/rubocop imports the parser, so the | |
| # front-end re-enters the closed dep graph through the RuboCop binding | |
| # (`go list -deps -tags rbgo_closed ./cmd/rbgo` shows it). | |
| # | |
| # Confirmed on a GitHub ubuntu runner, not only locally, and it fails for EXACTLY | |
| # that one reason: TestBuildIntegration, TestBuildEnv and | |
| # TestRunSendsWarningsToTheRealStderr pass, and the only lines in the failure are | |
| # the two "still links the front-end" assertions. The node run of the closed wasm | |
| # module and both of its JS.log assertions pass there too, so the leak is | |
| # platform-independent and nothing else in the lane is broken. | |
| # | |
| # The fix is deliberately NOT in this PR: it is a scope decision about what | |
| # --closed supports (does a closed-world build still answer `require "rubocop"`, | |
| # or degrade to a LoadError the way the network backends do on wasm?), and it | |
| # touches internal/vm, not this cluster. Neither assertion was weakened to get a | |
| # green tick -- the whole point of the exercise was that a check nobody runs is | |
| # documentation. | |
| build-integration: | |
| name: rbgo build integration (RBGO_BUILD_IT) | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - uses: actions/setup-go@v7 | |
| with: | |
| go-version: 1.27.3 | |
| - uses: actions/setup-node@v7 | |
| with: | |
| node-version: '26' | |
| - run: go version && node --version | |
| - name: go test ./cmd/rbgo with the integration tests enabled | |
| env: | |
| RBGO_BUILD_IT: '1' | |
| run: go test -count=1 -timeout=30m -v ./cmd/rbgo |