Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion .github/actions/file/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ description: "Files GitHub issues to track potential accessibility gaps."
inputs:
findings:
description: "List of potential accessibility gaps, as stringified JSON"
required: true
required: false
findings_file:
description: "Path to a JSON file containing findings (alternative to 'findings' for large datasets)"
required: false
repository:
description: "Repository (with owner) to file issues in"
required: true
Expand All @@ -14,6 +17,9 @@ inputs:
cached_filings:
description: "Cached filings from previous runs, as stringified JSON. Without this, duplicate issues may be filed."
required: false
cached_filings_file:
description: "Path to a JSON file containing cached filings (alternative to 'cached_filings' for large datasets)"
required: false
screenshot_repository:
description: "Repository (with owner) where screenshots are stored on the gh-cache branch. Defaults to the 'repository' input if not set. Required if issues are open in a different repo to construct proper screenshot URLs."
required: false
Expand All @@ -25,6 +31,8 @@ inputs:
outputs:
filings:
description: "List of issues filed (and their associated finding(s)), as stringified JSON"
filings_file:
description: "Path to a JSON file containing filings (use for large datasets to avoid output size limits)"

runs:
using: "node24"
Expand Down
19 changes: 15 additions & 4 deletions .github/actions/file/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import type {Finding, ResolvedFiling, RepeatedFiling, FindingGroupIssue, Filing, IssueResponse} from './types.d.js'
import fs from 'node:fs'
import path from 'node:path'
import process from 'node:process'
import * as core from '@actions/core'
import {Octokit} from '@octokit/core'
Expand All @@ -16,13 +18,17 @@ const OctokitWithThrottling = Octokit.plugin(throttling)

export default async function () {
core.info("Started 'file' action")
const findings: Finding[] = JSON.parse(core.getInput('findings', {required: true}))
const findingsFile = core.getInput('findings_file', {required: false})
const findings: Finding[] = findingsFile
? JSON.parse(fs.readFileSync(findingsFile, 'utf8'))
: JSON.parse(core.getInput('findings', {required: !findingsFile}))
const repoWithOwner = core.getInput('repository', {required: true})
const token = core.getInput('token', {required: true})
const screenshotRepo = core.getInput('screenshot_repository', {required: false}) || repoWithOwner
const cachedFilings: (ResolvedFiling | RepeatedFiling)[] = JSON.parse(
core.getInput('cached_filings', {required: false}) || '[]',
)
const cachedFilingsFile = core.getInput('cached_filings_file', {required: false})
const cachedFilings: (ResolvedFiling | RepeatedFiling)[] = cachedFilingsFile
? JSON.parse(fs.readFileSync(cachedFilingsFile, 'utf8'))
: JSON.parse(core.getInput('cached_filings', {required: false}) || '[]')
Comment thread
lindseywild marked this conversation as resolved.
Outdated
const shouldOpenGroupedIssues = core.getBooleanInput('open_grouped_issues')
core.debug(`Input: 'findings: ${JSON.stringify(findings)}'`)
core.debug(`Input: 'repository: ${repoWithOwner}'`)
Expand Down Expand Up @@ -132,6 +138,11 @@ export default async function () {
}

core.setOutput('filings', JSON.stringify(filings))

const filingsPath = path.join(process.env.RUNNER_TEMP || '/tmp', 'filings.json')
Comment thread
lindseywild marked this conversation as resolved.
Outdated
fs.writeFileSync(filingsPath, JSON.stringify(filings))
core.setOutput('filings_file', filingsPath)

core.debug(`Output: 'filings: ${JSON.stringify(filings)}'`)
core.info("Finished 'file' action")
}
2 changes: 2 additions & 0 deletions .github/actions/find/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ inputs:
outputs:
findings:
description: 'List of potential accessibility gaps, as stringified JSON'
findings_file:
description: 'Path to a JSON file containing findings (use for large datasets to avoid output size limits)'

runs:
using: 'node24'
Expand Down
7 changes: 7 additions & 0 deletions .github/actions/find/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import type {AuthContextInput, ColorSchemePreference, ReducedMotionPreference} from './types.js'
import fs from 'node:fs'
import path from 'node:path'
import * as core from '@actions/core'
import {AuthContext} from './AuthContext.js'
import {findForUrl} from './findForUrl.js'
Expand Down Expand Up @@ -45,6 +47,11 @@ export default async function () {
}

