1- /// @ts -check
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'
24
35// TODO: should this be combined with the branch checks in prepare.js?
46// They do seem quite similar, but this needs to run after eval,
@@ -9,39 +11,47 @@ const { readFile } = require('node:fs/promises')
911const { postReview, dismissReviews } = require ( './reviews.js' )
1012
1113const reviewKey = 'check-target-branch'
12- /**
13- * @param {{
14- * github: InstanceType<import('@actions /github/lib/utils').GitHub>,
15- * context: typeof import('@actions/github').context
16- * core: import('@actions/core')
17- * dry: boolean
18- * }} CheckTargetBranchProps
19- */
20- async function checkTargetBranch ( { github, context, core, dry } ) {
21- /**
22- * @type {{
23- * attrdiff: {
24- * added: string[],
25- * changed: string[],
26- * removed: string[],
27- * },
28- * attrdiffByKernel: Record<string, {
29- * added: string[],
30- * changed: string[],
31- * removed: string[],
32- * }>,
33- * attrdiffByPlatform: Record<string, {
34- * added: string[],
35- * changed: string[],
36- * removed: string[],
37- * }>,
38- * labels: Record<string, boolean>,
39- * rebuildCountByKernel: Record<string, number>,
40- * rebuildsByKernel: Record<string, string[]>,
41- * rebuildsByPlatform: Record<string, string[]>,
42- * }}
43- */
44- 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 (
4555 await readFile ( 'comparison/changed-paths.json' , 'utf-8' ) ,
4656 )
4757 const pull_number = context . payload . pull_request ?. number
@@ -155,7 +165,7 @@ async function checkTargetBranch({ github, context, core, dry }) {
155165 reviewKey,
156166 } )
157167 } else if ( rebuildsAllTests && ! isExemptKernelUpdate ) {
158- let branchText
168+ let branchText : string
159169 if ( base === 'master' && maxRebuildCount >= 500 ) {
160170 branchText = '(probably either `staging-nixos` or `staging`)'
161171 } else if ( base === 'master' ) {
0 commit comments