-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
github: annotate build warnings #365
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# syntax=docker/dockerfile-upstream:master | ||
|
||
# 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 as base | ||
Check warning on line 17 in __tests__/fixtures/lint.Dockerfile GitHub Actions / test-itg (github.test.itg.ts, ubuntu-latest)All commands within the Dockerfile should use the same casing (either upper or lower)
Check warning on line 17 in __tests__/fixtures/lint.Dockerfile GitHub Actions / test-itg (github.test.itg.ts, ubuntu-latest)All commands within the Dockerfile should use the same casing (either upper or lower)
|
||
cOpy lint.Dockerfile . | ||
Check warning on line 18 in __tests__/fixtures/lint.Dockerfile GitHub Actions / test-itg (github.test.itg.ts, ubuntu-latest)All commands within the Dockerfile should use the same casing (either upper or lower)
Check warning on line 18 in __tests__/fixtures/lint.Dockerfile GitHub Actions / test-itg (github.test.itg.ts, ubuntu-latest)All commands within the Dockerfile should use the same casing (either upper or lower)
|
||
|
||
from scratch | ||
Check warning on line 20 in __tests__/fixtures/lint.Dockerfile GitHub Actions / test-itg (github.test.itg.ts, ubuntu-latest)All commands within the Dockerfile should use the same casing (either upper or lower)
Check warning on line 20 in __tests__/fixtures/lint.Dockerfile GitHub Actions / test-itg (github.test.itg.ts, ubuntu-latest)All commands within the Dockerfile should use the same casing (either upper or lower)
|
||
MAINTAINER [email protected] | ||
Check warning on line 21 in __tests__/fixtures/lint.Dockerfile GitHub Actions / test-itg (github.test.itg.ts, ubuntu-latest)The MAINTAINER instruction is deprecated, use a label instead to define an image author
Check warning on line 21 in __tests__/fixtures/lint.Dockerfile GitHub Actions / test-itg (github.test.itg.ts, ubuntu-latest)The MAINTAINER instruction is deprecated, use a label instead to define an image author
|
||
COPy --from=base \ | ||
Check warning on line 22 in __tests__/fixtures/lint.Dockerfile GitHub Actions / test-itg (github.test.itg.ts, ubuntu-latest)All commands within the Dockerfile should use the same casing (either upper or lower)
Check warning on line 22 in __tests__/fixtures/lint.Dockerfile GitHub Actions / test-itg (github.test.itg.ts, ubuntu-latest)All commands within the Dockerfile should use the same casing (either upper or lower)
|
||
/lint.Dockerfile \ | ||
/ | ||
|
||
CMD [ "echo", "Hello, Norway!" ] | ||
Check warning on line 26 in __tests__/fixtures/lint.Dockerfile GitHub Actions / test-itg (github.test.itg.ts, ubuntu-latest)Multiple instructions of the same type should not be used in the same stage
Check warning on line 26 in __tests__/fixtures/lint.Dockerfile GitHub Actions / test-itg (github.test.itg.ts, ubuntu-latest)Multiple instructions of the same type should not be used in the same stage
|
||
CMD [ "echo", "Hello, Sweden!" ] | ||
ENTRYPOINT my-program start | ||
Check warning on line 28 in __tests__/fixtures/lint.Dockerfile GitHub Actions / test-itg (github.test.itg.ts, ubuntu-latest)JSON arguments recommended for ENTRYPOINT/CMD to prevent unintended behavior related to OS signals
Check warning on line 28 in __tests__/fixtures/lint.Dockerfile GitHub Actions / test-itg (github.test.itg.ts, ubuntu-latest)JSON arguments recommended for ENTRYPOINT/CMD to prevent unintended behavior related to OS signals
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,6 +37,7 @@ import {jwtDecode, JwtPayload} from 'jwt-decode'; | |
|
||
import {Util} from './util'; | ||
|
||
import {VertexWarning} from './types/buildkit/client'; | ||
import {BuildSummaryOpts, GitHubActionsRuntimeToken, GitHubActionsRuntimeTokenAC, GitHubRepo, UploadArtifactOpts, UploadArtifactResponse} from './types/github'; | ||
|
||
export interface GitHubOpts { | ||
|
@@ -328,4 +329,39 @@ export class GitHub { | |
core.info(`Writing summary`); | ||
await sum.addSeparator().write(); | ||
} | ||
|
||
public static async annotateBuildWarnings(source: string, warnings?: Array<VertexWarning>): Promise<void> { | ||
(warnings ?? []).forEach(warning => { | ||
if (!warning.detail || !warning.short) { | ||
return; | ||
} | ||
const title = warning.detail.map(encoded => atob(encoded)).join(' '); | ||
let message = atob(warning.short).replace(/\s\(line \d+\)$/, ''); | ||
if (warning.url) { | ||
// https://github.com/docker/buildx/blob/d8c9ebde1fdcf659f1fa3efa6ccc27a28b0f1564/commands/build.go#L854 | ||
message += `\nMore info: ${warning.url}`; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wonder if this link can be made clickable by adding some markdown around it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Opened https://github.com/orgs/community/discussions/129897 And does not work with markdown 😞 https://github.com/orgs/community/discussions/129897#discussioncomment-9886696 |
||
} | ||
|
||
// GitHub annotations don't clearly show ranges of lines, so we'll just | ||
// show the first line | ||
const startLine = warning.range && warning.range.length > 0 ? warning.range[0]?.start.line : undefined; | ||
|
||
// TODO: When GitHub annotations support showing ranges properly, we can use this code | ||
// let startLine: number | undefined, endLine: number | undefined; | ||
// for (const range of warning.range ?? []) { | ||
// if (range.start.line && (!startLine || range.start.line < startLine)) { | ||
// startLine = range.start.line; | ||
// } | ||
// if (range.end.line && (!endLine || range.end.line > endLine)) { | ||
// endLine = range.end.line; | ||
// } | ||
// } | ||
|
||
core.warning(message, { | ||
title: title, | ||
file: source, | ||
startLine: startLine | ||
}); | ||
}); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
needs follow-up to bump to v0.16.0 when released