github(summary): build record upload optional
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
@@ -248,6 +248,52 @@ maybe('writeBuildSummary', () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('without build record', async () => {
|
||||||
|
const startedTime = new Date();
|
||||||
|
const buildx = new Buildx();
|
||||||
|
const build = new Build({buildx: buildx});
|
||||||
|
|
||||||
|
fs.mkdirSync(tmpDir, {recursive: true});
|
||||||
|
await expect(
|
||||||
|
(async () => {
|
||||||
|
// prettier-ignore
|
||||||
|
const buildCmd = await buildx.getCommand([
|
||||||
|
'--builder', process.env.CTN_BUILDER_NAME ?? 'default',
|
||||||
|
'build',
|
||||||
|
'-f', path.join(fixturesDir, 'hello.Dockerfile'),
|
||||||
|
fixturesDir,
|
||||||
|
'--metadata-file', build.getMetadataFilePath()
|
||||||
|
]);
|
||||||
|
await Exec.exec(buildCmd.command, buildCmd.args);
|
||||||
|
})()
|
||||||
|
).resolves.not.toThrow();
|
||||||
|
|
||||||
|
const refs = Buildx.refs({
|
||||||
|
dir: Buildx.refsDir,
|
||||||
|
builderName: process.env.CTN_BUILDER_NAME ?? 'default',
|
||||||
|
since: startedTime
|
||||||
|
});
|
||||||
|
expect(refs).toBeDefined();
|
||||||
|
expect(Object.keys(refs).length).toBeGreaterThan(0);
|
||||||
|
|
||||||
|
const history = new History({buildx: buildx});
|
||||||
|
const exportRes = await history.export({
|
||||||
|
refs: [Object.keys(refs)[0] ?? '']
|
||||||
|
});
|
||||||
|
expect(exportRes).toBeDefined();
|
||||||
|
expect(exportRes?.dockerbuildFilename).toBeDefined();
|
||||||
|
expect(exportRes?.dockerbuildSize).toBeDefined();
|
||||||
|
expect(exportRes?.summaries).toBeDefined();
|
||||||
|
|
||||||
|
await GitHub.writeBuildSummary({
|
||||||
|
exportRes: exportRes,
|
||||||
|
inputs: {
|
||||||
|
context: fixturesDir,
|
||||||
|
file: path.join(fixturesDir, 'hello.Dockerfile')
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
maybe('annotateBuildWarnings', () => {
|
maybe('annotateBuildWarnings', () => {
|
||||||
|
|||||||
@@ -226,6 +226,9 @@ export class GitHub {
|
|||||||
|
|
||||||
const refsSize = Object.keys(opts.exportRes.refs).length;
|
const refsSize = Object.keys(opts.exportRes.refs).length;
|
||||||
|
|
||||||
|
const sum = core.summary.addHeading('Docker Build summary', 2);
|
||||||
|
|
||||||
|
if (opts.uploadRes) {
|
||||||
// we just need the last two parts of the URL as they are always relative
|
// we just need the last two parts of the URL as they are always relative
|
||||||
// to the workflow run URL otherwise URL could be broken if GitHub
|
// to the workflow run URL otherwise URL could be broken if GitHub
|
||||||
// repository name is part of a secret value used in the workflow. e.g.:
|
// repository name is part of a secret value used in the workflow. e.g.:
|
||||||
@@ -235,9 +238,7 @@ export class GitHub {
|
|||||||
const artifactRelativeURL = `./${GitHub.runId}/${opts.uploadRes.url.split('/').slice(-2).join('/')}`;
|
const artifactRelativeURL = `./${GitHub.runId}/${opts.uploadRes.url.split('/').slice(-2).join('/')}`;
|
||||||
|
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
const sum = core.summary
|
sum.addRaw(`<p>`)
|
||||||
.addHeading('Docker Build summary', 2)
|
|
||||||
.addRaw(`<p>`)
|
|
||||||
.addRaw(`For a detailed look at the build, download the following build record archive and import it into Docker Desktop's Builds view. `)
|
.addRaw(`For a detailed look at the build, download the following build record archive and import it into Docker Desktop's Builds view. `)
|
||||||
.addBreak()
|
.addBreak()
|
||||||
.addRaw(`Build records include details such as timing, dependencies, results, logs, traces, and other information about a build. `)
|
.addRaw(`Build records include details such as timing, dependencies, results, logs, traces, and other information about a build. `)
|
||||||
@@ -245,11 +246,19 @@ export class GitHub {
|
|||||||
.addRaw('</p>')
|
.addRaw('</p>')
|
||||||
.addRaw(`<p>`)
|
.addRaw(`<p>`)
|
||||||
.addRaw(`:arrow_down: ${addLink(`<strong>${Util.stringToUnicodeEntities(opts.uploadRes.filename)}</strong>`, artifactRelativeURL)} (${Util.formatFileSize(opts.uploadRes.size)} - includes <strong>${refsSize} build record${refsSize > 1 ? 's' : ''}</strong>)`)
|
.addRaw(`:arrow_down: ${addLink(`<strong>${Util.stringToUnicodeEntities(opts.uploadRes.filename)}</strong>`, artifactRelativeURL)} (${Util.formatFileSize(opts.uploadRes.size)} - includes <strong>${refsSize} build record${refsSize > 1 ? 's' : ''}</strong>)`)
|
||||||
.addRaw(`</p>`)
|
.addRaw(`</p>`);
|
||||||
.addRaw(`<p>`)
|
} else {
|
||||||
.addRaw(`Find this useful? `)
|
// prettier-ignore
|
||||||
.addRaw(addLink('Let us know', 'https://docs.docker.com/feedback/gha-build-summary'))
|
sum.addRaw(`<p>`)
|
||||||
.addRaw('</p>');
|
.addRaw(`The following table provides a brief summary of your build.`)
|
||||||
|
.addBreak()
|
||||||
|
.addRaw(`For a detailed look at the build, including timing, dependencies, results, logs, traces, and other information, consider enabling the export of the build record so you can import it into Docker Desktop's Builds view. `)
|
||||||
|
.addRaw(addLink('Learn more', 'https://www.docker.com/blog/new-beta-feature-deep-dive-into-github-actions-docker-builds-with-docker-desktop/?utm_source=github&utm_medium=actions'))
|
||||||
|
.addRaw(`</p>`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Feedback survey
|
||||||
|
sum.addRaw(`<p>`).addRaw(`Find this useful? `).addRaw(addLink('Let us know', 'https://docs.docker.com/feedback/gha-build-summary')).addRaw('</p>');
|
||||||
|
|
||||||
// Preview
|
// Preview
|
||||||
sum.addRaw('<p>');
|
sum.addRaw('<p>');
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ export interface UploadArtifactResponse {
|
|||||||
|
|
||||||
export interface BuildSummaryOpts {
|
export interface BuildSummaryOpts {
|
||||||
exportRes: ExportRecordResponse;
|
exportRes: ExportRecordResponse;
|
||||||
uploadRes: UploadArtifactResponse;
|
uploadRes?: UploadArtifactResponse;
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
inputs?: any;
|
inputs?: any;
|
||||||
bakeDefinition?: BakeDefinition;
|
bakeDefinition?: BakeDefinition;
|
||||||
|
|||||||
Reference in New Issue
Block a user