Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/nightly-compat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ concurrency:

jobs:
resolve-branch:
if: ${{ github.event_name != 'schedule' || github.repository == 'diegosouzapw/OmniRoute' }}
name: Resolve active release branch
runs-on: ubuntu-latest
outputs:
Expand Down Expand Up @@ -57,6 +58,7 @@ jobs:
echo "target=$TARGET" >> "$GITHUB_OUTPUT"

compat-build-26:
if: ${{ github.event_name != 'schedule' || github.repository == 'diegosouzapw/OmniRoute' }}
name: Node 26 Compatibility Build
runs-on: ubuntu-latest
timeout-minutes: 25
Expand Down Expand Up @@ -87,6 +89,7 @@ jobs:
OMNIROUTE_USE_TURBOPACK: "0"

compat-tests:
if: ${{ github.event_name != 'schedule' || github.repository == 'diegosouzapw/OmniRoute' }}
name: Node ${{ matrix.node }} Compat Tests (${{ matrix.shard }}/4)
runs-on: ubuntu-latest
timeout-minutes: 25
Expand Down Expand Up @@ -117,7 +120,7 @@ jobs:
report:
name: Open / update tracking issue on failure
runs-on: ubuntu-latest
if: ${{ !cancelled() && (needs.compat-tests.result == 'failure' || needs.compat-build-26.result == 'failure') }}
if: ${{ (!cancelled() && (needs.compat-tests.result == 'failure' || needs.compat-build-26.result == 'failure')) && (github.event_name != 'schedule' || github.repository == 'diegosouzapw/OmniRoute') }}
needs: [resolve-branch, compat-build-26, compat-tests]
permissions:
issues: write
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/nightly-llm-security.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ permissions:

jobs:
promptfoo-guard:
if: ${{ github.event_name != 'schedule' || github.repository == 'diegosouzapw/OmniRoute' }}
name: promptfoo — injection guard (block mode, no secret)
# #11965: this job runs a backend-only `next build`; the hosted 7 GB runner cannot build
# release/v3.8.51 (VM shutdown ~7 min in), so it targets the box's light pool (`omni-light`:
Expand Down Expand Up @@ -56,6 +57,7 @@ jobs:
run: kill "$(cat server.pid)" || true

garak:
if: ${{ github.event_name != 'schedule' || github.repository == 'diegosouzapw/OmniRoute' }}
name: garak probes (skip without provider secret)
# #11965: this job runs a backend-only `next build`; the hosted 7 GB runner cannot build
# release/v3.8.51 (VM shutdown ~7 min in), so it targets the box's light pool (`omni-light`:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/nightly-mutation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ permissions:

