@homeflare/config 0.11.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -1
- package/dist/hooks/gates.d.ts.map +1 -1
- package/dist/hooks/oxfmt-config.d.ts +25 -0
- package/dist/hooks/oxfmt-config.d.ts.map +1 -0
- package/dist/hooks/report.d.ts +10 -0
- package/dist/hooks/report.d.ts.map +1 -1
- package/dist/hooks.js +70 -11
- package/dist/hooks.js.map +6 -5
- package/dist/repo-shape/dependabot.d.ts +11 -17
- package/dist/repo-shape/dependabot.d.ts.map +1 -1
- package/dist/repo-shape/render.d.ts.map +1 -1
- package/dist/repo-shape/shape.d.ts +1 -1
- package/dist/repo-shape/shape.d.ts.map +1 -1
- package/dist/repo-shape/yaml.d.ts +20 -3
- package/dist/repo-shape/yaml.d.ts.map +1 -1
- package/dist/repo-shape.d.ts +2 -4
- package/dist/repo-shape.d.ts.map +1 -1
- package/dist/repo-shape.js +106 -202
- package/dist/repo-shape.js.map +7 -8
- package/dist/versions.js +8 -2
- package/dist/versions.js.map +4 -4
- package/docs/hooks.md +19 -0
- package/docs/repo-shape-dependabot.md +31 -43
- package/package.json +1 -1
- package/src/hooks/gates.ts +70 -12
- package/src/hooks/oxfmt-config.ts +67 -0
- package/src/hooks/report.ts +15 -0
- package/src/repo-shape/dependabot.ts +23 -38
- package/src/repo-shape/render.ts +0 -3
- package/src/repo-shape/shape.ts +0 -1
- package/src/repo-shape/yaml.ts +26 -4
- package/src/repo-shape.ts +1 -4
- package/dist/repo-shape/automerge.d.ts +0 -17
- package/dist/repo-shape/automerge.d.ts.map +0 -1
- package/src/repo-shape/automerge.ts +0 -144
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `.github/workflows/dependabot-automerge.yml`, rendered.
|
|
3
|
-
*
|
|
4
|
-
* ★ THE OTHER HALF OF THE `homeflare` GROUP. Dependabot opens the bump; this arms GitHub's
|
|
5
|
-
* own auto-merge on it; the branch ruleset's required checks (`ci`, `secret scan`)
|
|
6
|
-
* decide whether it ever merges. Nothing here merges anything itself, and a merge
|
|
7
|
-
* deploys nothing — every stack in the estate is deployed by hand.
|
|
8
|
-
*
|
|
9
|
-
* ⛔ `gh pr merge --auto` IS NOT ALWAYS "ARM". When the pull request is already CLEAN,
|
|
10
|
-
* UNSTABLE or HAS_HOOKS it merges AT ONCE instead (cli/cli `pkg/cmd/pr/merge/merge.go`,
|
|
11
|
-
* `isImmediatelyMergeable`, read at v2.101.0 — the version the mini's job image ships).
|
|
12
|
-
* UNSTABLE is "mergeable, with a non-passing status", which is every pull request on a
|
|
13
|
-
* branch whose rules require no check: before `check` has run, and even after it failed.
|
|
14
|
-
* So the step reads the base branch's active rules first and refuses — a red check, never
|
|
15
|
-
* a merge — when none requires a status check. Measured 2026-09-22: homeflare-builds (its
|
|
16
|
-
* ruleset not deployed yet) and homeflare-desktop have none.
|
|
17
|
-
*
|
|
18
|
-
* ⛔ FIRST-PARTY ONLY: A `run:` STEP AND THE GitHub CLI, NO `uses:` AT ALL. GitHub's own
|
|
19
|
-
* example ("Automating Dependabot with GitHub Actions") identifies the update with
|
|
20
|
-
* `dependabot/fetch-metadata`, which the same page marks as "not certified by GitHub".
|
|
21
|
-
* The group is identified by the branch Dependabot gives it instead, whose format is
|
|
22
|
-
* dependabot-core's (`branch_namer/dependency_group_strategy.rb`, read at v0.397.0):
|
|
23
|
-
* `<prefix>/<package manager>/<directory>/<group>-<10 hex MD5 digest>`, with the root
|
|
24
|
-
* directory collapsing to nothing.
|
|
25
|
-
*/
|
|
26
|
-
import { HOMEFLARE_GROUP } from './dependabot.ts';
|
|
27
|
-
import type { RepoShape } from './shape.ts';
|
|
28
|
-
import { runsOn } from './shape.ts';
|
|
29
|
-
import { renderSteps } from './yaml.ts';
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* The branch prefix a job-level `if:` can test with `startsWith`. GitHub's expression
|
|
33
|
-
* language has no regex, so this is the cheap filter that keeps every other pull request
|
|
34
|
-
* from taking a runner slot; `GROUP_BRANCH` is the exact test inside the step.
|
|
35
|
-
*/
|
|
36
|
-
export const GROUP_BRANCH_PREFIX: string = `dependabot/bun/${HOMEFLARE_GROUP}-`;
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* ⛔ EXACT, AND FAILS CLOSED. A solo update of `@homeflare/config` is
|
|
40
|
-
* `dependabot/bun/homeflare/config-0.9.0` and a package named `homeflare-x` would be
|
|
41
|
-
* `dependabot/bun/homeflare-x-1.2.3`; neither matches. If Dependabot ever changes its
|
|
42
|
-
* format, the symptom is a bump that waits for a person — never one merged by mistake.
|
|
43
|
-
*/
|
|
44
|
-
export const GROUP_BRANCH: string = `^${GROUP_BRANCH_PREFIX}[0-9a-f]{10}$`;
|
|
45
|
-
|
|
46
|
-
const HEADER = `# Arms auto-merge on Dependabot's @homeflare/* group, and on nothing else.
|
|
47
|
-
#
|
|
48
|
-
# 🤖 RENDERED BY @homeflare/config — DO NOT EDIT THIS FILE BY HAND.
|
|
49
|
-
# Its input is this repository's \`repo-shape.ts\`; refresh with \`bun run repo-shape:refresh\`.
|
|
50
|
-
#
|
|
51
|
-
# ★ HOW A KIT RELEASE ARRIVES: the \`${HOMEFLARE_GROUP}\` group in .github/dependabot.yml opens one
|
|
52
|
-
# pull request; this arms GitHub's auto-merge on it; the ruleset's required checks decide.
|
|
53
|
-
# Nothing here merges anything itself, and merging deploys nothing.
|
|
54
|
-
# ⛔ NO THIRD-PARTY ACTION. GitHub's own example uses dependabot/fetch-metadata, which its
|
|
55
|
-
# docs mark "not certified by GitHub"; the group is recognised by its branch name instead.
|
|
56
|
-
# ⛔ NO REQUIRED CHECK ON THE BASE BRANCH, NO ARMING: there \`gh pr merge --auto\` would merge
|
|
57
|
-
# at once, unchecked. The job fails instead, so the pull request waits for a person.
|
|
58
|
-
# ⚠️ A RENDERER CHANGE STILL NEEDS A PERSON. When a kit release changes what @homeflare/config
|
|
59
|
-
# renders, the bump fails \`check\` (the drift test) and never goes green. Run
|
|
60
|
-
# \`bun run repo-shape:refresh\` on Dependabot's branch and push. ⛔ This workflow does not do
|
|
61
|
-
# it for you: a push made with GITHUB_TOKEN starts no workflow run, so a refreshed commit
|
|
62
|
-
# would never get the required checks and the pull request would wait forever.
|
|
63
|
-
`;
|
|
64
|
-
|
|
65
|
-
const TRIGGER = `name: dependabot auto-merge
|
|
66
|
-
|
|
67
|
-
on:
|
|
68
|
-
pull_request:
|
|
69
|
-
|
|
70
|
-
# ⛔ NOTHING AT THE TOP; the one job asks for exactly what \`gh pr merge --auto\` needs.
|
|
71
|
-
permissions: {}
|
|
72
|
-
|
|
73
|
-
concurrency:
|
|
74
|
-
group: automerge-\${{ github.ref }}
|
|
75
|
-
cancel-in-progress: true
|
|
76
|
-
`;
|
|
77
|
-
|
|
78
|
-
const JOB_NOTE = ` # ⛔ BOTH LOGINS, NOT EITHER. \`user.login\` is who opened the pull request; \`github.actor\` is
|
|
79
|
-
# who started this run. A person pushing to Dependabot's branch changes the actor, so
|
|
80
|
-
# their commit never arms anything; only Dependabot's own rebases do.`;
|
|
81
|
-
|
|
82
|
-
const PERMISSIONS_NOTE = ` # ★ WHAT GitHub'S OWN EXAMPLE GRANTS FOR THIS STEP, AND NO MORE. A run Dependabot starts gets
|
|
83
|
-
# a read-only GITHUB_TOKEN unless the workflow raises it ("Troubleshooting Dependabot on
|
|
84
|
-
# GitHub Actions" → "Changing GITHUB_TOKEN permissions").`;
|
|
85
|
-
|
|
86
|
-
const ARM = `set -euo pipefail
|
|
87
|
-
if [[ ! "$HEAD_REF" =~ ${GROUP_BRANCH} ]]; then
|
|
88
|
-
echo "::notice::$HEAD_REF is not the ${HOMEFLARE_GROUP} group's branch; auto-merge not armed"
|
|
89
|
-
exit 0
|
|
90
|
-
fi
|
|
91
|
-
# ⛔ gh merges a CLEAN or UNSTABLE pull request at once rather than arming it. Only a branch
|
|
92
|
-
# rule that requires a status check keeps it BLOCKED until the checks have passed.
|
|
93
|
-
required=$(gh api "repos/$GITHUB_REPOSITORY/rules/branches/$BASE_REF" \\
|
|
94
|
-
--jq '[.[] | select(.type == "required_status_checks")] | length')
|
|
95
|
-
if [ "$required" = 0 ]; then
|
|
96
|
-
echo "::error::$BASE_REF requires no status check, so gh would merge at once; auto-merge not armed"
|
|
97
|
-
exit 1
|
|
98
|
-
fi
|
|
99
|
-
# ★ --squash: the house repositories allow squash merges only (declareRepoPolicy).
|
|
100
|
-
gh pr merge --auto --squash "$PR_URL"`;
|
|
101
|
-
|
|
102
|
-
/** The whole `dependabot-automerge.yml` for a shape. */
|
|
103
|
-
export function renderAutomerge(shape: RepoShape): string {
|
|
104
|
-
// ⚠️ GitHub ACTIONS EXPRESSIONS, NOT TEMPLATE LITERALS: the runner interpolates `${{ … }}`
|
|
105
|
-
// at job time, so they must reach the file verbatim (see security.ts for the same note).
|
|
106
|
-
// oxlint-disable-next-line no-template-curly-in-string
|
|
107
|
-
const headRef = '${{ github.head_ref }}';
|
|
108
|
-
// oxlint-disable-next-line no-template-curly-in-string
|
|
109
|
-
const baseRef = '${{ github.base_ref }}';
|
|
110
|
-
// oxlint-disable-next-line no-template-curly-in-string
|
|
111
|
-
const prUrl = '${{ github.event.pull_request.html_url }}';
|
|
112
|
-
// oxlint-disable-next-line no-template-curly-in-string
|
|
113
|
-
const token = '${{ secrets.GITHUB_TOKEN }}';
|
|
114
|
-
const condition = [
|
|
115
|
-
"github.event.pull_request.user.login == 'dependabot[bot]'",
|
|
116
|
-
"github.actor == 'dependabot[bot]'",
|
|
117
|
-
`startsWith(github.head_ref, '${GROUP_BRANCH_PREFIX}')`,
|
|
118
|
-
].join(' && ');
|
|
119
|
-
|
|
120
|
-
return `${HEADER}
|
|
121
|
-
${TRIGGER}
|
|
122
|
-
jobs:
|
|
123
|
-
${JOB_NOTE}
|
|
124
|
-
arm:
|
|
125
|
-
name: arm auto-merge
|
|
126
|
-
if: ${condition}
|
|
127
|
-
runs-on: ${runsOn(shape.runner)}
|
|
128
|
-
${PERMISSIONS_NOTE}
|
|
129
|
-
permissions:
|
|
130
|
-
contents: write
|
|
131
|
-
pull-requests: write
|
|
132
|
-
steps:
|
|
133
|
-
${renderSteps(
|
|
134
|
-
[
|
|
135
|
-
{
|
|
136
|
-
env: { BASE_REF: baseRef, GH_TOKEN: token, HEAD_REF: headRef, PR_URL: prUrl },
|
|
137
|
-
name: 'Arm auto-merge on the homeflare group',
|
|
138
|
-
run: ARM,
|
|
139
|
-
},
|
|
140
|
-
],
|
|
141
|
-
3,
|
|
142
|
-
)}
|
|
143
|
-
`;
|
|
144
|
-
}
|