From b62610f9c544db56e004812474f33d6633de20ad Mon Sep 17 00:00:00 2001 From: "melodic-standards-sync[bot]" <300666570+melodic-standards-sync[bot]@users.noreply.github.com> Date: Sat, 21 Nov 2026 22:24:48 +0000 Subject: [PATCH] chore: sync standards components (a108391366e7aeefa92a4a19faba9201d3680b17) --- .../standards/runner-policy/runner-policy.mjs | 59 +++++++++++++++---- .../trusted-actors/trusted-actors.json | 1 - .../pr-check-managed-files-hosted.yml | 1 + 3 files changed, 49 insertions(+), 12 deletions(-) diff --git a/.github/standards/runner-policy/runner-policy.mjs b/.github/standards/runner-policy/runner-policy.mjs index 900b442ad2c..4d632cadbaf 100755 --- a/.github/standards/runner-policy/runner-policy.mjs +++ b/.github/standards/runner-policy/runner-policy.mjs @@ -6,7 +6,7 @@ // overwritten by the next sync PR; change the component upstream, or move the // component to `locally-owned` in the manifest to customize. -import { readdir, readFile } from "node:fs/promises"; +import { lstat, readdir, readFile } from "node:fs/promises"; import path from "node:path"; import process from "node:process"; import { pathToFileURL } from "node:url"; @@ -35,6 +35,12 @@ const YAML_PARSE_OPTIONS = { const MODULE_DIRECTORY = import.meta.dirname; const DEFAULT_POLICY_PATH = path.join(MODULE_DIRECTORY, "policy.json"); const DEFAULT_CONFIG_PATH = ".github/runner-policy.json"; +const DEFAULT_PUBLIC_REPOSITORY_CONFIG = Object.freeze({ + schemaVersion: 1, + visibility: "public", + selfHostedCi: false, + exceptions: Object.freeze({}), +}); const POLICY_SCHEMA_PATH = path.join(MODULE_DIRECTORY, "policy.schema.json"); const REPOSITORY_POLICY_SCHEMA_PATH = path.join(MODULE_DIRECTORY, "repository-policy.schema.json"); const POLICY_SCHEMA = parseUniqueJson( @@ -409,6 +415,39 @@ async function readJson(filePath, location) { return parseUniqueJson(source, `${location} at ${filePath}`); } +async function readRepositoryConfig(filePath, { configPath, repositoryVisibility }) { + let source; + try { + source = await readFile(filePath, "utf8"); + } catch (error) { + if (error.code === "ENOENT" && configPath === DEFAULT_CONFIG_PATH) { + let existsAsLink = false; + try { + await lstat(filePath); + existsAsLink = true; + } catch { + // Truly absent, not a dangling symlink. + } + if (!existsAsLink) { + if (repositoryVisibility === "public") { + return DEFAULT_PUBLIC_REPOSITORY_CONFIG; + } + const requirement = + repositoryVisibility === "private" + ? "private repositories must declare .github/runner-policy.json" + : '.github/runner-policy.json may be omitted only when CI_REPOSITORY_VISIBILITY or --repository-visibility is "public"'; + throw new ConfigurationError( + `repository runner config could not be read at ${filePath}: ${error.message} (${requirement})`, + ); + } + } + throw new ConfigurationError( + `repository runner config could not be read at ${filePath}: ${error.message}`, + ); + } + return parseUniqueJson(source, `repository runner config at ${filePath}`); +} + function parseWorkflow(source, file) { const workflow = parseYamlMapping(source, file); if (!isMapping(workflow.jobs)) { @@ -2030,19 +2069,17 @@ export async function auditRepository({ ? policyPath : path.join(resolvedRoot, policyPath); const basePolicy = validatePolicy(await readJson(resolvedPolicy, "runner policy")); + if (repositoryVisibility && !new Set(["public", "private"]).has(repositoryVisibility)) { + throw new ConfigurationError('repository visibility evidence must be "public" or "private"'); + } const config = validateRepositoryConfig( - await readJson(resolvedConfig, "repository runner config"), + await readRepositoryConfig(resolvedConfig, { configPath, repositoryVisibility }), basePolicy, ); - if (repositoryVisibility) { - if (!new Set(["public", "private"]).has(repositoryVisibility)) { - throw new ConfigurationError('repository visibility evidence must be "public" or "private"'); - } - if (repositoryVisibility !== config.visibility) { - throw new ConfigurationError( - `repository visibility evidence is ${repositoryVisibility}, but .github/runner-policy.json declares ${config.visibility}`, - ); - } + if (repositoryVisibility && repositoryVisibility !== config.visibility) { + throw new ConfigurationError( + `repository visibility evidence is ${repositoryVisibility}, but .github/runner-policy.json declares ${config.visibility}`, + ); } const repositoryOwner = resolveRepositoryOwner(config, githubRepository); const policy = { ...basePolicy, repositoryOwner }; diff --git a/.github/standards/trusted-actors/trusted-actors.json b/.github/standards/trusted-actors/trusted-actors.json index b1dc6e56e38..4cfaca20843 100644 --- a/.github/standards/trusted-actors/trusted-actors.json +++ b/.github/standards/trusted-actors/trusted-actors.json @@ -11,7 +11,6 @@ { "id": 288071998, "login": "melodic-ai[bot]", "kind": "bot" }, { "id": 296023097, "login": "melodic-software-github-iac[bot]", "kind": "bot" }, { "id": 300690090, "login": "melodic-ci-runner-host[bot]", "kind": "bot" }, - { "id": 302525172, "login": "melodic-ci-runner-observer[bot]", "kind": "bot" }, { "id": 337859524, "login": "melodic-release[bot]", "kind": "bot" } ] } diff --git a/.github/workflows/pr-check-managed-files-hosted.yml b/.github/workflows/pr-check-managed-files-hosted.yml index 3dd53e4b7c2..c6fcd70877a 100644 --- a/.github/workflows/pr-check-managed-files-hosted.yml +++ b/.github/workflows/pr-check-managed-files-hosted.yml @@ -61,6 +61,7 @@ on: - .github/standards/trusted-actors/trusted-actors.json - .github/standards/trusted-actors/trusted-actors.schema.json - .github/workflows/maintenance-check-links-online.yml + - .github/workflows/pr-automerge-dependabot-hosted.yml - .github/workflows/pr-check-managed-files-hosted.yml - .github/workflows/pr-review-hosted.yml - .github/workflows/pr-review-security-hosted.yml