1+ import type * as actionsCore from '@actions/core'
2+ import type { context as actionsContext } from '@actions/github'
3+ import type { GitHub } from '@actions/github/lib/utils'
4+
15// TODO: should this be combined with the branch checks in prepare.js?
26// They do seem quite similar, but this needs to run after eval,
37// and prepare.js obviously doesn't.
@@ -7,39 +11,47 @@ const { readFile } = require('node:fs/promises')
711const { postReview, dismissReviews } = require ( './reviews.js' )
812
913const reviewKey = 'check-target-branch'
10- /**
11- * @param {{
12- * github: InstanceType<import('@actions /github/lib/utils').GitHub>,
13- * context: typeof import('@actions/github').context
14- * core: import('@actions/core')
15- * dry: boolean
16- * }} CheckTargetBranchProps
17- */
18- async function checkTargetBranch ( { github, context, core, dry } ) {
19- /**
20- * @type {{
21- * attrdiff: {
22- * added: string[],
23- * changed: string[],
24- * removed: string[],
25- * },
26- * attrdiffByKernel: Record<string, {
27- * added: string[],
28- * changed: string[],
29- * removed: string[],
30- * }>,
31- * attrdiffByPlatform: Record<string, {
32- * added: string[],
33- * changed: string[],
34- * removed: string[],
35- * }>,
36- * labels: Record<string, boolean>,
37- * rebuildCountByKernel: Record<string, number>,
38- * rebuildsByKernel: Record<string, string[]>,
39- * rebuildsByPlatform: Record<string, string[]>,
40- * }}
41- */
42- const changed = JSON . parse (
14+
15+ type ChangedPaths = {
16+ attrdiff : {
17+ added : string [ ]
18+ changed : string [ ]
19+ removed : string [ ]
20+ }
21+ attrdiffByKernel : Record <
22+ string ,
23+ {
24+ added : string [ ]
25+ changed : string [ ]
26+ removed : string [ ]
27+ }
28+ >
29+ attrdiffByPlatform : Record <
30+ string ,
31+ {
32+ added : string [ ]
33+ changed : string [ ]
34+ removed : string [ ]
35+ }
36+ >
37+ labels : Record < string , boolean >
38+ rebuildCountByKernel : Record < string , number >
39+ rebuildsByKernel : Record < string , string [ ] >
40+ rebuildsByPlatform : Record < string , string [ ] >
41+ }
42+
43+ async function checkTargetBranch ( {
44+ github,
45+ context,
46+ core,
47+ dry,
48+ } : {
49+ github : InstanceType < typeof GitHub >
50+ context : typeof actionsContext
51+ core : typeof actionsCore
52+ dry : boolean
53+ } ) {
54+ const changed : ChangedPaths = JSON . parse (
4355 await readFile ( 'comparison/changed-paths.json' , 'utf-8' ) ,
4456 )
4557 const pull_number = context . payload . pull_request ?. number
@@ -153,7 +165,7 @@ async function checkTargetBranch({ github, context, core, dry }) {
153165 reviewKey,
154166 } )
155167 } else if ( rebuildsAllTests && ! isExemptKernelUpdate ) {
156- let branchText
168+ let branchText : string
157169 if ( base === 'master' && maxRebuildCount >= 500 ) {
158170 branchText = '(probably either `staging-nixos` or `staging`)'
159171 } else if ( base === 'master' ) {
0 commit comments