Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Keep backend slices within the existing CI and patch control envelope

pulse-triage[bot]b9bef60186e4
diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml
index 932b8789b1..c3b1c02667 100644
--- a/.github/workflows/build-and-test.yml
+++ b/.github/workflows/build-and-test.yml
@@ -451,8 +451,8 @@ jobs:
- name: Compile every Go race-test binary without executing it
run: bash scripts/compile-go-tests.sh
- backend-packages:
- name: Backend package tests (${{ matrix.shard }})
+ backend:
+ name: Backend tests (${{ matrix.shard }})
needs: [changes, test-compile]
# Expand the unchanged required checks even when compilation fails. A
# skipped dependency must not turn a broken source into a green check.
@@ -465,8 +465,7 @@ jobs:
fail-fast: false
matrix:
# internal/api has its own sharded job below. Measured weights balance
- # the remaining whole packages across these two workers. The two slow
- # packages have exhaustive source-derived slices in backend-slow.
+ # every other whole package across these two unchanged required checks.
shard: [rest-0, rest-1]
steps:
@@ -512,12 +511,15 @@ jobs:
if: needs.changes.outputs.code == 'true'
env:
PULSE_DATA_DIR: /tmp/pulse-test-data
+ # Two ordinary package binaries plus the two sliced binaries: keep
+ # the four-package concurrency envelope, rather than adding runners.
+ GOMAXPROCS: '2'
# Source, not the timing file, defines coverage. Longest measured
# packages go to the lightest shard and start first within that shard;
# new packages use a default weight. Do not leave slow binaries behind
# the alphabetically earlier small packages in Go's parallel scheduler.
- # Package binaries are independent, so only internal/api needs the
- # contiguous, order-preserving test slices used in its separate job.
+ # Package binaries are independent. Keep each slow package's own
+ # source order inside its two slices, as the API shards already do.
run: |
set -euo pipefail
case "${{ matrix.shard }}" in
@@ -525,7 +527,11 @@ jobs:
rest-1) index=1 ;;
*) echo "unknown shard ${{ matrix.shard }}" >&2; exit 1 ;;
esac
- pkgs=$(go list ./... | grep -vE '/(internal/api|internal/monitoring|scripts/installtests)$' \
+ # These controls travel with main's copied patch controls too; no
+ # test-name allowlist or unrelated stable source is required.
+ python3 scripts/release_control/run_go_package_slice_test.py
+ pkgs=$(go list ./... | grep -v '/internal/api$' \
+ | grep -vE '/(internal/monitoring|scripts/installtests)$' \
| python3 .github/scripts/select-go-package-shard.py \
.github/scripts/go-package-test-seconds.txt 2 "$index")
if [ -z "$pkgs" ]; then
@@ -533,100 +539,33 @@ jobs:
exit 1
fi
printf 'Packages in this shard:\n%s\n' "$pkgs"
- go test -race -timeout 50m $pkgs
-
- # These packages now take 10–12 minutes each under -race. Whole-package
- # weights cannot shorten that serial floor. Preserve each package's test
- # order in two source-derived slices; the recorder requires every selected
- # root exactly once, not just a package-level pass.
- backend-slow:
- name: Backend slices (${{ matrix.suite }}-${{ matrix.index }}/2)
- needs: [changes, test-compile]
- if: ${{ !cancelled() && needs.changes.result == 'success' && needs.changes.outputs.code == 'true' }}
- runs-on: ubuntu-24.04
- timeout-minutes: 45
- strategy:
- fail-fast: false
- matrix:
- suite: [monitoring, installtests]
- index: [0, 1]
- include:
- - suite: monitoring
- package: internal/monitoring
- - suite: installtests
- package: scripts/installtests
- steps:
- - name: Require compiled backend tests
- env:
- COMPILE_REQUIRED: ${{ needs.changes.outputs.go_compile }}
- COMPILE_RESULT: ${{ needs.test-compile.result }}
- run: |
- if [ "$COMPILE_REQUIRED" = true ] && [ "$COMPILE_RESULT" != success ]; then
- echo "::error::Backend test compilation did not pass; no sliced tests started."
- exit 1
- fi
-
- - name: Checkout repository
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- with:
- persist-credentials: false
-
- - name: Set up Go
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
- with:
- go-version-file: go.mod
- cache: true
-
- - name: Provide frontend embed stub
- run: bash scripts/ensure_test_assets.sh
-
- - name: Run source-derived backend slice
- env:
- PULSE_DATA_DIR: /tmp/pulse-test-data
- TEST_PACKAGE: ${{ matrix.package }}
- TEST_INDEX: ${{ matrix.index }}
- run: >-
- python3 .github/scripts/run-go-package-slice.py
- --package "$TEST_PACKAGE" --index "$TEST_INDEX"
- --output "$RUNNER_TEMP/backend-slice"
-
- - name: Retain slice coverage and failure observations
- if: always()
+ # GOMAXPROCS=2 bounds ordinary go test to two package workers. The
+ # other two binaries each run this worker's contiguous source-listed
+ # half. Preserve both protected rest names and compilation gates.
+ pids=()
+ go test -race -timeout 50m $pkgs &
+ pids+=("$!")
+ for package in internal/monitoring scripts/installtests; do
+ python3 scripts/release_control/run_go_package_slice.py \
+ --package "$package" --index "$index" \
+ --output "$RUNNER_TEMP/backend-slices/${package##*/}" &
+ pids+=("$!")
+ done
+ status=0
+ for pid in "${pids[@]}"; do
+ if wait "$pid"; then :; else status=1; fi
+ done
+ exit "$status"
+
+ - name: Retain source-listed backend coverage
+ if: always() && needs.changes.outputs.code == 'true'
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
- name: backend-slice-${{ matrix.suite }}-${{ matrix.index }}
- path: ${{ runner.temp }}/backend-slice/
+ name: backend-slices-${{ matrix.shard }}
+ path: ${{ runner.temp }}/backend-slices/
if-no-files-found: warn
retention-days: 7
- # Branch protection keeps its exact two names. Neither a skipped/failed
- # worker nor a partial matrix can manufacture a successful required check.
- backend:
- name: Backend tests (${{ matrix.shard }})
- needs: [changes, backend-packages, backend-slow]
- if: always()
- runs-on: ubuntu-24.04
- timeout-minutes: 5
- strategy:
- matrix:
- shard: [rest-0, rest-1]
- steps:
- - name: Require exhaustive backend coverage
- env:
- CHANGE_RESULT: ${{ needs.changes.result }}
- CODE_REQUIRED: ${{ needs.changes.outputs.code }}
- PACKAGES_RESULT: ${{ needs.backend-packages.result }}
- SLICES_RESULT: ${{ needs.backend-slow.result }}
- run: |
- set -euo pipefail
- test "$CHANGE_RESULT" = success
- test "$PACKAGES_RESULT" = success
- case "$CODE_REQUIRED:$SLICES_RESULT" in
- true:success) echo "Every whole-package worker and all four source-derived slices passed." ;;
- false:skipped) echo "Runtime tests not applicable to this source range." ;;
- *) echo "::error::Backend slice coverage unavailable or failed ($CODE_REQUIRED:$SLICES_RESULT)."; exit 1 ;;
- esac
-
# internal/api alone took ~27 of the ~31 minutes of the old single
# `Backend tests (api)` job under -race, which made it the critical path of
# every pull request. Its top-level tests are split across these shards
diff --git a/.gitignore b/.gitignore
index 4ec1aaba5e..8edd432d8b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -272,6 +272,8 @@ scripts/release_control/*
!scripts/release_control/render_release_body_test.py
!scripts/release_control/resolve_release_promotion.py
!scripts/release_control/resolve_release_promotion_test.py
+!scripts/release_control/run_go_package_slice.py
+!scripts/release_control/run_go_package_slice_test.py
!scripts/release_control/repo_file_io.py
!scripts/release_control/repo_file_io_test.py
!scripts/release_control/record_rc_to_ga_rehearsal.py
diff --git a/docs/release-control/v6/internal/subsystems/deployment-installability.md b/docs/release-control/v6/internal/subsystems/deployment-installability.md
index a998c26710..4fd8c42bf0 100644
--- a/docs/release-control/v6/internal/subsystems/deployment-installability.md
+++ b/docs/release-control/v6/internal/subsystems/deployment-installability.md
@@ -1318,31 +1318,38 @@ caches only its last compiled pattern, so `-run .` next to `-skip` recompiled
the long skip pattern for every test and subtest and roughly doubled that
shard. The required check name
`Backend tests (api)` belongs to a verdict job that passes only when every
-shard succeeded. The required `Backend tests (rest-0)` and `Backend tests
-(rest-1)` names now belong to exhaustive verdicts: both ordinary package
-workers and all four slow-package slices must succeed on code changes.
-The ordinary workers exclude exactly `internal/api`, `internal/monitoring`
-and `scripts/installtests`; API coverage remains in its unchanged five shards.
-`.github/scripts/run-go-package-slice.py` runs each of the latter two slow
-packages in two contiguous, source-listed halves, retaining declaration order,
-`-race`, uncached execution, the 50-minute test deadline and the existing JSON
-recorder's exact selected-root/package checks. It chooses only one of `-run`
-and `-skip`, bounded to 120,000 bytes, and retains the full inventory, selection,
-terminal exits, timings and bounded failure/skip observations as CI artifacts.
-No maintained test-name list or timing estimate defines coverage. A new root
-belongs to exactly one half; failed listing, empty selection, partial execution
-or a producer/recorder failure cannot pass the slice or either required verdict.
+shard succeeded. `Backend tests (rest-0)` and `Backend tests (rest-1)`
+keep their original names, compile dependencies and two-worker matrix. Within
+each worker the ordinary source-listed packages exclude exactly `internal/api`,
+`internal/monitoring` and `scripts/installtests`. API coverage remains in its
+unchanged five shards. Each worker runs the other two slow packages as contiguous
+source-listed halves through `scripts/release_control/run_go_package_slice.py`.
+The ordinary Go command and both sliced commands run concurrently; every child
+must finish successfully before that same protected check can pass. A failed
+listing, incomplete JSON execution or failed child cannot be hidden by another
+passing command. `GOMAXPROCS=2` bounds the ordinary command to two package
+workers, alongside the two sliced binaries: four package workers, not extra
+hosted jobs. Documentation-only changes retain the original explicit
+runtime-inapplicable results and required check names.
+
+The slice runner preserves declaration order, `-race`, uncached execution, the
+50-minute test deadline and the existing JSON recorder's exact selected-root
+and package checks. It chooses only one of `-run` and `-skip`, bounded to
+120,000 bytes, and retains each inventory, selection, terminal exits, timings
+and bounded failure/skip observations as a source-bound CI artifact. No
+maintained test-name list or timing estimate defines coverage. A new root
+belongs to exactly one half. The helper and its executable controls live under
+`scripts/release_control/`, which the mechanical patch path copies from main;
+no unrelated stable source or expansion of the patch contents is needed. The
+old job shapes, compile controls and ordinary Go command stay compatible with
+source contract tests shipped by the current stable.
Three complete passing main runs on 27 October measured monitoring at
524–719 seconds and installer tests at 605–725 seconds. Whole-package weights
cannot shorten that serial floor. Splitting those suites is a CI scheduling
change, not reduced source coverage or release/native acceptance. Contiguous
halves may expose existing package-state coupling; actual split-suite proof and
-required CI, not a prediction, establish whether the partition is valid.
-Documentation/receipt-only changes still produce the required verdict names:
-ordinary workers report runtime tests inapplicable, slow slices do not execute,
-and verdicts accept only that exact expected combination. Missing, failed,
-cancelled or unexpected worker states fail closed. Go test steps are not skipped for frontend-only changes, because Go tests
+required CI, not a prediction, establish whether the partition is valid. Go test steps are not skipped for frontend-only changes, because Go tests
read frontend sources (the `internal/api` contract tests, the
`internal/unifiedresources` code standards walk of `frontend-modern/src`, and
the `internal/telemetry` repository-wide wording scan). Core E2E runs its
@@ -2090,7 +2097,7 @@ Windows lifecycle controls or macOS installer and logging checks on native CI.
13a. `.github/workflows/compile-release-payload.yml`
13b. `.github/workflows/qualify-secure-runtime-release.yml`
14. `.github/workflows/build-and-test.yml`
-14a. `.github/scripts/run-go-package-slice.py`
+14a. `scripts/release_control/run_go_package_slice.py`
14. `.github/workflows/create-release.yml`
14. `.github/workflows/deploy-demo-server.yml`
15. `.github/workflows/helm-pages.yml`
diff --git a/docs/release-control/v6/internal/subsystems/registry.json b/docs/release-control/v6/internal/subsystems/registry.json
index cfb199f420..94ac3f95e1 100644
--- a/docs/release-control/v6/internal/subsystems/registry.json
+++ b/docs/release-control/v6/internal/subsystems/registry.json
@@ -4650,7 +4650,6 @@
".github/scripts/recover-demo-runtime.sh",
".github/scripts/refresh-internal-api-test-seconds.py",
".github/scripts/resolve-demo-runtime-profile.sh",
- ".github/scripts/run-go-package-slice.py",
".github/scripts/select-internal-api-shard.sh",
".github/scripts/setup-demo-ssh.sh",
".github/scripts/tests/demo_runtime_native.py",
@@ -4770,6 +4769,7 @@
"scripts/release_control/release_snapshot.py",
"scripts/release_control/render_release_body.py",
"scripts/release_control/resolve_release_promotion.py",
+ "scripts/release_control/run_go_package_slice.py",
"scripts/release_control/secure_runtime_attestation_v6.py",
"scripts/release_control/secure_runtime_attestation_v7.py",
"scripts/release_control/secure_runtime_rootful_attestation_v1.py",
@@ -5288,11 +5288,11 @@
".github/scripts/internal-api-test-seconds.txt",
".github/scripts/record-internal-api-test-seconds.py",
".github/scripts/refresh-internal-api-test-seconds.py",
- ".github/scripts/run-go-package-slice.py",
".github/scripts/select-internal-api-shard.sh",
".github/workflows/build-and-test.yml",
"frontend-modern/package-lock.json",
- "frontend-modern/package.json"
+ "frontend-modern/package.json",
+ "scripts/release_control/run_go_package_slice.py"
],
"allow_same_subsystem_tests": false,
"test_prefixes": [],
diff --git a/scripts/installtests/build_release_assets_test.go b/scripts/installtests/build_release_assets_test.go
index f062e8055a..ce32bf46a6 100644
--- a/scripts/installtests/build_release_assets_test.go
+++ b/scripts/installtests/build_release_assets_test.go
@@ -4165,11 +4165,11 @@ func TestBackendAPIShardsKeepRequiredCheckExhaustive(t *testing.T) {
// Branch protection requires these exact check names. The rest shards stay
// matrix entries and internal/api keeps its name on the verdict job.
- backend := workflowJobBlock(t, workflow, "backend-packages")
+ backend := workflowJobBlock(t, workflow, "backend")
for _, required := range []string{
- "name: Backend package tests (${{ matrix.shard }})",
+ "name: Backend tests (${{ matrix.shard }})",
"shard: [rest-0, rest-1]",
- "grep -vE '/(internal/api|internal/monitoring|scripts/installtests)$'",
+ "grep -v '/internal/api$'",
"python3 .github/scripts/select-go-package-shard.py",
`.github/scripts/go-package-test-seconds.txt 2 "$index")`,
"set -euo pipefail",
@@ -4180,34 +4180,17 @@ func TestBackendAPIShardsKeepRequiredCheckExhaustive(t *testing.T) {
}
}
- // The old protected names now require both ordinary workers and every
- // source-derived slice. A successful ordinary package cannot conceal an
- // omitted, failed or skipped slow-package matrix.
- restVerdict := workflowJobBlock(t, workflow, "backend")
- for _, required := range []string{
- "name: Backend tests (${{ matrix.shard }})",
- "shard: [rest-0, rest-1]",
- "needs: [changes, backend-packages, backend-slow]",
- "if: always()",
- "PACKAGES_RESULT: ${{ needs.backend-packages.result }}",
- "SLICES_RESULT: ${{ needs.backend-slow.result }}",
- "true:success)", "false:skipped)",
- } {
- if !strings.Contains(restVerdict, required) {
- t.Fatalf("required rest verdict missing %q", required)
- }
- }
- slow := workflowJobBlock(t, workflow, "backend-slow")
for _, required := range []string{
- "needs: [changes, test-compile]", "fail-fast: false",
- "suite: [monitoring, installtests]", "index: [0, 1]",
- "package: internal/monitoring", "package: scripts/installtests",
- "python3 .github/scripts/run-go-package-slice.py",
- `--package "$TEST_PACKAGE" --index "$TEST_INDEX"`,
- "PULSE_DATA_DIR: /tmp/pulse-test-data",
+ "grep -vE '/(internal/monitoring|scripts/installtests)$'",
+ "python3 scripts/release_control/run_go_package_slice_test.py",
+ "python3 scripts/release_control/run_go_package_slice.py",
+ "for package in internal/monitoring scripts/installtests; do",
+ "for pid in \"${pids[@]}\"; do",
+ "if wait \"$pid\"; then :; else status=1; fi",
+ "GOMAXPROCS: '2'", "name: backend-slices-${{ matrix.shard }}",
} {
- if !strings.Contains(slow, required) {
- t.Fatalf("source-derived backend slices missing %q", required)
+ if !strings.Contains(backend, required) {
+ t.Fatalf("required backend worker lost exhaustive sliced coverage: %q", required)
}
}
@@ -5647,8 +5630,8 @@ func TestCITestCompilationPreservesChecks(t *testing.T) {
t.Fatalf("compile admission removed independent CI requirement: %s", required)
}
}
- if strings.Count(workflow, "name: Require compiled backend tests") != 3 {
- t.Fatal("ordinary, sliced and API backend workers must report compilation failures")
+ if strings.Count(workflow, "name: Require compiled backend tests") != 2 {
+ t.Fatal("both required backend matrices must report compilation failures")
}
for _, path := range []string{
repoFile("scripts", "compile-go-tests.sh"),
diff --git a/.github/scripts/run-go-package-slice.py b/scripts/release_control/run_go_package_slice.py
similarity index 100%
rename from .github/scripts/run-go-package-slice.py
rename to scripts/release_control/run_go_package_slice.py
diff --git a/scripts/tests/test_go_package_slices.py b/scripts/release_control/run_go_package_slice_test.py
similarity index 58%
rename from scripts/tests/test_go_package_slices.py
rename to scripts/release_control/run_go_package_slice_test.py
index 9c1ffefdb1..d192e2b6f3 100644
--- a/scripts/tests/test_go_package_slices.py
+++ b/scripts/release_control/run_go_package_slice_test.py
@@ -5,13 +5,14 @@ import json
import os
from pathlib import Path
import re
+import shutil
import subprocess
import tempfile
import unittest
ROOT = Path(__file__).resolve().parents[2]
-RUNNER = ROOT / ".github/scripts/run-go-package-slice.py"
+RUNNER = ROOT / "scripts/release_control/run_go_package_slice.py"
WORKFLOW = ROOT / ".github/workflows/build-and-test.yml"
spec = importlib.util.spec_from_file_location("package_slices", RUNNER)
runner = importlib.util.module_from_spec(spec)
@@ -64,6 +65,13 @@ import json, os, re, sys
from pathlib import Path
args = sys.argv[1:]
with Path(os.environ['CALLS']).open('a') as f: f.write(json.dumps(args)+'\\n')
+if args[0] == 'list':
+ print('\\n'.join('github.com/rcourtman/pulse-go-rewrite/'+n for n in
+ ['internal/api','internal/monitoring','scripts/installtests','internal/a','internal/b','internal/c','internal/d']))
+ sys.exit(0)
+if '-list' not in args and '-json' not in args:
+ print('ok ordinary packages 0.01s')
+ sys.exit(int(os.environ.get('ORDINARY_EXIT','0')))
names = ['TestZ', 'TestA', 'FuzzB', 'ExampleC', 'TestLast']
if '-list' in args:
if os.environ.get('LISTING_EXIT'):
@@ -135,39 +143,68 @@ sys.exit(int(os.environ.get('TEST_EXIT','0')))
class WorkflowTest(unittest.TestCase):
- def test_fixed_matrix_and_whole_package_exclusion_match_the_runner(self):
- slow = job('backend-slow')
- self.assertIn('suite: [monitoring, installtests]', slow)
- self.assertIn('index: [0, 1]', slow)
- self.assertEqual(re.findall(r' package: (\S+)', slow), list(runner.PACKAGES))
- for required in ('fail-fast: false', 'needs: [changes, test-compile]',
- 'needs.changes.outputs.code == \'true\'', 'persist-credentials: false',
- 'if: always()', 'run-go-package-slice.py', '--package "$TEST_PACKAGE"',
- '--index "$TEST_INDEX"', 'backend-slice-${{ matrix.suite }}-${{ matrix.index }}'):
- self.assertIn(required, slow)
- self.assertNotIn('continue-on-error', slow)
- self.assertIn("grep -vE '/(internal/api|internal/monitoring|scripts/installtests)$'",
- job('backend-packages'))
- self.assertIn('shard: [rest-0, rest-1]', job('backend'))
- self.assertIn('name: Backend tests (${{ matrix.shard }})', job('backend'))
- self.assertIn('needs: [changes, backend-packages, backend-slow]', job('backend'))
- self.assertIn('if: always()', job('backend'))
-
- def test_actual_required_verdict_rejects_every_unavailable_or_incomplete_matrix(self):
- verdict = job('backend').split(' run: |\n', 1)[1]
- script = '\n'.join(line[10:] for line in verdict.splitlines()
- if line.startswith(' ') or not line.strip())
- for code, slices in (('true', 'success'), ('false', 'skipped')):
- env = {**os.environ, 'CHANGE_RESULT': 'success', 'CODE_REQUIRED': code,
- 'PACKAGES_RESULT': 'success', 'SLICES_RESULT': slices}
- result = subprocess.run(['bash', '-c', script], env=env, capture_output=True)
- self.assertEqual(result.returncode, 0, result.stderr)
- for field in ('CHANGE_RESULT', 'PACKAGES_RESULT', 'SLICES_RESULT', 'CODE_REQUIRED'):
- for value in ('', 'failure', 'cancelled', 'unknown', 'true' if field != 'CODE_REQUIRED' else 'other'):
- with self.subTest(code=code, field=field, value=value):
- result = subprocess.run(['bash', '-c', script], env={**env, field: value},
- capture_output=True)
- self.assertNotEqual(result.returncode, 0)
+ def test_same_two_required_workers_cover_both_sliced_packages(self):
+ block = job('backend')
+ for expected in (
+ 'name: Backend tests (${{ matrix.shard }})', 'shard: [rest-0, rest-1]',
+ 'needs: [changes, test-compile]', "GOMAXPROCS: '2'",
+ "grep -v '/internal/api$'", "grep -vE '/(internal/monitoring|scripts/installtests)$'",
+ 'go test -race -timeout 50m $pkgs &',
+ 'for package in internal/monitoring scripts/installtests; do',
+ 'scripts/release_control/run_go_package_slice.py',
+ '--package "$package" --index "$index"',
+ 'for pid in "${pids[@]}"; do', 'if wait "$pid"; then :; else status=1; fi',
+ 'exit "$status"', 'name: backend-slices-${{ matrix.shard }}',
+ ):
+ self.assertIn(expected, block)
+ self.assertNotIn('continue-on-error', block)
+ self.assertNotIn(' backend-slow:', WORKFLOW.read_text())
+ self.assertNotIn(' backend-packages:', WORKFLOW.read_text())
+
+ def test_actual_worker_recipe_waits_for_both_slices_and_ordinary_failures(self):
+ fixture = ExecutedRunnerTest()
+ fixture.setUp()
+ self.addCleanup(fixture.doCleanups)
+ root = fixture.root
+ for name in ('scripts/release_control/run_go_package_slice.py',
+ '.github/scripts/record-internal-api-test-seconds.py',
+ '.github/scripts/select-go-package-shard.py',
+ '.github/scripts/go-package-test-seconds.txt'):
+ target = root / name
+ target.parent.mkdir(parents=True, exist_ok=True)
+ shutil.copyfile(ROOT / name, target)
+ # Do not recursively execute this test from the extracted recipe.
+ # The real test command is separately exercised by the CI/source suite.
+ (root / 'scripts/release_control/run_go_package_slice_test.py').write_text(
+ 'import os; raise SystemExit(int(os.environ.get("CONTROL_EXIT","0")))\n')
+ step = job('backend').split(' - name: Go unit tests (shard ${{ matrix.shard }})\n', 1)[1]
+ body = step.split(' run: |\n', 1)[1].split('\n - name:', 1)[0]
+ command = '\n'.join(line[10:] for line in body.splitlines()
+ if line.startswith(' ') or not line.strip())
+ for index, options in enumerate(({}, {'ORDINARY_EXIT':'9'}, {'MODE':'failed-root'},
+ {'LISTING_EXIT':'7'}, {'CONTROL_EXIT':'5'})):
+ with self.subTest(options=options):
+ calls = root / 'calls'
+ calls.write_text('')
+ env = {**os.environ, 'PATH': str(root)+':'+os.environ['PATH'],
+ 'CALLS':str(calls), 'RUNNER_TEMP':str(root / f'output{index}'), **options}
+ result = subprocess.run(['bash', '-c', command.replace('${{ matrix.shard }}', 'rest-0')],
+ cwd=root, env=env, capture_output=True, text=True, timeout=20)
+ self.assertEqual(result.returncode == 0, not options, result.stdout+result.stderr)
+ observed = [json.loads(line) for line in calls.read_text().splitlines()]
+ if 'CONTROL_EXIT' in options:
+ self.assertEqual(observed, [])
+ else:
+ self.assertEqual(sum('-list' in call for call in observed), 2)
+ self.assertEqual(sum('-json' not in call and '-list' not in call
+ and call[0]=='test' for call in observed), 1)
+
+ def test_helpers_are_part_of_the_exact_main_controls_copied_to_patches(self):
+ stable_patch = (ROOT / 'scripts/release_control/stable_patch.py').read_text()
+ self.assertIn('"scripts/release_control"', stable_patch)
+ self.assertTrue(RUNNER.is_relative_to(ROOT / 'scripts/release_control'))
+ self.assertTrue(Path(__file__).is_relative_to(ROOT / 'scripts/release_control'))
+ self.assertIn('python3 scripts/release_control/run_go_package_slice_test.py', job('backend'))
if __name__ == "__main__":
diff --git a/scripts/tests/test_go_test_compilation.py b/scripts/tests/test_go_test_compilation.py
index 91e76379ed..b8af39061e 100644
--- a/scripts/tests/test_go_test_compilation.py
+++ b/scripts/tests/test_go_test_compilation.py
@@ -132,13 +132,10 @@ func TestStaleFixture(t *testing.T) { _ = api.Resource{Alerts: []api.ResourceAle
def test_required_checks_fail_on_bad_compile_and_pass_docs_only_skip(self):
source = WORKFLOW.read_text()
- for name in ("backend-packages", "backend-slow", "backend-api"):
+ for name in ("backend", "backend-api"):
section = job(source, name)
self.assertIn("needs: [changes, test-compile]", section)
- condition = "if: ${{ !cancelled() && needs.changes.result == 'success'"
- if name == "backend-slow":
- condition += " && needs.changes.outputs.code == 'true'"
- self.assertIn(condition + " }}", section)
+ self.assertIn("if: ${{ !cancelled() && needs.changes.result == 'success' }}", section)
self.assertIn("COMPILE_RESULT: ${{ needs.test-compile.result }}", section)
self.assertLess(section.index("Require compiled backend tests"), section.index("Checkout repository"))
script = prerequisite_script(section)
@@ -153,12 +150,7 @@ func TestStaleFixture(t *testing.T) { _ = api.Resource{Alerts: []api.ResourceAle
expected = 0 if code == "false" or result == "success" else 1
self.assertEqual(observed.returncode, expected, observed.stdout + observed.stderr)
# Compile-only success cannot replace these full race/vet runs.
- if name == "backend-slow":
- self.assertIn("run-go-package-slice.py", section)
- self.assertIn('"-race", "-count=1", "-timeout", "50m", "-json"',
- (ROOT / ".github/scripts/run-go-package-slice.py").read_text())
- else:
- self.assertIn("go test -race -timeout 50m", section)
+ self.assertIn("go test -race -timeout 50m", section)
self.assertIn("shard: [rest-0, rest-1]", job(source, "backend"))
self.assertIn("index: [0, 1, 2, 3, 4]", job(source, "backend-api"))
self.assertIn("name: Backend tests (api)", job(source, "backend-api-verdict"))