mirror of
https://github.com/gradle/actions.git
synced 2026-08-22 05:42:51 +00:00
Hide obsolete Job summaries (#902)
- Injects a `<!-- gradle-job-summary: ${jobCorrelator} -->` marker on
each job summary
- Lists 100 last comments: unfortunately there is no API to specifically
filter for comments, and checking the last 100 comments (the limit) is
usually enough and does not require iterating over pages
- Mutate comments having this expected marker
I tried to add some tests, but I'm not familiar enough to setup a
complete test suite with proper mocking of GitHub/Octokit with jest.
I could potentially extract the `prComment` creation to check for the
marker presence, let me know.
Note: it seems like there is currently an issue on mutating comments as
`OUTDATED` through graphql. Although it does not work as expected
(flagging as OUTDATED) the comments are still minimized, which is what
we want.
- https://github.com/orgs/community/discussions/19865
Implements #176
---------
Co-authored-by: Daz DeBoer <daz@gradle.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Daz DeBoer
Claude Opus 4.8
parent
a740661292
commit
318eed7038
@@ -1,8 +1,15 @@
|
||||
import dedent from 'dedent'
|
||||
import {describe, expect, it} from '@jest/globals'
|
||||
import * as github from '@actions/github'
|
||||
import {afterEach, describe, expect, it} from '@jest/globals'
|
||||
|
||||
import {BuildResult} from '../../src/build-results'
|
||||
import {renderSummaryTable} from '../../src/job-summary'
|
||||
import {jobMarker, renderSummaryTable} from '../../src/job-summary'
|
||||
|
||||
const MATRIX_INPUT_ENV = 'INPUT_WORKFLOW-JOB-CONTEXT'
|
||||
|
||||
function fakeContext(workflow: string, job: string): typeof github.context {
|
||||
return {workflow, job} as unknown as typeof github.context
|
||||
}
|
||||
|
||||
const successfulHelpBuild: BuildResult = {
|
||||
rootProjectName: 'root',
|
||||
@@ -177,3 +184,27 @@ describe('renderSummaryTable', () => {
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('jobMarker', () => {
|
||||
const original = process.env[MATRIX_INPUT_ENV]
|
||||
|
||||
afterEach(() => {
|
||||
if (original === undefined) {
|
||||
delete process.env[MATRIX_INPUT_ENV]
|
||||
} else {
|
||||
process.env[MATRIX_INPUT_ENV] = original
|
||||
}
|
||||
})
|
||||
|
||||
it('builds a hidden marker from the workflow and job', () => {
|
||||
process.env[MATRIX_INPUT_ENV] = 'null'
|
||||
const marker = jobMarker(fakeContext('CI', 'build'))
|
||||
expect(marker).toBe('<!-- gradle-job-summary: ci-build -->')
|
||||
})
|
||||
|
||||
it('includes the job matrix in the marker', () => {
|
||||
process.env[MATRIX_INPUT_ENV] = JSON.stringify({os: 'ubuntu', java: '17'})
|
||||
const marker = jobMarker(fakeContext('CI', 'build'))
|
||||
expect(marker).toBe('<!-- gradle-job-summary: ci-build-ubuntu-17 -->')
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user