Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 3 additions & 1 deletion scripts/__tests__/actions/access-summary.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,9 @@ members:

const comment = describeAccessChangesComment(state, config)

assert.match(comment, /<summary>Access Changes<\/summary>/)
assert.match(comment, /The following access changes/)
assert.match(comment, /For the full access breakdown/)
assert.match(comment, /<details><summary>Access Changes<\/summary>/)
assert.doesNotMatch(comment, /Potential no members/)
assert.doesNotMatch(comment, /Any other members/)
})
Expand Down
15 changes: 8 additions & 7 deletions scripts/__tests__/workflows.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import assert from 'node:assert'
import {readFileSync} from 'node:fs'
import {existsSync, readFileSync} from 'node:fs'
import {describe, it} from 'node:test'
import * as YAML from 'yaml'

Expand Down Expand Up @@ -47,13 +47,14 @@ describe('workflows', () => {
assert.match(applyStep.run ?? '', /allow_destroy_override\.tf\.disabled/)
})

it('provides a manual access report workflow with summary and artifact output', () => {
const report = workflow('access-report.yml')
const steps = report.jobs.report.steps.map(step => step.name)
it('does not provide a manual access report workflow', () => {
assert.equal(existsSync('../.github/workflows/access-report.yml'), false)
})

it('publishes the full access report from the fix workflow', () => {
const fix = workflow('fix.yml')
const steps = fix.jobs.fix.steps.map(step => step.name)

assert.ok(report.on.workflow_dispatch)
assert.equal(report.jobs.report.environment, 'read')
assert.ok(steps.includes('Generate access report'))
assert.ok(steps.includes('Publish access report summary'))
assert.ok(steps.includes('Upload access report'))
})
Expand Down
15 changes: 8 additions & 7 deletions scripts/src/actions/shared/describe-access-changes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ export function describeAccessChangesComment(
runUrl = workflowRunUrl()
): string {
const accessChangesDescription = describeAccessChanges(state, config)
const reportDestination =
runUrl === undefined
? 'the Fix workflow summary or access report artifact'
: `[the Fix workflow summary or access report artifact](${runUrl})`
const comment = [
'The following access changes will be introduced as a result of applying the plan:',
'',
Expand All @@ -49,19 +53,16 @@ export function describeAccessChangesComment(
accessChangesDescription,
'```',
'',
'</details>'
'</details>',
'',
`For the full access breakdown, inspect ${reportDestination}.`
].join('\n')

if (Buffer.byteLength(comment, 'utf8') < maxLength) {
return comment
}

const destination =
runUrl === undefined
? 'the Fix workflow summary or the access report artifact'
: `[the Fix workflow summary or access report artifact](${runUrl})`

return `Access changes are too long to post as a comment. Please inspect ${destination} instead.`
return `Access changes are too long to post as a comment. Please inspect ${reportDestination} instead.`
}

export function describeAccessReport(state: State, config: Config): string {
Expand Down
Loading