-
Notifications
You must be signed in to change notification settings - Fork 2k
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 Actions for lint #3211
Merged
Merged
GitHub Actions for lint #3211
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: validate | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- 'master' | ||
- '[0-9]+.[0-9]{2}' | ||
tags: | ||
- 'v*' | ||
pull_request: | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
target: | ||
- lint | ||
- shellcheck | ||
steps: | ||
- | ||
name: Checkout | ||
uses: actions/checkout@v2 | ||
- | ||
name: Run | ||
uses: docker/bake-action@v1 | ||
with: | ||
targets: ${{ matrix.target }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,16 @@ | ||
# syntax=docker/dockerfile:1.3 | ||
|
||
ARG GO_VERSION=1.16.6 | ||
ARG GOLANGCI_LINTER_SHA="v1.21.0" | ||
ARG GOLANGCI_LINT_VERSION=v1.23.8 | ||
|
||
FROM golang:${GO_VERSION}-alpine AS build | ||
ENV CGO_ENABLED=0 | ||
RUN apk add --no-cache git | ||
ARG GOLANGCI_LINTER_SHA | ||
ARG GO111MODULE=on | ||
RUN --mount=type=cache,target=/root/.cache/go-build \ | ||
--mount=type=cache,target=/go/pkg/mod \ | ||
go get github.com/golangci/golangci-lint/cmd/golangci-lint@${GOLANGCI_LINTER_SHA} | ||
FROM golangci/golangci-lint:${GOLANGCI_LINT_VERSION}-alpine AS golangci-lint | ||
|
||
FROM golang:${GO_VERSION}-alpine AS lint | ||
ENV GO111MODULE=off | ||
ENV CGO_ENABLED=0 | ||
ENV DISABLE_WARN_OUTSIDE_CONTAINER=1 | ||
COPY --from=build /go/bin/golangci-lint /usr/local/bin | ||
FROM golang:${GO_VERSION}-alpine AS lint | ||
ENV GO111MODULE=off | ||
ENV CGO_ENABLED=0 | ||
ENV GOGC=75 | ||
WORKDIR /go/src/github.com/docker/cli | ||
ENV GOGC=75 | ||
ENTRYPOINT ["/usr/local/bin/golangci-lint"] | ||
CMD ["run", "--config=.golangci.yml"] | ||
COPY . . | ||
COPY --from=golangci-lint /usr/bin/golangci-lint /usr/bin/golangci-lint | ||
RUN --mount=type=bind,target=. \ | ||
--mount=type=cache,target=/root/.cache \ | ||
golangci-lint run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
FROM koalaman/shellcheck-alpine:v0.7.1 | ||
RUN apk add --no-cache bash make | ||
# syntax=docker/dockerfile:1.3 | ||
|
||
FROM koalaman/shellcheck-alpine:v0.7.1 AS shellcheck | ||
WORKDIR /go/src/github.com/docker/cli | ||
ENV DISABLE_WARN_OUTSIDE_CONTAINER=1 | ||
COPY . . | ||
RUN --mount=type=bind,target=. \ | ||
crazy-max marked this conversation as resolved.
Show resolved
Hide resolved
|
||
set -eo pipefail; \ | ||
find scripts/ contrib/completion/bash -type f | grep -v scripts/winresources | grep -v '.*.ps1' | xargs shellcheck |
This file was deleted.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The official
golangci-lint
GitHub Action can also run on Windows, Darwin. Wondering if we can trick it by setting GOOS/GOARCH to also lint non-matching platforms (especially for the CLI, which will be extensively used on macOS and Windows)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.
Yes I think we can have a special matrix to run Windows and MacOS runners in this case. We can do that in follow-up.
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.
Yeah, it's tricky, because of course we can't run a macOS container, and Windows doesn't support BuildKit for Windows containers (if it would, it's still possible that building takes a long time (Moby Ci can take 10 minutes to build the Dockerfile, a large portion of that is taken by just pulling the base image 😞).
So if it's possible to somehow trick golangci-lint (through
GOOS
/GOARCH
) that would be a lot easier.If not, then perhaps (for CI) we would have to consider using the official golangci-lint GitHub action, which doesn't (I think?) run containerised, but at least runs fast (and on Windows and macOS). We can still use the BuildKit approach for local use (and for Linux perhaps).
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.
@thaJeztah
Yes I think we can do that with https://github.com/golangci/golangci-lint-action for Win/MacOS.