Skip to content

armgit / laya

Public Imported from GitHub
0

Non-autoregressive System 1 decision engine. Typed choice, score and yes/no decisions over any text in a single forward pass, in 100+ languages, with a router that picks the right checkpoint per request.

fix(java): the release gate's own comment was disabling it

Adeshina Lasisi271d071f7338
diff --git a/.github/workflows/java.yml b/.github/workflows/java.yml
index 150f7583..41831ee7 100644
--- a/.github/workflows/java.yml
+++ b/.github/workflows/java.yml
@@ -72,6 +72,15 @@ jobs:
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: "3.12"
+ # Before anything expensive: a `run: >` block folds to one line and `#` is not a comment
+ # inside a YAML scalar, so a comment written in one reaches the shell and truncates the
+ # command. That silently removed `--min-tests 625 --allow-aborted` from this repository's
+ # Maven Central release gate, dropping its floor to 1. actionlint does not report it -- the
+ # YAML is valid and the command is legal -- and the broken form is one character from the
+ # correct one in a diff. Standard library only, so it needs no install step.
+ - name: No workflow folds a comment into a run block
+ run: python laya-java/scripts/check_workflow_folding.py
+
- name: Install the Python toolchain the fixtures were recorded with
run: |
python -m pip install --upgrade pip
diff --git a/.github/workflows/release-java.yml b/.github/workflows/release-java.yml
index 91d62344..b00971a2 100644
--- a/.github/workflows/release-java.yml
+++ b/.github/workflows/release-java.yml
@@ -67,12 +67,21 @@ jobs:
# that lane already covered.
- name: Model-free tests
run: ./gradlew --no-daemon test
+ # 631 of the 640 registered tests run without a checkpoint. The floor was 440, which
+ # left 191 of slack -- the whole decode family could have vanished from this lane with
+ # the gate still green, and a floor that does not bind is not a gate.
+ #
+ # These lines sit ABOVE `run:`, not inside it. A `>` block folds to one line and `#` is
+ # not a comment inside a YAML scalar, so a comment written in there reaches the shell and
+ # silences the rest of the folded line: it took `--min-tests 625 --allow-aborted` off this
+ # command, dropping the floor to the script's default of 1 instead of raising it to 625,
+ # and losing `--allow-aborted` on a runner whose parity factories abort. A `|` block keeps
+ # the newlines so the `#` really is a shell comment there, which is why the broken and the
+ # correct form look identical in a diff. `scripts/check_workflow_folding.py` now fails the
+ # build on it rather than relying on a reader spotting it.
- name: The suite was not vacuous
run: >
python3 scripts/check_test_results.py laya-java/build/test-results/test
- # 631 of the 640 registered tests run without a checkpoint. 440 left 191 of
- # slack, so the whole decode family could have vanished from this lane with the
- # gate still green -- and a floor that does not bind is not a gate.
--min-tests 625 --allow-aborted
- name: Build the jars
diff --git a/laya-java/scripts/check_workflow_folding.py b/laya-java/scripts/check_workflow_folding.py
new file mode 100755
index 00000000..375112a1
--- /dev/null
+++ b/laya-java/scripts/check_workflow_folding.py
@@ -0,0 +1,94 @@
+#!/usr/bin/env python3
+"""Refuse a workflow `run:` block that folds a comment into the command.
+
+A folded scalar -- `run: >` or `run: >-` -- joins its lines with spaces, and `#` is not a comment
+inside a YAML scalar. So a comment written inside one arrives at the shell as part of the command
+and silences everything after it on the folded line. A literal block -- `run: |` -- keeps the
+newlines, so there the `#` really is a shell comment. The two forms are one character apart and
+look identical in a diff.
+
+This is not hypothetical. `release-java.yml`'s release gate read:
+
+ - name: The suite was not vacuous
+ run: >
+ python3 scripts/check_test_results.py laya-java/build/test-results/test
+ # 631 of the 640 registered tests run without a checkpoint. ...
+ --min-tests 625 --allow-aborted
+
+which the shell received as
+
+ python3 scripts/check_test_results.py laya-java/build/test-results/test
+
+with both arguments gone: the floor fell to the script's default of 1 instead of rising to 625,
+and `--allow-aborted` was lost on a runner whose parity factories abort. One failure is silent and
+one is loud, and the step's own purpose was to stop a gate that does not bind. `actionlint` does
+not report it, because the YAML is valid and the shell command is a legal one.
+
+Exits 1 and names every occurrence. Run with no arguments to scan `.github/workflows/*.yml` from
+the repository root, or pass paths.
+"""
+import glob
+import io
+import os
+import re
+import sys
+
+# `run:` introducing a block scalar, with the chomping indicator optional.
+RUN_BLOCK = re.compile(r'^(\s*)run:\s*(>-?|\|-?)\s*$')
+
+
+def offenders(path):
+ """Every (line number, comment) a folded `run:` block in `path` would hand to the shell."""
+ lines = io.open(path, encoding="utf-8").read().split("\n")
+ found = []
+ index = 0
+ while index < len(lines):
+ match = RUN_BLOCK.match(lines[index])
+ if match is None:
+ index += 1
+ continue
+ indent, style = match.group(1), match.group(2)
+ start = index
+ index += 1
+ body = []
+ while index < len(lines):
+ line = lines[index]
+ # The block ends at the first non-blank line indented no further than `run:` itself.
+ if line.strip() and len(line) - len(line.lstrip()) <= len(indent):
+ break
+ body.append(line)
+ index += 1
+ if not style.startswith(">"):
+ continue # a literal block keeps its newlines; `#` is fine there
+ for line in body:
+ if line.strip().startswith("#"):
+ found.append((start + 1, line.strip()))
+ return found
+
+
+def main(argv):
+ paths = argv[1:]
+ if not paths:
+ root = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "..")
+ paths = sorted(glob.glob(os.path.join(root, ".github", "workflows", "*.yml")))
+ if not paths:
+ print("check_workflow_folding: no workflows found", file=sys.stderr)
+ return 1
+
+ total = 0
+ for path in paths:
+ for line, comment in offenders(path):
+ total += 1
+ print("%s:%d: a comment inside a folded `run: >` block reaches the shell and"
+ " truncates the command" % (os.path.relpath(path), line), file=sys.stderr)
+ print(" %s" % comment[:110], file=sys.stderr)
+ if total:
+ print("check_workflow_folding: %d folded block(s) with an embedded comment. Move the"
+ " comment above the `run:` key, or use `run: |`." % total, file=sys.stderr)
+ return 1
+ print("check_workflow_folding: %d workflow(s) clean" % len(paths))
+ return 0
+
+
+if __name__ == "__main__":
+ sys.exit(main(sys.argv))