Files
orca/config/scripts/dev-channel-orcad-template-workflow.test.mjs
T
f4d98b74e3 ci: run hourly and daily dev builds on free hosted runners (#34585)
Hourly and daily builds publish unvetted dev channels on a schedule, so their
latency is not user-facing. Move the macOS build to hosted macos-15, the
Windows build to hosted windows-2022 (the release path), template
qualification to hosted lanes, and the small routing/publish jobs to
ubuntu-latest. Adhoc and release builds stay on Blacksmith.

Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
Co-authored-by: Claude <noreply@anthropic.com>
2026-10-27 16:02:46 -07:00

68 lines
2.6 KiB
JavaScript

import { readFileSync } from 'node:fs'
import { describe, expect, it } from 'vitest'
import { parse } from 'yaml'
// Every SSH host needs template-deployed orcad; missing dev-channel templates break all SSH connections.
function readWorkflow(name) {
return parse(readFileSync(new URL(`../../.github/workflows/${name}`, import.meta.url), 'utf8'))
}
const channels = [
{
name: 'hourly',
workflow: readWorkflow('hourly-mac-build.yml'),
macJob: 'build-hourly-mac',
winJob: 'build-hourly-win',
pinnedSha: '${{ needs.preflight.outputs.head_sha }}'
},
{
name: 'daily',
workflow: readWorkflow('daily-mac-build.yml'),
macJob: 'build-daily-mac',
winJob: 'build-daily-win',
pinnedSha: '${{ needs.resolve-main.outputs.head_sha }}'
}
]
describe.each(channels)('$name build ships the orcad template', (channel) => {
const { jobs } = channel.workflow
const mac = jobs[channel.macJob]
const stepIndex = (predicate) => mac.steps.findIndex(predicate)
it('builds the template from the commit the app is built from', () => {
const template = jobs['orcad-template']
expect(template.uses).toBe('./.github/workflows/node-server-tests.yml')
expect(template.with).toEqual({
ref: channel.pinnedSha,
build_template: true,
fast_runners: false
})
expect(template.permissions).toEqual({ contents: 'read', actions: 'read' })
expect(template.secrets).toBeUndefined()
expect(mac.steps.find((step) => step.name === 'Checkout').with.ref).toBe(channel.pinnedSha)
})
it('packages the macOS build only with the template present', () => {
expect(mac.needs).toContain('orcad-template')
// Implicit success(): a failed template job must skip the signed build.
expect(mac.if ?? '').not.toMatch(/always\(\)|!cancelled\(\)/)
const build = stepIndex((step) => step.name === 'Build app')
const download = stepIndex((step) => step.name === 'Download the orcad deployment template')
const publish = stepIndex((step) => step.with?.command?.includes('electron-builder'))
expect(build).toBeGreaterThanOrEqual(0)
expect(download).toBeGreaterThan(build)
expect(publish).toBeGreaterThan(download)
expect(mac.steps[download].uses).toMatch(/^actions\/download-artifact@/)
expect(mac.steps[download].with).toEqual({
name: 'orcad-template',
path: 'out/orcad-template'
})
expect(mac.steps[publish].env.ORCA_REQUIRE_ORCAD_TEMPLATE).toBe('1')
})
it('ships the same template in the Windows build', () => {
expect(jobs[channel.winJob].uses).toBe('./.github/workflows/dev-channel-win-build.yml')
expect(jobs[channel.winJob].with.orcad_template).toBe(true)
})
})