core.setOutput('findings', JSON.stringify(findings))

const findingsPath = path.join(process.env.RUNNER_TEMP || '/tmp', 'findings.json')
fs.writeFileSync(findingsPath, JSON.stringify(findings))
core.setOutput('findings_file', findingsPath)
Comment thread
lindseywild marked this conversation as resolved.
Outdated

core.debug(`Output: 'findings: ${JSON.stringify(findings)}'`)
core.info(`Found ${findings.length} findings in total`)
core.info("Finished 'find' action")
Expand Down
7 changes: 6 additions & 1 deletion .github/actions/fix/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ description: "Attempts to fix issues with Copilot."
inputs:
issues:
description: "List of issues to attempt to fix, as stringified JSON"
required: true
required: false
issues_file:
description: "Path to a JSON file containing issues (alternative to 'issues' for large datasets)"
required: false
repository:
description: "Repository (with owner) containing issues"
required: true
Expand All @@ -15,6 +18,8 @@ inputs:
outputs:
fixings:
description: "List of pull requests filed (and their associated issues), as stringified JSON"
fixings_file:
description: "Path to a JSON file containing fixings (use for large datasets to avoid output size limits)"

runs:
using: "node24"
Expand Down
12 changes: 11 additions & 1 deletion .github/actions/fix/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import type {Issue as IssueInput, Fixing} from './types.d.js'
import fs from 'node:fs'
import path from 'node:path'
import process from 'node:process'
import * as core from '@actions/core'
import {Octokit} from '@octokit/core'
Expand All @@ -11,7 +13,10 @@ const OctokitWithThrottling = Octokit.plugin(throttling)

export default async function () {
core.info("Started 'fix' action")
const issues: IssueInput[] = JSON.parse(core.getInput('issues', {required: true}) || '[]')
const issuesFile = core.getInput('issues_file', {required: false})
Comment thread
lindseywild marked this conversation as resolved.
Outdated
const issues: IssueInput[] = issuesFile
? JSON.parse(fs.readFileSync(issuesFile, 'utf8'))
: JSON.parse(core.getInput('issues', {required: !issuesFile}) || '[]')
const repoWithOwner = core.getInput('repository', {required: true})
const token = core.getInput('token', {required: true})
core.debug(`Input: 'issues: ${JSON.stringify(issues)}'`)
Expand Down Expand Up @@ -57,6 +62,11 @@ export default async function () {
}

core.setOutput('fixings', JSON.stringify(fixings))

const fixingsPath = path.join(process.env.RUNNER_TEMP || '/tmp', 'fixings.json')
fs.writeFileSync(fixingsPath, JSON.stringify(fixings))
core.setOutput('fixings_file', fixingsPath)
Comment thread
lindseywild marked this conversation as resolved.
Outdated

core.debug(`Output: 'fixings: ${JSON.stringify(fixings)}'`)
core.info("Finished 'fix' action")
}
39 changes: 17 additions & 22 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ runs:
# If cached data is a list of Finding objects, each with 'issueUrl' keys (i.e. v1),
# convert to a list of (partial) Result objects, each with 'findings' and 'issue' keys (i.e. v2).
# Otherwise, re-output as-is.
printf '%s' "value=$(printf '%s' '${{ steps.restore.outputs.value }}' | jq -c 'if (type == "array" and length > 0 and (.[0] | has("issueUrl"))) then map({findings: [del(.issueUrl)], issue: {url: .issueUrl}}) else . end' )" >> $GITHUB_OUTPUT
# Read directly from the cache file to avoid shell interpolation of large JSON.
jq -c 'if (type == "array" and length > 0 and (.[0] | has("issueUrl"))) then map({findings: [del(.issueUrl)], issue: {url: .issueUrl}}) else . end' "${{ inputs.cache_key }}" > "$RUNNER_TEMP/cached_filings.json"
echo "cached_filings_file=$RUNNER_TEMP/cached_filings.json" >> $GITHUB_OUTPUT
Comment thread
lindseywild marked this conversation as resolved.
- if: ${{ inputs.login_url && inputs.username && inputs.password && !inputs.auth_context }}
name: Authenticate
id: auth
Expand All @@ -113,49 +115,42 @@ runs:
id: file
uses: ./../../_actions/github/accessibility-scanner/current/.github/actions/file
with:
findings: ${{ steps.find.outputs.findings }}
findings_file: ${{ steps.find.outputs.findings_file }}
repository: ${{ inputs.repository }}
token: ${{ inputs.token }}
cached_filings: ${{ steps.normalize_cache.outputs.value }}
cached_filings_file: ${{ steps.normalize_cache.outputs.cached_filings_file }}
screenshot_repository: ${{ github.repository }}
open_grouped_issues: ${{ inputs.open_grouped_issues }}
- if: ${{ steps.file.outputs.filings }}
- if: ${{ steps.file.outputs.filings_file }}
name: Get issues from filings
id: get_issues_from_filings
shell: bash
run: |
# Extract open issues from Filing objects and output as a single-line JSON array
issues=$(jq -c '[.[] | select(.issue.state == "open") | .issue]' <<< '${{ steps.file.outputs.filings }}')
echo "issues=$issues" >> "$GITHUB_OUTPUT"
# Extract open issues from Filing objects and write to a file
jq -c '[.[] | select(.issue.state == "open") | .issue]' "${{ steps.file.outputs.filings_file }}" > "$RUNNER_TEMP/issues.json"
echo "issues_file=$RUNNER_TEMP/issues.json" >> "$GITHUB_OUTPUT"
Comment thread
lindseywild marked this conversation as resolved.
- if: ${{ inputs.skip_copilot_assignment != 'true' }}
name: Fix
id: fix
uses: ./../../_actions/github/accessibility-scanner/current/.github/actions/fix
with:
issues: ${{ steps.get_issues_from_filings.outputs.issues }}
issues_file: ${{ steps.get_issues_from_filings.outputs.issues_file }}
repository: ${{ inputs.repository }}
token: ${{ inputs.token }}
- name: Write filings and fixings to temp files

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even though we already had files being written to, these were happening after the find/file steps, so they couldn't have been used as inputs.

