From 9f575906f64668160a9bd0beeaae77b82bcb187f Mon Sep 17 00:00:00 2001 From: firestar5683 <168790843+firestar5683@users.noreply.github.com> Date: Tue, 17 Nov 2026 20:23:12 -0600 Subject: [PATCH] Use Stable and Testing channels in legacy Galaxy and build tools --- .github/workflows/channel-migration.yaml | 30 +++++++++++++ .github/workflows/compile_bluescreens.yaml | 6 +++ .github/workflows/compile_starpilot.yaml | 8 +++- .github/workflows/docs.yaml | 21 +++++++++ .github/workflows/flm-offroad.yaml | 21 +++++++++ .github/workflows/galaxy-phone-bridge.yaml | 21 +++++++++ .github/workflows/safety.yaml | 21 +++++++++ .github/workflows/simulator-driving.yaml | 21 +++++++++ .github/workflows/tests.yaml | 21 +++++++++ scripts/tests/test_stable_build_targets.py | 37 +++++++++++++++ scripts/tests/test_stable_workflows.mjs | 32 +++++++++++++ .../assets/mobile/js/views/SystemTools.js | 26 +++++------ .../the_galaxy/tests/test_branch_selector.mjs | 45 +++++++++++++++++-- starpilot/system/the_galaxy/the_galaxy.py | 4 +- 14 files changed, 295 insertions(+), 19 deletions(-) create mode 100644 .github/workflows/channel-migration.yaml create mode 100644 .github/workflows/docs.yaml create mode 100644 .github/workflows/flm-offroad.yaml create mode 100644 .github/workflows/galaxy-phone-bridge.yaml create mode 100644 .github/workflows/safety.yaml create mode 100644 .github/workflows/simulator-driving.yaml create mode 100644 .github/workflows/tests.yaml create mode 100644 scripts/tests/test_stable_build_targets.py create mode 100644 scripts/tests/test_stable_workflows.mjs diff --git a/.github/workflows/channel-migration.yaml b/.github/workflows/channel-migration.yaml new file mode 100644 index 0000000000..13fb2d00dd --- /dev/null +++ b/.github/workflows/channel-migration.yaml @@ -0,0 +1,30 @@ +name: Legacy channel migration contracts + +on: + push: + branches: [StarPilot, stable, review/nov17-stable-channel-config] + pull_request: + paths: + - 'scripts/branch_migration.py' + - 'scripts/tests/test_stable_workflows.mjs' + - '.github/workflows/**' + - 'starpilot/system/the_galaxy/assets/mobile/js/views/SystemTools.js' + - 'starpilot/system/the_galaxy/tests/test_branch_selector.mjs' + workflow_dispatch: + +permissions: + contents: read + +jobs: + contracts: + name: Legacy channel migration contracts + runs-on: ubuntu-24.04 + timeout-minutes: 10 + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: '22' + - run: node starpilot/system/the_galaxy/tests/test_branch_selector.mjs "$PWD" + - run: node scripts/tests/test_stable_workflows.mjs "$PWD" + - run: python3 -m unittest discover -s scripts/tests -p test_stable_build_targets.py -v diff --git a/.github/workflows/compile_bluescreens.yaml b/.github/workflows/compile_bluescreens.yaml index 2f5d59494f..d9174f9ac5 100644 --- a/.github/workflows/compile_bluescreens.yaml +++ b/.github/workflows/compile_bluescreens.yaml @@ -82,6 +82,12 @@ jobs: echo "BUILD_BRANCH=${TARGET_REF}" >> "$GITHUB_ENV" fi + branch="${TARGET_REF#refs/heads/}" + git check-ref-format --branch "$branch" + case "$branch" in + Dom|StarPilot) echo "Compatibility bridges cannot receive build commits." >&2; exit 1 ;; + esac + - name: Checkout target branch uses: actions/checkout@v6 with: diff --git a/.github/workflows/compile_starpilot.yaml b/.github/workflows/compile_starpilot.yaml index ddedaa2e18..b36b75853f 100644 --- a/.github/workflows/compile_starpilot.yaml +++ b/.github/workflows/compile_starpilot.yaml @@ -6,7 +6,7 @@ on: target_ref: description: "Branch to build and publish back to" type: string - default: "master" + default: "stable" required: true jobs: description: "Optional parallel job count passed to ./build" @@ -47,6 +47,12 @@ jobs: echo "BUILD_BRANCH=${TARGET_REF}" >> "$GITHUB_ENV" fi + branch="${TARGET_REF#refs/heads/}" + git check-ref-format --branch "$branch" + case "$branch" in + Dom|StarPilot) echo "Compatibility bridges cannot receive build commits." >&2; exit 1 ;; + esac + - name: Checkout target branch uses: actions/checkout@v6 with: diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml new file mode 100644 index 0000000000..3e616c46ee --- /dev/null +++ b/.github/workflows/docs.yaml @@ -0,0 +1,21 @@ +name: Testing docs (manual) + +on: + workflow_dispatch: + +permissions: + contents: read + actions: write + +jobs: + dispatch: + name: Queue Testing qualification + runs-on: ubuntu-24.04 + timeout-minutes: 5 + steps: + - uses: actions/github-script@v7 + with: + script: | + const branch = await github.rest.repos.getBranch({...context.repo, branch: 'testing'}); + await github.rest.actions.createWorkflowDispatch({...context.repo, workflow_id: 'docs.yaml', ref: 'testing'}); + core.notice('Queued docs.yaml on Testing (observed head ' + branch.data.commit.sha + '). Check that workflow for qualification results; this job only dispatches it.'); diff --git a/.github/workflows/flm-offroad.yaml b/.github/workflows/flm-offroad.yaml new file mode 100644 index 0000000000..6708301973 --- /dev/null +++ b/.github/workflows/flm-offroad.yaml @@ -0,0 +1,21 @@ +name: Testing flm-offroad (manual) + +on: + workflow_dispatch: + +permissions: + contents: read + actions: write + +jobs: + dispatch: + name: Queue Testing qualification + runs-on: ubuntu-24.04 + timeout-minutes: 5 + steps: + - uses: actions/github-script@v7 + with: + script: | + const branch = await github.rest.repos.getBranch({...context.repo, branch: 'testing'}); + await github.rest.actions.createWorkflowDispatch({...context.repo, workflow_id: 'flm-offroad.yaml', ref: 'testing'}); + core.notice('Queued flm-offroad.yaml on Testing (observed head ' + branch.data.commit.sha + '). Check that workflow for qualification results; this job only dispatches it.'); diff --git a/.github/workflows/galaxy-phone-bridge.yaml b/.github/workflows/galaxy-phone-bridge.yaml new file mode 100644 index 0000000000..2f85580c0b --- /dev/null +++ b/.github/workflows/galaxy-phone-bridge.yaml @@ -0,0 +1,21 @@ +name: Testing galaxy-phone-bridge (manual) + +on: + workflow_dispatch: + +permissions: + contents: read + actions: write + +jobs: + dispatch: + name: Queue Testing qualification + runs-on: ubuntu-24.04 + timeout-minutes: 5 + steps: + - uses: actions/github-script@v7 + with: + script: | + const branch = await github.rest.repos.getBranch({...context.repo, branch: 'testing'}); + await github.rest.actions.createWorkflowDispatch({...context.repo, workflow_id: 'galaxy-phone-bridge.yaml', ref: 'testing'}); + core.notice('Queued galaxy-phone-bridge.yaml on Testing (observed head ' + branch.data.commit.sha + '). Check that workflow for qualification results; this job only dispatches it.'); diff --git a/.github/workflows/safety.yaml b/.github/workflows/safety.yaml new file mode 100644 index 0000000000..5a5746034f --- /dev/null +++ b/.github/workflows/safety.yaml @@ -0,0 +1,21 @@ +name: Testing safety (manual) + +on: + workflow_dispatch: + +permissions: + contents: read + actions: write + +jobs: + dispatch: + name: Queue Testing qualification + runs-on: ubuntu-24.04 + timeout-minutes: 5 + steps: + - uses: actions/github-script@v7 + with: + script: | + const branch = await github.rest.repos.getBranch({...context.repo, branch: 'testing'}); + await github.rest.actions.createWorkflowDispatch({...context.repo, workflow_id: 'safety.yaml', ref: 'testing'}); + core.notice('Queued safety.yaml on Testing (observed head ' + branch.data.commit.sha + '). Check that workflow for qualification results; this job only dispatches it.'); diff --git a/.github/workflows/simulator-driving.yaml b/.github/workflows/simulator-driving.yaml new file mode 100644 index 0000000000..122e2f44a4 --- /dev/null +++ b/.github/workflows/simulator-driving.yaml @@ -0,0 +1,21 @@ +name: Testing simulator-driving (manual) + +on: + workflow_dispatch: + +permissions: + contents: read + actions: write + +jobs: + dispatch: + name: Queue Testing qualification + runs-on: ubuntu-24.04 + timeout-minutes: 5 + steps: + - uses: actions/github-script@v7 + with: + script: | + const branch = await github.rest.repos.getBranch({...context.repo, branch: 'testing'}); + await github.rest.actions.createWorkflowDispatch({...context.repo, workflow_id: 'simulator-driving.yaml', ref: 'testing'}); + core.notice('Queued simulator-driving.yaml on Testing (observed head ' + branch.data.commit.sha + '). Check that workflow for qualification results; this job only dispatches it.'); diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml new file mode 100644 index 0000000000..53732736be --- /dev/null +++ b/.github/workflows/tests.yaml @@ -0,0 +1,21 @@ +name: Testing tests (manual) + +on: + workflow_dispatch: + +permissions: + contents: read + actions: write + +jobs: + dispatch: + name: Queue Testing qualification + runs-on: ubuntu-24.04 + timeout-minutes: 5 + steps: + - uses: actions/github-script@v7 + with: + script: | + const branch = await github.rest.repos.getBranch({...context.repo, branch: 'testing'}); + await github.rest.actions.createWorkflowDispatch({...context.repo, workflow_id: 'tests.yaml', ref: 'testing'}); + core.notice('Queued tests.yaml on Testing (observed head ' + branch.data.commit.sha + '). Check that workflow for qualification results; this job only dispatches it.'); diff --git a/scripts/tests/test_stable_build_targets.py b/scripts/tests/test_stable_build_targets.py new file mode 100644 index 0000000000..6db1fe58d6 --- /dev/null +++ b/scripts/tests/test_stable_build_targets.py @@ -0,0 +1,37 @@ +from pathlib import Path +import os +import subprocess +import tempfile +import unittest + +ROOT = Path(__file__).resolve().parents[2] + + +class BuildTargetsTest(unittest.TestCase): + def test_build_targets_reject_bridge_and_invalid_refs(self): + for workflow in ('compile_starpilot.yaml', 'compile_bluescreens.yaml'): + source = (ROOT / '.github/workflows' / workflow).read_text() + guard = source.split(' branch="${TARGET_REF#refs/heads/}"', 1)[1].split('\n - ', 1)[0] + script = 'set -eu\nbranch="${TARGET_REF#refs/heads/}"\n' + '\n'.join(line[10:] if line.startswith(' ') else line for line in guard.splitlines()) + with tempfile.TemporaryDirectory() as temporary: + for target in ('stable', 'testing', 'bluescreensonly2', 'refs/heads/stable'): + with self.subTest(workflow=workflow, target=target): + result = subprocess.run(['bash', '-c', script], cwd=temporary, env={**os.environ, 'TARGET_REF': target}, capture_output=True) + self.assertEqual(result.returncode, 0, result.stderr) + for target in ('Dom', 'StarPilot', 'refs/heads/Dom', 'refs/heads/StarPilot', '-bad', 'feature\nBUILD_BRANCH=Dom', 'HEAD', 'refs/heads/../../Dom'): + with self.subTest(workflow=workflow, target=target): + result = subprocess.run(['bash', '-c', script], cwd=temporary, env={**os.environ, 'TARGET_REF': target}, capture_output=True) + self.assertNotEqual(result.returncode, 0) + + def test_default_stable_and_source_only_fleet_gate(self): + compile_workflow = (ROOT / '.github/workflows/compile_starpilot.yaml').read_text() + self.assertIn('default: "stable"', compile_workflow) + self.assertIn('git push origin "HEAD:refs/heads/${BUILD_BRANCH}"', compile_workflow) + self.assertNotIn('--force', compile_workflow) + fleet = (ROOT / '.github/workflows/fleet_safety.yaml').read_text() + self.assertIn('python -m selfdrive.car.tests.fleet_safety --all --release', fleet) + self.assertNotIn('openpilot/selfdrive/', fleet) + + +if __name__ == '__main__': + unittest.main() diff --git a/scripts/tests/test_stable_workflows.mjs b/scripts/tests/test_stable_workflows.mjs new file mode 100644 index 0000000000..b76b25ee20 --- /dev/null +++ b/scripts/tests/test_stable_workflows.mjs @@ -0,0 +1,32 @@ +import fs from 'node:fs' +import vm from 'node:vm' +import assert from 'node:assert/strict' +import test from 'node:test' +const root = process.argv[2] || new URL('../', import.meta.url).pathname +const workflows = ['tests.yaml', 'safety.yaml', 'docs.yaml', 'flm-offroad.yaml', 'galaxy-phone-bridge.yaml', 'simulator-driving.yaml'] +for (const workflow of workflows) { + const source = fs.readFileSync(root + '/.github/workflows/' + workflow, 'utf8') + const script = source.split(' script: |\n')[1].split('\n').map(line => line.slice(12)).join('\n') + test(workflow + ' dispatches only the genuine Testing workflow without claiming qualification', async () => { + const calls = [], notices = [] + const context = {repo: {owner: 'StarPilotHQ', repo: 'StarPilot'}} + const github = {rest: { + repos: {getBranch: async args => {calls.push(['branch', args]); return {data: {commit: {sha: 'a'.repeat(40)}}}}}, + actions: {createWorkflowDispatch: async args => {calls.push(['dispatch', args])}}, + }} + await vm.runInNewContext('(async () => {' + script + '})()', {github, context, core: {notice: message => notices.push(message)}}) + assert.deepEqual(JSON.parse(JSON.stringify(calls)), [ + ['branch', {...context.repo, branch: 'testing'}], + ['dispatch', {...context.repo, workflow_id: workflow, ref: 'testing'}], + ]) + assert.match(notices[0], /this job only dispatches/) + assert.match(source, /actions: write/) + assert.doesNotMatch(source, /contents: write|schedule:|pull_request:|\bpush:/) + }) + test(workflow + ' fails before dispatch if Testing is unavailable', async () => { + let dispatched = false + const github = {rest: {repos: {getBranch: async () => {throw Error('missing Testing')}}, actions: {createWorkflowDispatch: async () => {dispatched = true}}}} + await assert.rejects(vm.runInNewContext('(async () => {' + script + '})()', {github, context: {repo: {}}, core: {notice() {}}}), /missing Testing/) + assert.equal(dispatched, false) + }) +} diff --git a/starpilot/system/the_galaxy/assets/mobile/js/views/SystemTools.js b/starpilot/system/the_galaxy/assets/mobile/js/views/SystemTools.js index 89c077565e..5c7347e19a 100644 --- a/starpilot/system/the_galaxy/assets/mobile/js/views/SystemTools.js +++ b/starpilot/system/the_galaxy/assets/mobile/js/views/SystemTools.js @@ -60,7 +60,7 @@ function githubCommitsUrl(remote, commitsUrl, branch) { return `${base}/commits/${encodeURIComponent(normalizedBranch)}/` } -const CORE_UPDATE_BRANCHES = ["StarPilot", "Dom"] +const CORE_UPDATE_BRANCHES = ["stable", "testing"] const REBOOT_PENDING_STORAGE_KEY = "galaxy-update-reboot-pending" const LOCAL_DEVICE_SCOPE = "local" const DEVICE_SLUG_RE = /^[A-Za-z0-9]{16}$/ @@ -177,11 +177,11 @@ export const SystemTools = { computed: { primaryBranchValue() { if (this.otherBranchesOpen) return "other:" - return ["StarPilot", "Dom"].includes(this.targetBranch) ? this.targetBranch : "" + return CORE_UPDATE_BRANCHES.includes(this.targetBranch) ? this.targetBranch : "" }, otherBranches() { - const branches = this.branches.filter(branch => !["StarPilot", "Dom"].includes(branch)) - if (this.currentBranch && !["StarPilot", "Dom"].includes(this.currentBranch) && !branches.includes(this.currentBranch)) { + const branches = this.branches.filter(branch => !CORE_UPDATE_BRANCHES.includes(branch)) + if (this.currentBranch && !CORE_UPDATE_BRANCHES.includes(this.currentBranch) && !branches.includes(this.currentBranch)) { branches.unshift(this.currentBranch) } return branches @@ -200,7 +200,7 @@ export const SystemTools = { }, updateInProgress() { return !!this.fastStatus?.running || this.statusRebooting || this.rebootPending }, statusPollingNeeded() { return this.statusUnavailable || !this.fastStatus || this.updateInProgress || this.rebootPending }, - versionChoices() { return this.targetBranch === "StarPilot" ? releaseVersions(this.versionCommits) : this.versionCommits }, + versionChoices() { return ["StarPilot", "stable"].includes(this.targetBranch) ? releaseVersions(this.versionCommits) : this.versionCommits }, installVersionBlocked() { return this.branchSwitchBlocked || this.branchBusy || !this.branches.includes(this.targetBranch) || (this.versionMode === "earlier" && (this.versionLoading || !/^[a-f0-9]{40}$/.test(this.selectedCommit) || !this.versionChoices.some(commit => commit.sha === this.selectedCommit))) @@ -238,7 +238,7 @@ export const SystemTools = { this.branchListError = "" if (!this.targetBranch) { this.targetBranch = this.currentBranch - this.otherBranchesOpen = !!this.targetBranch && !["StarPilot", "Dom"].includes(this.targetBranch) + this.otherBranchesOpen = !!this.targetBranch && !CORE_UPDATE_BRANCHES.includes(this.targetBranch) } this.isOnroad = !!data?.isOnroad } catch (e) { @@ -253,7 +253,7 @@ export const SystemTools = { this.branches = [...new Set([current, ...CORE_UPDATE_BRANCHES].filter(Boolean))] this.branchListFallback = true if (!this.targetBranch) { - this.targetBranch = current || "Dom" + this.targetBranch = current || "stable" this.otherBranchesOpen = !!this.targetBranch && !CORE_UPDATE_BRANCHES.includes(this.targetBranch) } showSnackbar("Could not refresh the full branch list. Standard branches are still available.", "error") @@ -397,7 +397,7 @@ export const SystemTools = { if (!branch || !this.branches.includes(branch) || this.branchBusy || this.branchSwitchBlocked) return if (branch === this.targetBranch) return this.targetBranch = branch - this.otherBranchesOpen = !["StarPilot", "Dom"].includes(branch) + this.otherBranchesOpen = !CORE_UPDATE_BRANCHES.includes(branch) this.resetVersions() }, resetVersions() { @@ -433,7 +433,7 @@ export const SystemTools = { this.versionLoading = true this.versionError = "" const originalCount = this.versionChoices.length - const budget = more && branch === "StarPilot" ? 4 : 1 + const budget = more && ["StarPilot", "stable"].includes(branch) ? 4 : 1 try { for (let scanned = 0; scanned < budget; scanned++) { const data = await api.getUpdateVersions(branch, {page, head, signal: controller.signal}) @@ -483,7 +483,7 @@ export const SystemTools = { this.branchBusy = true try { const selected = this.versionCommits.find(item => item.sha === commit) - const version = commit === "latest" ? "Latest" : `${versionTitle(selected, branch === "StarPilot")}\nCommit: ${commit}` + const version = commit === "latest" ? "Latest" : `${versionTitle(selected, ["StarPilot", "stable"].includes(branch))}\nCommit: ${commit}` const policy = commit === "latest" ? "This uses the normal branch updater, including any required OS update during startup. Your automatic-update setting is unchanged." : "Automatic updates will be paused for this earlier version." const recovery = commit === "latest" ? "This replaces the current software. Settings and statistics are kept. Local code changes may be overwritten; standard Rollback saves the previous committed version." @@ -724,8 +724,8 @@ export const SystemTools = { - - + +
@@ -747,7 +747,7 @@ export const SystemTools = { diff --git a/starpilot/system/the_galaxy/tests/test_branch_selector.mjs b/starpilot/system/the_galaxy/tests/test_branch_selector.mjs index 8a6ff9820a..51225e74d9 100644 --- a/starpilot/system/the_galaxy/tests/test_branch_selector.mjs +++ b/starpilot/system/the_galaxy/tests/test_branch_selector.mjs @@ -19,7 +19,7 @@ function fixture() { vm.runInContext(fs.readFileSync(js + 'components/VersionHistoryPicker.js', 'utf8').replace(/export /g, ''), context) vm.runInContext(source.replace(/^import .*$/gm, '').replace('export const SystemTools =', 'globalThis.component ='), context) const component = context.component - const instance = {...component.data(), ...component.methods, branches: ['Dom', 'SunnyPilot', 'StarPilot', 'feature/test'], currentBranch: 'feature/local', branchLoading: false} + const instance = {...component.data(), ...component.methods, branches: ['stable', 'testing', 'Dom', 'SunnyPilot', 'StarPilot', 'feature/test'], currentBranch: 'feature/local', branchLoading: false} for (const [key, getter] of Object.entries(component.computed)) Object.defineProperty(instance, key, {get: () => getter.call(instance)}) return {instance, calls, confirmations, messages, reads, api, setConfirm: fn => {confirm = fn}} } @@ -37,10 +37,10 @@ test('primary and Other choices stage a target without installing or confirming' }) test('current custom branch remains visible when absent from remote', () => { const {instance} = fixture() - assert.deepEqual(Array.from(instance.otherBranches), ['feature/local', 'SunnyPilot', 'feature/test']) + assert.deepEqual(Array.from(instance.otherBranches), ['feature/local', 'Dom', 'SunnyPilot', 'StarPilot', 'feature/test']) }) test('every remote branch can install latest only through explicit confirmation', async () => { - for (const branch of ['StarPilot', 'Dom', 'SunnyPilot', 'feature/test']) { + for (const branch of ['stable', 'testing', 'StarPilot', 'Dom', 'SunnyPilot', 'feature/test']) { const {instance, calls, confirmations} = fixture() instance.selectTargetBranch(branch) await instance.installSelectedVersion() @@ -290,3 +290,42 @@ test('Latest explains normal OS handling and local-edit behavior; historical con assert.match(confirmations[1].message, /updates will be paused/) assert.match(confirmations[1].message, /code changes are backed up/) }) + + +test('Stable and Testing are the primary choices; old aliases stay under Other', () => { + const {instance} = fixture() + assert.match(source, /