Skip to content

Commit 2580dea

Browse files
committed
GitHub Actions for lint
Signed-off-by: CrazyMax <[email protected]>
1 parent 2776a6d commit 2580dea

File tree

7 files changed

+77
-40
lines changed

7 files changed

+77
-40
lines changed

.circleci/config.yml

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ jobs:
77
docker: [{image: 'docker:20.10-git'}]
88
environment:
99
DOCKER_BUILDKIT: 1
10+
BUILDX_VERSION: "v0.6.0"
11+
BUILDKIT_PROGRESS: "plain"
12+
DISABLE_WARN_OUTSIDE_CONTAINER: 1
1013
steps:
1114
- checkout
1215
- setup_remote_docker:
@@ -19,23 +22,19 @@ jobs:
1922
- run:
2023
name: "Docker info"
2124
command: docker info
22-
- run:
23-
name: "Shellcheck - build image"
24-
command: |
25-
docker build --progress=plain -f dockerfiles/Dockerfile.shellcheck --tag cli-validator:$CIRCLE_BUILD_NUM .
25+
- run: apk add make curl
26+
- run: mkdir -vp ~/.docker/cli-plugins/
27+
- run: curl -fsSL --output ~/.docker/cli-plugins/docker-buildx https://github.com/docker/buildx/releases/download/${BUILDX_VERSION}/buildx-${BUILDX_VERSION}.linux-amd64
28+
- run: chmod a+x ~/.docker/cli-plugins/docker-buildx
29+
- run: docker buildx version
2630
- run:
2731
name: "Shellcheck"
2832
command: |
29-
docker run --rm cli-validator:$CIRCLE_BUILD_NUM \
30-
make shellcheck
31-
- run:
32-
name: "Lint - build image"
33-
command: |
34-
docker build --progress=plain -f dockerfiles/Dockerfile.lint --tag cli-linter:$CIRCLE_BUILD_NUM .
33+
make shellcheck
3534
- run:
3635
name: "Lint"
3736
command: |
38-
docker run --rm cli-linter:$CIRCLE_BUILD_NUM
37+
make lint
3938
4039
cross:
4140
working_directory: /work

.github/workflows/validate.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: validate
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- 'master'
8+
tags:
9+
- 'v*'
10+
pull_request:
11+
branches:
12+
- 'master'
13+
14+
jobs:
15+
lint:
16+
runs-on: ubuntu-latest
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
target:
21+
- lint
22+
- shellcheck
23+
steps:
24+
-
25+
name: Checkout
26+
uses: actions/checkout@v2
27+
-
28+
name: Run
29+
uses: docker/bake-action@v1
30+
with:
31+
targets: ${{ matrix.target }}

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ fmt:
2727

2828
.PHONY: lint
2929
lint: ## run all the lint tools
30-
gometalinter --config gometalinter.json ./...
30+
docker buildx bake lint
3131

3232
.PHONY: binary
3333
binary:
@@ -73,7 +73,7 @@ yamldocs: ## generate documentation YAML files consumed by docs repo
7373

7474
.PHONY: shellcheck
7575
shellcheck: ## run shellcheck validation
76-
scripts/validate/shellcheck
76+
docker buildx bake shellcheck
7777

7878
.PHONY: help
7979
help: ## print this help

docker-bake.hcl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,15 @@ target "cross" {
6161
target "dynbinary-cross" {
6262
inherits = ["dynbinary", "_all_platforms"]
6363
}
64+
65+
target "lint" {
66+
dockerfile = "./dockerfiles/Dockerfile.lint"
67+
target = "lint"
68+
output = ["type=cacheonly"]
69+
}
70+
71+
target "shellcheck" {
72+
dockerfile = "./dockerfiles/Dockerfile.shellcheck"
73+
target = "shellcheck"
74+
output = ["type=cacheonly"]
75+
}

dockerfiles/Dockerfile.lint

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,18 @@
11
# syntax=docker/dockerfile:1.3
22

33
ARG GO_VERSION=1.13.15
4-
ARG GOLANGCI_LINTER_SHA="v1.21.0"
4+
ARG GOLANGCI_LINT_VERSION=v1.21.0
55

6-
FROM golang:${GO_VERSION}-alpine AS build
7-
ENV CGO_ENABLED=0
8-
RUN apk add --no-cache git
9-
ARG GOLANGCI_LINTER_SHA
10-
ARG GO111MODULE=on
11-
RUN --mount=type=cache,target=/root/.cache/go-build \
12-
--mount=type=cache,target=/go/pkg/mod \
13-
go get github.com/golangci/golangci-lint/cmd/golangci-lint@${GOLANGCI_LINTER_SHA}
14-
15-
FROM golang:${GO_VERSION}-alpine AS lint
16-
ENV CGO_ENABLED=0
17-
ENV DISABLE_WARN_OUTSIDE_CONTAINER=1
18-
COPY --from=build /go/bin/golangci-lint /usr/local/bin
6+
FROM golang:${GO_VERSION}-alpine AS base
197
WORKDIR /go/src/github.com/docker/cli
20-
ENV GOGC=75
21-
ENTRYPOINT ["/usr/local/bin/golangci-lint"]
22-
CMD ["run", "--config=.golangci.yml"]
23-
COPY . .
8+
9+
FROM golangci/golangci-lint:${GOLANGCI_LINT_VERSION}-alpine AS golangci-lint
10+
11+
FROM base AS lint
12+
ENV CGO_ENABLED=0
13+
ENV GOGC=75
14+
RUN --mount=type=bind,target=. \
15+
--mount=type=cache,target=/root/.cache/go-build \
16+
--mount=type=cache,target=/root/.cache/golangci-lint \
17+
--mount=from=golangci-lint,source=/usr/bin/golangci-lint,target=/usr/bin/golangci-lint \
18+
golangci-lint run --config .golangci.yml ./...

dockerfiles/Dockerfile.shellcheck

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
FROM koalaman/shellcheck-alpine:v0.7.1
2-
RUN apk add --no-cache bash make
1+
# syntax=docker/dockerfile:1.3
2+
3+
FROM koalaman/shellcheck-alpine:v0.7.1 AS base
4+
RUN apk add --no-cache bash
35
WORKDIR /go/src/github.com/docker/cli
4-
ENV DISABLE_WARN_OUTSIDE_CONTAINER=1
5-
COPY . .
6+
7+
FROM base AS shellcheck
8+
RUN --mount=type=bind,target=. \
9+
shellcheck contrib/completion/bash/docker \
10+
&& find scripts/ -type f | grep -v scripts/winresources | grep -v '.*.ps1' | xargs shellcheck

scripts/validate/shellcheck

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)