shell: bash
run: |
cat > "$RUNNER_TEMP/filings.json" << 'FILINGS_HEREDOC_DELIMITER'
${{ steps.file.outputs.filings || '[]' }}
FILINGS_HEREDOC_DELIMITER

cat > "$RUNNER_TEMP/fixings.json" << 'FIXINGS_HEREDOC_DELIMITER'
${{ steps.fix.outputs.fixings || '[]' }}
FIXINGS_HEREDOC_DELIMITER

- name: Set results output
id: results
shell: bash
env:
FILINGS_FILE: ${{ steps.file.outputs.filings_file || '' }}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question/nit, does this need the fallback for sure? I figure below if you get an undefined filename, we'll just end up creating an empty array

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope not needed, you're right! I removed it

FIXINGS_FILE: ${{ steps.fix.outputs.fixings_file || '' }}
run: |
node << 'NODE_SCRIPT'
const fs = require('fs');
const path = require('path');
const runnerTemp = process.env.RUNNER_TEMP;
const filings = JSON.parse(fs.readFileSync(path.join(runnerTemp, 'filings.json'), 'utf8')) || [];
const fixings = JSON.parse(fs.readFileSync(path.join(runnerTemp, 'fixings.json'), 'utf8')) || [];
const filingsFile = process.env.FILINGS_FILE;
const fixingsFile = process.env.FIXINGS_FILE;
const filings = filingsFile && fs.existsSync(filingsFile) ? JSON.parse(fs.readFileSync(filingsFile, 'utf8')) : [];
const fixings = fixingsFile && fs.existsSync(fixingsFile) ? JSON.parse(fs.readFileSync(fixingsFile, 'utf8')) : [];
const fixingsByIssueUrl = fixings.reduce((acc, fixing) => {
if (fixing.issue && fixing.issue.url) acc[fixing.issue.url] = fixing;
return acc;
Expand Down
Loading