Skip to content

Commit 8637908

Browse files
committed
Add switches to skip filing best-practice and experimental issues
1 parent 7a0716b commit 8637908

3 files changed

Lines changed: 47 additions & 1 deletion

File tree

.github/actions/file/action.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ inputs:
2424
description: "In the 'file' step, also open grouped issues which link to all issues with the same root cause"
2525
required: false
2626
default: "false"
27+
file_best_practice_issues:
28+
description: "File issues for best-practice findings (accessibility recommendations that are not hard WCAG failures). Disabling only suppresses new issues; existing ones are left untouched."
29+
required: false
30+
default: "true"
31+
file_experimental_issues:
32+
description: "File issues for experimental findings (checks that are not yet stable). Disabling only suppresses new issues; existing ones are left untouched."
33+
required: false
34+
default: "true"
2735

2836
outputs:
2937
filings_file:

.github/actions/file/src/index.ts

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ import {updateFilingsWithNewFindings} from './updateFilingsWithNewFindings.js'
1616
import {OctokitResponse} from '@octokit/types'
1717
const OctokitWithThrottling = Octokit.plugin(throttling)
1818

19+
// core.getBooleanInput throws when an input is missing, so default unset switches.
20+
function getBooleanInputWithDefault(name: string, defaultValue: boolean): boolean {
21+
const raw = core.getInput(name)
22+
if (!raw) return defaultValue
23+
return raw.toLowerCase() === 'true'
24+
}
25+
1926
export default async function () {
2027
core.info("Started 'file' action")
2128
const findingsFile = core.getInput('findings_file', {required: true})
@@ -29,12 +36,16 @@ export default async function () {
2936
? JSON.parse(fs.readFileSync(cachedFilingsFile, 'utf8'))
3037
: []
3138
const shouldOpenGroupedIssues = core.getBooleanInput('open_grouped_issues')
39+
const fileBestPracticeIssues = getBooleanInputWithDefault('file_best_practice_issues', true)
40+
const fileExperimentalIssues = getBooleanInputWithDefault('file_experimental_issues', true)
3241
core.debug(`Input: 'findings_file: ${findingsFile}'`)
3342
core.debug(`Input: 'repository: ${repoWithOwner}'`)
3443
core.debug(`Input: 'base_url: ${baseUrl ?? '(default)'}'`)
3544
core.debug(`Input: 'screenshot_repository: ${screenshotRepo}'`)
3645
core.debug(`Input: 'cached_filings_file: ${cachedFilingsFile}'`)
3746
core.debug(`Input: 'open_grouped_issues: ${shouldOpenGroupedIssues}'`)
47+
core.debug(`Input: 'file_best_practice_issues: ${fileBestPracticeIssues}'`)
48+
core.debug(`Input: 'file_experimental_issues: ${fileExperimentalIssues}'`)
3849

3950
const octokit = new OctokitWithThrottling({
4051
auth: token,
@@ -58,6 +69,10 @@ export default async function () {
5869
})
5970
const filings = updateFilingsWithNewFindings(cachedFilings, findings)
6071

72+
// Suppressed new filings are kept out of the cache so they aren't seen as
73+
// resolved (and auto-closed) on the next run.
74+
const suppressedFilings = new Set<Filing>()
75+
6176
// Track new issues for grouping
6277
const newIssuesByProblemShort: Record<string, FindingGroupIssue[]> = {}
6378
const trackingIssueUrls: Record<string, string> = {}
@@ -70,6 +85,18 @@ export default async function () {
7085
response = await closeIssue(octokit, new Issue(filing.issue))
7186
filing.issue.state = 'closed'
7287
} else if (isNewFiling(filing)) {
88+
// Category switches gate only NEW issues; existing ones are reconciled above.
89+
const category = filing.findings[0].category ?? 'wcag'
90+
if (
91+
(category === 'best-practice' && !fileBestPracticeIssues) ||
92+
(category === 'experimental' && !fileExperimentalIssues)
93+
) {
94+
core.info(
95+
`Skipping new ${category} issue (filing disabled for this category): ${filing.findings[0].problemShort}`,
96+
)
97+
suppressedFilings.add(filing)
98+
continue
99+
}
73100
// Open a new issue for the filing
74101
response = await openIssue(octokit, repoWithOwner, filing.findings[0], screenshotRepo)
75102
;(filing as Filing).issue = {state: 'open'} as Issue
@@ -139,7 +166,8 @@ export default async function () {
139166
}
140167

141168
const filingsPath = path.join(process.env.RUNNER_TEMP || '/tmp', `filings-${crypto.randomUUID()}.json`)
142-
fs.writeFileSync(filingsPath, JSON.stringify(filings))
169+
const outputFilings = suppressedFilings.size > 0 ? filings.filter(f => !suppressedFilings.has(f)) : filings
170+
fs.writeFileSync(filingsPath, JSON.stringify(outputFilings))
143171
core.setOutput('filings_file', filingsPath)
144172

145173
core.debug(`Output: 'filings_file: ${filingsPath}'`)

action.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,14 @@ inputs:
4545
description: "In the 'file' step, also open grouped issues which link to all issues with the same problem"
4646
required: false
4747
default: 'false'
48+
file_best_practice_issues:
49+
description: 'File issues for best-practice findings (accessibility recommendations that are not hard WCAG failures). Disabling suppresses new issues while existing ones are left untouched.'
50+
required: false
51+
default: 'true'
52+
file_experimental_issues:
53+
description: 'File issues for experimental findings (checks that are not yet stable). Disabling suppresses new issues while existing ones are left untouched.'
54+
required: false
55+
default: 'true'
4856
reduced_motion:
4957
description: 'Playwright reducedMotion setting: https://playwright.dev/docs/api/class-browser#browser-new-page-option-reduced-motion'
5058
required: false
@@ -129,6 +137,8 @@ runs:
129137
cached_filings_file: ${{ steps.normalize_cache.outputs.cached_filings_file }}
130138
screenshot_repository: ${{ github.repository }}
131139
open_grouped_issues: ${{ inputs.open_grouped_issues }}
140+
file_best_practice_issues: ${{ inputs.file_best_practice_issues }}
141+
file_experimental_issues: ${{ inputs.file_experimental_issues }}
132142
- if: ${{ steps.file.outputs.filings_file }}
133143
name: Get issues from filings
134144
id: get_issues_from_filings

0 commit comments

Comments
 (0)