jobs:
stryker:
if: ${{ github.event_name != 'schedule' || github.repository == 'diegosouzapw/OmniRoute' }}
name: Stryker mutation (batch ${{ matrix.batch.name }} — advisory)
runs-on: ubuntu-latest
# Mutation testing is expensive. History of the budget:
Expand Down Expand Up @@ -144,7 +145,7 @@ jobs:
mutation-ratchet:
name: Mutation score ratchet (blocking)
needs: stryker
if: always()
if: ${{ always() && (github.event_name != 'schedule' || github.repository == 'diegosouzapw/OmniRoute') }}
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/nightly-property.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ permissions:
issues: write
jobs:
property-random-seed:
if: ${{ github.event_name != 'schedule' || github.repository == 'diegosouzapw/OmniRoute' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/nightly-release-green.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:
name: Validate active release branch
# On a push, only run for release/* pushes — a push to main is handled by the
# main-green job below. Schedule/dispatch always run (they validate the highest release).
if: ${{ github.event_name != 'push' || startsWith(github.ref_name, 'release/') }}
if: ${{ (github.event_name != 'push' || startsWith(github.ref_name, 'release/')) && (github.event_name != 'schedule' || github.repository == 'diegosouzapw/OmniRoute') }}
# Dynamic runner: with USE_VPS_RUNNER=true (release window / on-demand pre-flight)
# this runs on the dedicated VPS runner — clean env (no operator OMNIROUTE_API_KEY,
# no local noauth CLIs => zero machine-specific false positives) and no contention.
Expand Down Expand Up @@ -275,7 +275,7 @@ jobs:
name: Validate main branch
# On a push, only run for a push to main — a push to release/* is handled by
# release-green above. Schedule/dispatch always run (they also sweep main).
if: ${{ github.event_name != 'push' || github.ref_name == 'main' }}
if: ${{ (github.event_name != 'push' || github.ref_name == 'main') && (github.event_name != 'schedule' || github.repository == 'diegosouzapw/OmniRoute') }}
runs-on: ${{ (vars.USE_VPS_RUNNER == 'true' && fromJSON('["self-hosted","omni-build"]')) || 'ubuntu-latest' }}
env:
JWT_SECRET: ci-nightly-secret-with-sufficient-length-for-validation
Expand Down Expand Up @@ -436,7 +436,7 @@ jobs:
# walk each time. Detection stays on push (release-green above); banking is batched.
bank-ratchet-shrinks:
name: Bank ratchet shrinks
if: ${{ github.event_name != 'push' }}
if: ${{ github.event_name != 'push' && (github.event_name != 'schedule' || github.repository == 'diegosouzapw/OmniRoute') }}
runs-on: ubuntu-latest
permissions:
contents: write
Expand Down Expand Up @@ -567,7 +567,7 @@ jobs:
# first red PR. Advisory: never fails the workflow.
baseline-headroom:
name: Baseline headroom
if: ${{ github.event_name != 'push' }}
if: ${{ github.event_name != 'push' && (github.event_name != 'schedule' || github.repository == 'diegosouzapw/OmniRoute') }}
timeout-minutes: 60
runs-on: ${{ (vars.USE_VPS_RUNNER == 'true' && fromJSON('["self-hosted","omni-light"]')) || 'ubuntu-latest' }}
permissions:
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/nightly-resilience.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ permissions:

jobs:
heap:
if: ${{ github.event_name != 'schedule' || github.repository == 'diegosouzapw/OmniRoute' }}
name: Heap-growth gate
runs-on: ubuntu-latest
steps:
Expand All @@ -23,6 +24,7 @@ jobs:
- run: npm run test:heap

chaos:
if: ${{ github.event_name != 'schedule' || github.repository == 'diegosouzapw/OmniRoute' }}
name: Resilience chaos (fault injection)
runs-on: ubuntu-latest
steps:
Expand All @@ -37,6 +39,7 @@ jobs:
- run: npm run test:chaos

k6-soak:
if: ${{ github.event_name != 'schedule' || github.repository == 'diegosouzapw/OmniRoute' }}
name: k6 load/soak
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -77,6 +80,7 @@ jobs:
run: kill "$(cat server.pid)" || true

a11y:
if: ${{ github.event_name != 'schedule' || github.repository == 'diegosouzapw/OmniRoute' }}
name: A11y axe (nightly, freeze-and-alert)
# #11965: this job runs a backend-only `next build`; the hosted 7 GB runner cannot build
# release/v3.8.51 (VM shutdown ~7 min in), so it targets the box's light pool (`omni-light`:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/nightly-schemathesis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ permissions:

jobs:
schemathesis:
if: ${{ github.event_name != 'schedule' || github.repository == 'diegosouzapw/OmniRoute' }}
name: Schemathesis — OpenAPI contract fuzz (advisory)
# #11965: this job runs a backend-only `next build`; the hosted 7 GB runner cannot build
# release/v3.8.51 (VM shutdown ~7 min in), so it targets the box's light pool (`omni-light`:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/radar-export.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ env:

jobs:
publish-export:
if: ${{ github.event_name != 'schedule' || github.repository == 'diegosouzapw/OmniRoute' }}
runs-on: ubuntu-latest
permissions:
contents: write # gh release upload — clobra o asset estável do export
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/scorecard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ permissions: read-all

jobs:
analysis:
if: ${{ github.event_name != 'push' || github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}
if: ${{ (github.event_name != 'push' || github.ref == format('refs/heads/{0}', github.event.repository.default_branch)) && (github.event_name != 'schedule' || github.repository == 'diegosouzapw/OmniRoute') }}
name: Scorecard analysis
runs-on: ubuntu-latest
permissions:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test-quarantine.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ concurrency:

jobs:
quarantine:
if: ${{ github.event_name != 'schedule' || github.repository == 'diegosouzapw/OmniRoute' }}
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- **ci:** scheduled workflows now run only in the upstream repository, so forks with Actions enabled skip the inherited crons ([#15398](https://github.com/diegosouzapw/OmniRoute/pull/15398)) — thanks @maxmad64bis
128 changes: 128 additions & 0 deletions scripts/check/check-workflows.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import { execFileSync, spawnSync } from "node:child_process";
import fs from "node:fs";
import path from "node:path";
import { pathToFileURL } from "node:url";
import { load as yamlLoad } from "js-yaml";
import { findProvenanceOnSelfHosted, formatProvenanceFinding } from "./lib/provenanceRunner.mjs";

const ROOT = process.cwd();
Expand Down Expand Up @@ -282,6 +283,112 @@ export function runZizmor(workflowsDir) {
// Main
// ---------------------------------------------------------------------------

// ---------------------------------------------------------------------------
// Scheduled-run guard: scheduled executions stay in the upstream repository
// ---------------------------------------------------------------------------

const SCHEDULED_GUARD_EVENT = "github.event_name != 'schedule'";
const SCHEDULED_GUARD_REPO = "github.repository";

/**
* Reads the trigger section of a parsed workflow document. The `on` key is
* read defensively (`doc[true] ?? doc["on"]`) so both YAML 1.1 (boolean true)
* and YAML 1.2 (string "on") parses stay green across parser versions.
* @param {unknown} doc parsed workflow document
* @returns {unknown} the `on` section, or undefined
*/
function readTriggerSection(doc) {
if (!doc || typeof doc !== "object") return undefined;
const record = /** @type {Record<string|symbol, unknown>} */ (doc);
return record[true] ?? record["on"];
}

/**
* Whether a parsed trigger section declares a `schedule` trigger. Accepts the
* object form (`schedule:` with cron entries), the bare string form, and the
* array form of `on:`.
* @param {unknown} onSection parsed `on` section
* @returns {boolean}
*/
function hasScheduleTrigger(onSection) {
if (onSection == null) return false;
if (typeof onSection === "string") return onSection === "schedule";
if (Array.isArray(onSection)) return onSection.includes("schedule");
if (typeof onSection !== "object") return false;
return Object.prototype.hasOwnProperty.call(onSection, "schedule");
}

/**
* Whether a job-level `if` carries the upstream-only scheduled-run guard.
* @param {unknown} condition the job's `if` value
* @returns {boolean}
*/
function hasScheduledGuard(condition) {
return (
typeof condition === "string" &&
condition.includes(SCHEDULED_GUARD_EVENT) &&
condition.includes(SCHEDULED_GUARD_REPO)
);
}

/**
* Lists scheduled jobs missing the upstream-only guard. Fail-closed: an
* unreadable file, invalid YAML, or a document without a usable `jobs` map is
* reported, never silently accepted. A workflow without a `schedule` trigger
* reports nothing. Never throws for these cases; a non-array argument is a
* usage error and still throws.
* @param {string[]} files absolute workflow paths
* @returns {{ file: string, job: string, reason: string }[]}
*/
export function findScheduledJobsWithoutGuard(files) {
if (!Array.isArray(files)) throw new TypeError("files must be an array");
const findings = [];
for (const file of files) {
let text;
try {
text = fs.readFileSync(file, "utf8");
} catch {
findings.push({ file, job: "<unreadable>", reason: "unreadable or missing jobs" });
continue;
}
let doc;
try {
doc = yamlLoad(text);
} catch {
findings.push({ file, job: "<unreadable>", reason: "unreadable or missing jobs" });
continue;
}
if (!hasScheduleTrigger(readTriggerSection(doc))) continue;
const jobs = doc && typeof doc === "object" ? doc.jobs : undefined;
if (!jobs || typeof jobs !== "object" || Array.isArray(jobs)) {
findings.push({ file, job: "<unreadable>", reason: "unreadable or missing jobs" });
continue;
}
for (const [jobName, job] of Object.entries(jobs)) {
if (!job || typeof job !== "object" || Array.isArray(job)) {
findings.push({ file, job: jobName, reason: "unreadable or missing jobs" });
continue;
}
if (!hasScheduledGuard(job.if)) {
findings.push({ file, job: jobName, reason: "scheduled job without upstream guard" });
}
}
}
return findings;
}

/**
* Runs the scheduled-run guard over the given workflow files.
* @param {string[]} files absolute workflow paths
* @returns {{ file: string, job: string, reason: string }[]}
*/
export function runScheduledGuardCheck(files) {
return findScheduledJobsWithoutGuard(files).map((f) => ({
...f,
file: path.relative(ROOT, f.file),
}));
}

/**
* Hard rule (not a lint count): `--provenance` inside a job that runs on a
* self-hosted runner. npm answers 422 at the registry, and in v3.8.50 that
Expand Down Expand Up @@ -383,6 +490,18 @@ function main() {
// version that produced it. See zizmorVersion().
process.stdout.write(`zizmorVersion=${scannerVersion}\n`);
process.stdout.write(`provenanceRunnerFindings=${provenanceFindings.length}\n`);
const scheduledGuardFindings = runScheduledGuardCheck(workflowFiles);
if (scheduledGuardFindings.length > 0) {
console.error(
`[check-workflows] scheduled-guard: ${scheduledGuardFindings.length} finding(s) — HARD RULE:`
);
scheduledGuardFindings.forEach((f) =>
console.error(` ${f.file}: job "${f.job}" — ${f.reason}`)
);
} else if (!QUIET) {
console.log("[check-workflows] scheduled-guard: OK (0 findings)");
}
process.stdout.write(`scheduledGuardFindings=${scheduledGuardFindings.length}\n`);
if ((STRICT || RATCHET) && provenanceFindings.length > 0) {
console.error(
`\n[check-workflows] FAIL — ${provenanceFindings.length} job(s) publish with --provenance from a self-hosted runner.\n` +
Expand All @@ -392,6 +511,15 @@ function main() {
process.exit(1);
}

if ((STRICT || RATCHET) && scheduledGuardFindings.length > 0) {
console.error(
`\n[check-workflows] FAIL — ${scheduledGuardFindings.length} scheduled job(s) without the upstream-only guard.\n` +
" Scheduled runs must stay in diegosouzapw/OmniRoute: keep the job-level `if:` naming both\n" +
" `github.event_name != 'schedule'` and `github.repository`."
);
process.exit(1);
}

if (STRICT && total > 0) {
console.error(`\n[check-workflows] FAIL — ${total} workflow finding(s) total (--strict mode).`);
process.exit(1);
Expand Down
Loading
Loading