Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bbf0a8d268 | ||
|
|
4ce8a708c9 | ||
|
|
6f66565779 | ||
|
|
504af69bd9 | ||
|
|
f3734ee134 | ||
|
|
4183444df2 | ||
|
|
a5466523c1 | ||
|
|
e0007fb5cd | ||
|
|
c330895cef | ||
|
|
e7017a21b8 | ||
|
|
b56d9771d7 | ||
|
|
680ab5bdf1 | ||
|
|
5ea53e0090 |
41
.github/buildx-lab-releases.json
vendored
41
.github/buildx-lab-releases.json
vendored
@@ -40,6 +40,47 @@
|
|||||||
"https://github.com/docker/buildx-desktop/releases/download/v0.14.1-desktop.1/checksums.txt"
|
"https://github.com/docker/buildx-desktop/releases/download/v0.14.1-desktop.1/checksums.txt"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"v0.15.1-desktop.1": {
|
||||||
|
"id": 161492089,
|
||||||
|
"tag_name": "v0.15.1-desktop.1",
|
||||||
|
"html_url": "https://github.com/docker/buildx-desktop/releases/tag/v0.15.1-desktop.1",
|
||||||
|
"assets": [
|
||||||
|
"https://github.com/docker/buildx-desktop/releases/download/v0.15.1-desktop.1/buildx-v0.15.1-desktop.1.darwin-amd64",
|
||||||
|
"https://github.com/docker/buildx-desktop/releases/download/v0.15.1-desktop.1/buildx-v0.15.1-desktop.1.darwin-amd64.provenance.json",
|
||||||
|
"https://github.com/docker/buildx-desktop/releases/download/v0.15.1-desktop.1/buildx-v0.15.1-desktop.1.darwin-amd64.sbom.json",
|
||||||
|
"https://github.com/docker/buildx-desktop/releases/download/v0.15.1-desktop.1/buildx-v0.15.1-desktop.1.darwin-arm64",
|
||||||
|
"https://github.com/docker/buildx-desktop/releases/download/v0.15.1-desktop.1/buildx-v0.15.1-desktop.1.darwin-arm64.provenance.json",
|
||||||
|
"https://github.com/docker/buildx-desktop/releases/download/v0.15.1-desktop.1/buildx-v0.15.1-desktop.1.darwin-arm64.sbom.json",
|
||||||
|
"https://github.com/docker/buildx-desktop/releases/download/v0.15.1-desktop.1/buildx-v0.15.1-desktop.1.linux-amd64",
|
||||||
|
"https://github.com/docker/buildx-desktop/releases/download/v0.15.1-desktop.1/buildx-v0.15.1-desktop.1.linux-amd64.provenance.json",
|
||||||
|
"https://github.com/docker/buildx-desktop/releases/download/v0.15.1-desktop.1/buildx-v0.15.1-desktop.1.linux-amd64.sbom.json",
|
||||||
|
"https://github.com/docker/buildx-desktop/releases/download/v0.15.1-desktop.1/buildx-v0.15.1-desktop.1.linux-arm-v6",
|
||||||
|
"https://github.com/docker/buildx-desktop/releases/download/v0.15.1-desktop.1/buildx-v0.15.1-desktop.1.linux-arm-v6.provenance.json",
|
||||||
|
"https://github.com/docker/buildx-desktop/releases/download/v0.15.1-desktop.1/buildx-v0.15.1-desktop.1.linux-arm-v6.sbom.json",
|
||||||
|
"https://github.com/docker/buildx-desktop/releases/download/v0.15.1-desktop.1/buildx-v0.15.1-desktop.1.linux-arm-v7",
|
||||||
|
"https://github.com/docker/buildx-desktop/releases/download/v0.15.1-desktop.1/buildx-v0.15.1-desktop.1.linux-arm-v7.provenance.json",
|
||||||
|
"https://github.com/docker/buildx-desktop/releases/download/v0.15.1-desktop.1/buildx-v0.15.1-desktop.1.linux-arm-v7.sbom.json",
|
||||||
|
"https://github.com/docker/buildx-desktop/releases/download/v0.15.1-desktop.1/buildx-v0.15.1-desktop.1.linux-arm64",
|
||||||
|
"https://github.com/docker/buildx-desktop/releases/download/v0.15.1-desktop.1/buildx-v0.15.1-desktop.1.linux-arm64.provenance.json",
|
||||||
|
"https://github.com/docker/buildx-desktop/releases/download/v0.15.1-desktop.1/buildx-v0.15.1-desktop.1.linux-arm64.sbom.json",
|
||||||
|
"https://github.com/docker/buildx-desktop/releases/download/v0.15.1-desktop.1/buildx-v0.15.1-desktop.1.linux-ppc64le",
|
||||||
|
"https://github.com/docker/buildx-desktop/releases/download/v0.15.1-desktop.1/buildx-v0.15.1-desktop.1.linux-ppc64le.provenance.json",
|
||||||
|
"https://github.com/docker/buildx-desktop/releases/download/v0.15.1-desktop.1/buildx-v0.15.1-desktop.1.linux-ppc64le.sbom.json",
|
||||||
|
"https://github.com/docker/buildx-desktop/releases/download/v0.15.1-desktop.1/buildx-v0.15.1-desktop.1.linux-riscv64",
|
||||||
|
"https://github.com/docker/buildx-desktop/releases/download/v0.15.1-desktop.1/buildx-v0.15.1-desktop.1.linux-riscv64.provenance.json",
|
||||||
|
"https://github.com/docker/buildx-desktop/releases/download/v0.15.1-desktop.1/buildx-v0.15.1-desktop.1.linux-riscv64.sbom.json",
|
||||||
|
"https://github.com/docker/buildx-desktop/releases/download/v0.15.1-desktop.1/buildx-v0.15.1-desktop.1.linux-s390x",
|
||||||
|
"https://github.com/docker/buildx-desktop/releases/download/v0.15.1-desktop.1/buildx-v0.15.1-desktop.1.linux-s390x.provenance.json",
|
||||||
|
"https://github.com/docker/buildx-desktop/releases/download/v0.15.1-desktop.1/buildx-v0.15.1-desktop.1.linux-s390x.sbom.json",
|
||||||
|
"https://github.com/docker/buildx-desktop/releases/download/v0.15.1-desktop.1/buildx-v0.15.1-desktop.1.windows-amd64.exe",
|
||||||
|
"https://github.com/docker/buildx-desktop/releases/download/v0.15.1-desktop.1/buildx-v0.15.1-desktop.1.windows-amd64.provenance.json",
|
||||||
|
"https://github.com/docker/buildx-desktop/releases/download/v0.15.1-desktop.1/buildx-v0.15.1-desktop.1.windows-amd64.sbom.json",
|
||||||
|
"https://github.com/docker/buildx-desktop/releases/download/v0.15.1-desktop.1/buildx-v0.15.1-desktop.1.windows-arm64.exe",
|
||||||
|
"https://github.com/docker/buildx-desktop/releases/download/v0.15.1-desktop.1/buildx-v0.15.1-desktop.1.windows-arm64.provenance.json",
|
||||||
|
"https://github.com/docker/buildx-desktop/releases/download/v0.15.1-desktop.1/buildx-v0.15.1-desktop.1.windows-arm64.sbom.json",
|
||||||
|
"https://github.com/docker/buildx-desktop/releases/download/v0.15.1-desktop.1/checksums.txt"
|
||||||
|
]
|
||||||
|
},
|
||||||
"v0.15.0-desktop.1": {
|
"v0.15.0-desktop.1": {
|
||||||
"id": 160473592,
|
"id": 160473592,
|
||||||
"tag_name": "v0.15.0-desktop.1",
|
"tag_name": "v0.15.0-desktop.1",
|
||||||
|
|||||||
12
.github/docker-releases.json
vendored
12
.github/docker-releases.json
vendored
@@ -5,6 +5,18 @@
|
|||||||
"html_url": "https://github.com/moby/moby/releases/tag/v26.1.4",
|
"html_url": "https://github.com/moby/moby/releases/tag/v26.1.4",
|
||||||
"assets": []
|
"assets": []
|
||||||
},
|
},
|
||||||
|
"v27.0.1-rc.1": {
|
||||||
|
"id": 161457618,
|
||||||
|
"tag_name": "v27.0.1-rc.1",
|
||||||
|
"html_url": "https://github.com/moby/moby/releases/tag/v27.0.1-rc.1",
|
||||||
|
"assets": []
|
||||||
|
},
|
||||||
|
"v23.0.13": {
|
||||||
|
"id": 161533551,
|
||||||
|
"tag_name": "v23.0.13",
|
||||||
|
"html_url": "https://github.com/moby/moby/releases/tag/v23.0.13",
|
||||||
|
"assets": []
|
||||||
|
},
|
||||||
"v27.0.0-rc.2": {
|
"v27.0.0-rc.2": {
|
||||||
"id": 160534078,
|
"id": 160534078,
|
||||||
"tag_name": "v27.0.0-rc.2",
|
"tag_name": "v27.0.0-rc.2",
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ on:
|
|||||||
branches:
|
branches:
|
||||||
- 'main'
|
- 'main'
|
||||||
pull_request:
|
pull_request:
|
||||||
paths-ignore:
|
paths:
|
||||||
- '.github/*-releases.json'
|
- '.github/workflows/buildx-lab-releases-json.yml'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
generate:
|
generate:
|
||||||
|
|||||||
4
.github/workflows/buildx-releases-json.yml
vendored
4
.github/workflows/buildx-releases-json.yml
vendored
@@ -12,8 +12,8 @@ on:
|
|||||||
branches:
|
branches:
|
||||||
- 'main'
|
- 'main'
|
||||||
pull_request:
|
pull_request:
|
||||||
paths-ignore:
|
paths:
|
||||||
- '.github/*-releases.json'
|
- '.github/workflows/buildx-releases-json.yml'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
generate:
|
generate:
|
||||||
|
|||||||
4
.github/workflows/docker-releases-json.yml
vendored
4
.github/workflows/docker-releases-json.yml
vendored
@@ -12,8 +12,8 @@ on:
|
|||||||
branches:
|
branches:
|
||||||
- 'main'
|
- 'main'
|
||||||
pull_request:
|
pull_request:
|
||||||
paths-ignore:
|
paths:
|
||||||
- '.github/*-releases.json'
|
- '.github/workflows/docker-releases-json.yml'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
generate:
|
generate:
|
||||||
|
|||||||
19
__tests__/fixtures/hello-err.Dockerfile
Normal file
19
__tests__/fixtures/hello-err.Dockerfile
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
# syntax=docker/dockerfile:1
|
||||||
|
|
||||||
|
# Copyright 2024 actions-toolkit authors
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
FROM busybox:latest
|
||||||
|
ARGGG NAME=foo
|
||||||
|
RUN echo "hello $NAME"
|
||||||
@@ -118,29 +118,20 @@ maybe('writeBuildSummary', () => {
|
|||||||
test.each([
|
test.each([
|
||||||
[
|
[
|
||||||
'single',
|
'single',
|
||||||
[
|
path.join(fixturesDir, 'hello-bake.hcl'),
|
||||||
'bake',
|
'hello'
|
||||||
'-f', path.join(fixturesDir, 'hello-bake.hcl'),
|
|
||||||
'hello'
|
|
||||||
],
|
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'group',
|
'group',
|
||||||
[
|
path.join(fixturesDir, 'hello-bake.hcl'),
|
||||||
'bake',
|
'hello-all'
|
||||||
'-f', path.join(fixturesDir, 'hello-bake.hcl'),
|
|
||||||
'hello-all'
|
|
||||||
],
|
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'matrix',
|
'matrix',
|
||||||
[
|
path.join(fixturesDir, 'hello-bake.hcl'),
|
||||||
'bake',
|
'hello-matrix'
|
||||||
'-f', path.join(fixturesDir, 'hello-bake.hcl'),
|
|
||||||
'hello-matrix'
|
|
||||||
],
|
|
||||||
]
|
]
|
||||||
])('write bake summary %p', async (_, bargs) => {
|
])('write bake summary %p', async (_, file, target) => {
|
||||||
const buildx = new Buildx();
|
const buildx = new Buildx();
|
||||||
const bake = new Bake({buildx: buildx});
|
const bake = new Bake({buildx: buildx});
|
||||||
|
|
||||||
@@ -150,7 +141,9 @@ maybe('writeBuildSummary', () => {
|
|||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
const buildCmd = await buildx.getCommand([
|
const buildCmd = await buildx.getCommand([
|
||||||
'--builder', process.env.CTN_BUILDER_NAME ?? 'default',
|
'--builder', process.env.CTN_BUILDER_NAME ?? 'default',
|
||||||
...bargs,
|
'bake',
|
||||||
|
'-f', file,
|
||||||
|
target,
|
||||||
'--metadata-file', bake.getMetadataFilePath()
|
'--metadata-file', bake.getMetadataFilePath()
|
||||||
]);
|
]);
|
||||||
await Exec.exec(buildCmd.command, buildCmd.args, {
|
await Exec.exec(buildCmd.command, buildCmd.args, {
|
||||||
@@ -159,6 +152,16 @@ maybe('writeBuildSummary', () => {
|
|||||||
})()
|
})()
|
||||||
).resolves.not.toThrow();
|
).resolves.not.toThrow();
|
||||||
|
|
||||||
|
const definition = await bake.getDefinition(
|
||||||
|
{
|
||||||
|
files: [file],
|
||||||
|
targets: [target],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
cwd: fixturesDir
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
const metadata = bake.resolveMetadata();
|
const metadata = bake.resolveMetadata();
|
||||||
expect(metadata).toBeDefined();
|
expect(metadata).toBeDefined();
|
||||||
const buildRefs = bake.resolveRefs(metadata);
|
const buildRefs = bake.resolveRefs(metadata);
|
||||||
@@ -186,6 +189,62 @@ maybe('writeBuildSummary', () => {
|
|||||||
uploadRes: uploadRes,
|
uploadRes: uploadRes,
|
||||||
inputs: {
|
inputs: {
|
||||||
files: path.join(fixturesDir, 'hello-bake.hcl')
|
files: path.join(fixturesDir, 'hello-bake.hcl')
|
||||||
|
},
|
||||||
|
bakeDefinition: definition
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('fails with dockerfile syntax issue', 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-err.Dockerfile'),
|
||||||
|
fixturesDir,
|
||||||
|
'--metadata-file', build.getMetadataFilePath()
|
||||||
|
]);
|
||||||
|
await Exec.exec(buildCmd.command, buildCmd.args);
|
||||||
|
})()
|
||||||
|
).rejects.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();
|
||||||
|
|
||||||
|
const uploadRes = await GitHub.uploadArtifact({
|
||||||
|
filename: exportRes?.dockerbuildFilename,
|
||||||
|
mimeType: 'application/gzip',
|
||||||
|
retentionDays: 1
|
||||||
|
});
|
||||||
|
expect(uploadRes).toBeDefined();
|
||||||
|
expect(uploadRes?.url).toBeDefined();
|
||||||
|
|
||||||
|
await GitHub.writeBuildSummary({
|
||||||
|
exportRes: exportRes,
|
||||||
|
uploadRes: uploadRes,
|
||||||
|
inputs: {
|
||||||
|
context: fixturesDir,
|
||||||
|
file: path.join(fixturesDir, 'hello-err.Dockerfile')
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -380,6 +380,42 @@ describe('stringToUnicodeEntities', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('countLines', () => {
|
||||||
|
it('counts total number of lines correctly', () => {
|
||||||
|
const text = `This
|
||||||
|
|
||||||
|
is
|
||||||
|
a
|
||||||
|
sample
|
||||||
|
|
||||||
|
text
|
||||||
|
with
|
||||||
|
multiple
|
||||||
|
lines`;
|
||||||
|
|
||||||
|
const result = Util.countLines(text);
|
||||||
|
expect(result).toEqual(10); // Including empty lines
|
||||||
|
});
|
||||||
|
it('handles edge case with empty string', () => {
|
||||||
|
const text = '';
|
||||||
|
|
||||||
|
const result = Util.countLines(text);
|
||||||
|
expect(result).toEqual(1); // Empty string should have 1 line
|
||||||
|
});
|
||||||
|
it('handles edge case with single line', () => {
|
||||||
|
const text = 'Single line text';
|
||||||
|
|
||||||
|
const result = Util.countLines(text);
|
||||||
|
expect(result).toEqual(1); // Single line should have 1 line
|
||||||
|
});
|
||||||
|
it('handles multiple types of line breaks', () => {
|
||||||
|
const text = `Line 1\r\nLine 2\rLine 3\nLine 4`;
|
||||||
|
|
||||||
|
const result = Util.countLines(text);
|
||||||
|
expect(result).toEqual(4); // Different line break types should be counted correctly
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// See: https://github.com/actions/toolkit/blob/a1b068ec31a042ff1e10a522d8fdf0b8869d53ca/packages/core/src/core.ts#L89
|
// See: https://github.com/actions/toolkit/blob/a1b068ec31a042ff1e10a522d8fdf0b8869d53ca/packages/core/src/core.ts#L89
|
||||||
function getInputName(name: string): string {
|
function getInputName(name: string): string {
|
||||||
return `INPUT_${name.replace(/ /g, '_').toUpperCase()}`;
|
return `INPUT_${name.replace(/ /g, '_').toUpperCase()}`;
|
||||||
|
|||||||
@@ -60,6 +60,7 @@
|
|||||||
"csv-parse": "^5.5.6",
|
"csv-parse": "^5.5.6",
|
||||||
"gunzip-maybe": "^1.4.2",
|
"gunzip-maybe": "^1.4.2",
|
||||||
"handlebars": "^4.7.8",
|
"handlebars": "^4.7.8",
|
||||||
|
"he": "^1.2.0",
|
||||||
"js-yaml": "^4.1.0",
|
"js-yaml": "^4.1.0",
|
||||||
"jwt-decode": "^4.0.0",
|
"jwt-decode": "^4.0.0",
|
||||||
"semver": "^7.6.2",
|
"semver": "^7.6.2",
|
||||||
@@ -69,6 +70,7 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/csv-parse": "^1.2.2",
|
"@types/csv-parse": "^1.2.2",
|
||||||
"@types/gunzip-maybe": "^1.4.2",
|
"@types/gunzip-maybe": "^1.4.2",
|
||||||
|
"@types/he": "^1.2.3",
|
||||||
"@types/js-yaml": "^4.0.9",
|
"@types/js-yaml": "^4.0.9",
|
||||||
"@types/node": "^20.12.10",
|
"@types/node": "^20.12.10",
|
||||||
"@types/semver": "^7.5.8",
|
"@types/semver": "^7.5.8",
|
||||||
|
|||||||
@@ -16,11 +16,13 @@
|
|||||||
|
|
||||||
import crypto from 'crypto';
|
import crypto from 'crypto';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
|
import he from 'he';
|
||||||
import jsyaml from 'js-yaml';
|
import jsyaml from 'js-yaml';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import {CreateArtifactRequest, FinalizeArtifactRequest, StringValue} from '@actions/artifact/lib/generated';
|
import {CreateArtifactRequest, FinalizeArtifactRequest, StringValue} from '@actions/artifact/lib/generated';
|
||||||
import {internalArtifactTwirpClient} from '@actions/artifact/lib/internal/shared/artifact-twirp-client';
|
import {internalArtifactTwirpClient} from '@actions/artifact/lib/internal/shared/artifact-twirp-client';
|
||||||
|
import {isGhes} from '@actions/artifact/lib/internal/shared/config';
|
||||||
import {getBackendIdsFromToken} from '@actions/artifact/lib/internal/shared/util';
|
import {getBackendIdsFromToken} from '@actions/artifact/lib/internal/shared/util';
|
||||||
import {getExpiration} from '@actions/artifact/lib/internal/upload/retention';
|
import {getExpiration} from '@actions/artifact/lib/internal/upload/retention';
|
||||||
import {InvalidResponseError, NetworkError} from '@actions/artifact';
|
import {InvalidResponseError, NetworkError} from '@actions/artifact';
|
||||||
@@ -121,6 +123,10 @@ export class GitHub {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static async uploadArtifact(opts: UploadArtifactOpts): Promise<UploadArtifactResponse> {
|
public static async uploadArtifact(opts: UploadArtifactOpts): Promise<UploadArtifactResponse> {
|
||||||
|
if (isGhes()) {
|
||||||
|
throw new Error('@actions/artifact v2.0.0+ is currently not supported on GHES.');
|
||||||
|
}
|
||||||
|
|
||||||
const artifactName = path.basename(opts.filename);
|
const artifactName = path.basename(opts.filename);
|
||||||
const backendIds = getBackendIdsFromToken();
|
const backendIds = getBackendIdsFromToken();
|
||||||
const artifactClient = internalArtifactTwirpClient();
|
const artifactClient = internalArtifactTwirpClient();
|
||||||
@@ -229,7 +235,7 @@ export class GitHub {
|
|||||||
|
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
const sum = core.summary
|
const sum = core.summary
|
||||||
.addHeading('Docker Build summary', 1)
|
.addHeading('Docker Build summary', 2)
|
||||||
.addRaw(`<p>`)
|
.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()
|
||||||
@@ -246,8 +252,8 @@ export class GitHub {
|
|||||||
.addRaw(addLink('Let us know', 'https://docs.docker.com/feedback/gha-build-summary'))
|
.addRaw(addLink('Let us know', 'https://docs.docker.com/feedback/gha-build-summary'))
|
||||||
.addRaw('</p>');
|
.addRaw('</p>');
|
||||||
|
|
||||||
sum.addHeading('Preview', 2);
|
// Preview
|
||||||
|
sum.addRaw(`<strong>Preview</strong>`).addBreak().addRaw('<p>');
|
||||||
const summaryTableData: Array<Array<SummaryTableCell>> = [
|
const summaryTableData: Array<Array<SummaryTableCell>> = [
|
||||||
[
|
[
|
||||||
{header: true, data: 'ID'},
|
{header: true, data: 'ID'},
|
||||||
@@ -257,7 +263,7 @@ export class GitHub {
|
|||||||
{header: true, data: 'Duration'}
|
{header: true, data: 'Duration'}
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
let summaryError: string | undefined;
|
let buildError: string | undefined;
|
||||||
for (const ref in opts.exportRes.summaries) {
|
for (const ref in opts.exportRes.summaries) {
|
||||||
if (Object.prototype.hasOwnProperty.call(opts.exportRes.summaries, ref)) {
|
if (Object.prototype.hasOwnProperty.call(opts.exportRes.summaries, ref)) {
|
||||||
const summary = opts.exportRes.summaries[ref];
|
const summary = opts.exportRes.summaries[ref];
|
||||||
@@ -270,28 +276,53 @@ export class GitHub {
|
|||||||
{data: summary.duration}
|
{data: summary.duration}
|
||||||
]);
|
]);
|
||||||
if (summary.error) {
|
if (summary.error) {
|
||||||
summaryError = summary.error;
|
buildError = summary.error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sum.addTable([...summaryTableData]);
|
sum.addTable([...summaryTableData]);
|
||||||
if (summaryError) {
|
sum.addRaw(`</p>`);
|
||||||
sum.addHeading('Error', 4);
|
|
||||||
sum.addCodeBlock(summaryError, 'text');
|
// Build error
|
||||||
|
if (buildError) {
|
||||||
|
sum.addRaw(`<blockquote>`);
|
||||||
|
if (Util.countLines(buildError) > 10) {
|
||||||
|
// prettier-ignore
|
||||||
|
sum
|
||||||
|
.addRaw(`<details><summary><strong>Error</strong></summary>`)
|
||||||
|
.addCodeBlock(he.encode(buildError), 'text')
|
||||||
|
.addRaw(`</details>`);
|
||||||
|
} else {
|
||||||
|
// prettier-ignore
|
||||||
|
sum
|
||||||
|
.addRaw(`<strong>Error</strong>`)
|
||||||
|
.addBreak()
|
||||||
|
.addRaw(`<p>`)
|
||||||
|
.addCodeBlock(he.encode(buildError), 'text')
|
||||||
|
.addRaw(`</p>`);
|
||||||
|
}
|
||||||
|
sum.addRaw(`</blockquote>`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Build inputs
|
||||||
if (opts.inputs) {
|
if (opts.inputs) {
|
||||||
sum.addHeading('Build inputs', 2).addCodeBlock(
|
// prettier-ignore
|
||||||
jsyaml.dump(opts.inputs, {
|
sum.addRaw(`<details><summary><strong>Build inputs</strong></summary>`)
|
||||||
indent: 2,
|
.addCodeBlock(
|
||||||
lineWidth: -1
|
jsyaml.dump(opts.inputs, {
|
||||||
}),
|
indent: 2,
|
||||||
'yaml'
|
lineWidth: -1
|
||||||
);
|
}), 'yaml'
|
||||||
|
)
|
||||||
|
.addRaw(`</details>`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Bake definition
|
||||||
if (opts.bakeDefinition) {
|
if (opts.bakeDefinition) {
|
||||||
sum.addHeading('Bake definition', 2).addCodeBlock(JSON.stringify(opts.bakeDefinition, null, 2), 'json');
|
// prettier-ignore
|
||||||
|
sum.addRaw(`<details><summary><strong>Bake definition</strong></summary>`)
|
||||||
|
.addCodeBlock(JSON.stringify(opts.bakeDefinition, null, 2), 'json')
|
||||||
|
.addRaw(`</details>`);
|
||||||
}
|
}
|
||||||
|
|
||||||
core.info(`Writing summary`);
|
core.info(`Writing summary`);
|
||||||
|
|||||||
@@ -185,4 +185,8 @@ export class Util {
|
|||||||
.map(char => `&#x${char.charCodeAt(0).toString(16)};`)
|
.map(char => `&#x${char.charCodeAt(0).toString(16)};`)
|
||||||
.join('');
|
.join('');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static countLines(input: string): number {
|
||||||
|
return input.split(/\r\n|\r|\n/).length;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
18
yarn.lock
18
yarn.lock
@@ -1112,6 +1112,7 @@ __metadata:
|
|||||||
"@octokit/plugin-rest-endpoint-methods": ^10.4.0
|
"@octokit/plugin-rest-endpoint-methods": ^10.4.0
|
||||||
"@types/csv-parse": ^1.2.2
|
"@types/csv-parse": ^1.2.2
|
||||||
"@types/gunzip-maybe": ^1.4.2
|
"@types/gunzip-maybe": ^1.4.2
|
||||||
|
"@types/he": ^1.2.3
|
||||||
"@types/js-yaml": ^4.0.9
|
"@types/js-yaml": ^4.0.9
|
||||||
"@types/node": ^20.12.10
|
"@types/node": ^20.12.10
|
||||||
"@types/semver": ^7.5.8
|
"@types/semver": ^7.5.8
|
||||||
@@ -1129,6 +1130,7 @@ __metadata:
|
|||||||
eslint-plugin-prettier: ^5.1.3
|
eslint-plugin-prettier: ^5.1.3
|
||||||
gunzip-maybe: ^1.4.2
|
gunzip-maybe: ^1.4.2
|
||||||
handlebars: ^4.7.8
|
handlebars: ^4.7.8
|
||||||
|
he: ^1.2.0
|
||||||
jest: ^29.7.0
|
jest: ^29.7.0
|
||||||
js-yaml: ^4.1.0
|
js-yaml: ^4.1.0
|
||||||
jwt-decode: ^4.0.0
|
jwt-decode: ^4.0.0
|
||||||
@@ -2175,6 +2177,13 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
|
"@types/he@npm:^1.2.3":
|
||||||
|
version: 1.2.3
|
||||||
|
resolution: "@types/he@npm:1.2.3"
|
||||||
|
checksum: e77851c73dd7b9902d92fe0118a26246a7f3676a3a1c6eb1408305187ef73b57c22550b1435946b983267f961d935554d5d0e1b458416932552f31e763e1aa41
|
||||||
|
languageName: node
|
||||||
|
linkType: hard
|
||||||
|
|
||||||
"@types/istanbul-lib-coverage@npm:*, @types/istanbul-lib-coverage@npm:^2.0.0, @types/istanbul-lib-coverage@npm:^2.0.1":
|
"@types/istanbul-lib-coverage@npm:*, @types/istanbul-lib-coverage@npm:^2.0.0, @types/istanbul-lib-coverage@npm:^2.0.1":
|
||||||
version: 2.0.3
|
version: 2.0.3
|
||||||
resolution: "@types/istanbul-lib-coverage@npm:2.0.3"
|
resolution: "@types/istanbul-lib-coverage@npm:2.0.3"
|
||||||
@@ -4923,6 +4932,15 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
|
"he@npm:^1.2.0":
|
||||||
|
version: 1.2.0
|
||||||
|
resolution: "he@npm:1.2.0"
|
||||||
|
bin:
|
||||||
|
he: bin/he
|
||||||
|
checksum: 3d4d6babccccd79c5c5a3f929a68af33360d6445587d628087f39a965079d84f18ce9c3d3f917ee1e3978916fc833bb8b29377c3b403f919426f91bc6965e7a7
|
||||||
|
languageName: node
|
||||||
|
linkType: hard
|
||||||
|
|
||||||
"html-escaper@npm:^2.0.0":
|
"html-escaper@npm:^2.0.0":
|
||||||
version: 2.0.2
|
version: 2.0.2
|
||||||
resolution: "html-escaper@npm:2.0.2"
|
resolution: "html-escaper@npm:2.0.2"
|
||||||
|
|||||||
Reference in New Issue
Block a user