forked from TrueCloudLab/distribution
ci: git validation target
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
parent
8b2c54bf57
commit
1a905ab966
4 changed files with 45 additions and 5 deletions
7
.github/workflows/validate.yml
vendored
7
.github/workflows/validate.yml
vendored
|
@ -8,8 +8,6 @@ on:
|
||||||
tags:
|
tags:
|
||||||
- 'v*'
|
- 'v*'
|
||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
|
||||||
- '*'
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
validate:
|
validate:
|
||||||
|
@ -20,11 +18,14 @@ jobs:
|
||||||
target:
|
target:
|
||||||
- lint
|
- lint
|
||||||
- validate-vendor
|
- validate-vendor
|
||||||
|
- validate-git
|
||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
-
|
-
|
||||||
name: Run
|
name: Run
|
||||||
run: |
|
run: |
|
||||||
make ${{ matrix.target }}
|
make ${{ matrix.target }}
|
||||||
|
env:
|
||||||
|
COMMIT_RANGE: ${{ format('{0}..{1}', github.sha, 'HEAD') }}
|
||||||
|
|
5
Makefile
5
Makefile
|
@ -38,7 +38,7 @@ BINARIES=$(addprefix bin/,$(COMMANDS))
|
||||||
TESTFLAGS ?= -v $(TESTFLAGS_RACE)
|
TESTFLAGS ?= -v $(TESTFLAGS_RACE)
|
||||||
TESTFLAGS_PARALLEL ?= 8
|
TESTFLAGS_PARALLEL ?= 8
|
||||||
|
|
||||||
.PHONY: all build binaries clean test test-race test-full integration coverage validate lint validate-vendor vendor mod-outdated
|
.PHONY: all build binaries clean test test-race test-full integration coverage validate lint validate-git validate-vendor vendor mod-outdated
|
||||||
.DEFAULT: all
|
.DEFAULT: all
|
||||||
|
|
||||||
all: binaries
|
all: binaries
|
||||||
|
@ -103,6 +103,9 @@ validate: ## run all validators
|
||||||
lint: ## run all linters
|
lint: ## run all linters
|
||||||
docker buildx bake $@
|
docker buildx bake $@
|
||||||
|
|
||||||
|
validate-git: ## validate git
|
||||||
|
docker buildx bake $@
|
||||||
|
|
||||||
validate-vendor: ## validate vendor
|
validate-vendor: ## validate vendor
|
||||||
docker buildx bake $@
|
docker buildx bake $@
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ group "default" {
|
||||||
}
|
}
|
||||||
|
|
||||||
group "validate" {
|
group "validate" {
|
||||||
targets = ["lint", "validate-vendor"]
|
targets = ["lint", "validate-git", "validate-vendor"]
|
||||||
}
|
}
|
||||||
|
|
||||||
target "lint" {
|
target "lint" {
|
||||||
|
@ -11,6 +11,19 @@ target "lint" {
|
||||||
output = ["type=cacheonly"]
|
output = ["type=cacheonly"]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
variable "COMMIT_RANGE" {
|
||||||
|
default = ""
|
||||||
|
}
|
||||||
|
target "validate-git" {
|
||||||
|
dockerfile = "./dockerfiles/git.Dockerfile"
|
||||||
|
target = "validate"
|
||||||
|
args = {
|
||||||
|
COMMIT_RANGE = COMMIT_RANGE
|
||||||
|
BUILDKIT_CONTEXT_KEEP_GIT_DIR = 1
|
||||||
|
}
|
||||||
|
output = ["type=cacheonly"]
|
||||||
|
}
|
||||||
|
|
||||||
target "validate-vendor" {
|
target "validate-vendor" {
|
||||||
dockerfile = "./dockerfiles/vendor.Dockerfile"
|
dockerfile = "./dockerfiles/vendor.Dockerfile"
|
||||||
target = "validate"
|
target = "validate"
|
||||||
|
|
23
dockerfiles/git.Dockerfile
Normal file
23
dockerfiles/git.Dockerfile
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
# syntax=docker/dockerfile:1
|
||||||
|
|
||||||
|
ARG GO_VERSION=1.18
|
||||||
|
ARG ALPINE_VERSION=3.16
|
||||||
|
|
||||||
|
FROM alpine:${ALPINE_VERSION} AS base
|
||||||
|
RUN apk add --no-cache git gpg
|
||||||
|
|
||||||
|
FROM golang:${GO_VERSION}-alpine${ALPINE_VERSION} AS gitvalidation
|
||||||
|
ARG GIT_VALIDATION_VERSION=v1.1.0
|
||||||
|
RUN --mount=type=cache,target=/root/.cache \
|
||||||
|
--mount=type=cache,target=/go/pkg/mod \
|
||||||
|
GOBIN=/out go install "github.com/vbatts/git-validation@${GIT_VALIDATION_VERSION}"
|
||||||
|
|
||||||
|
FROM base AS validate
|
||||||
|
ARG COMMIT_RANGE
|
||||||
|
RUN if [ -z "$COMMIT_RANGE" ]; then echo "COMMIT_RANGE required" && exit 1; fi
|
||||||
|
ENV GIT_CHECK_EXCLUDE="./vendor"
|
||||||
|
WORKDIR /src
|
||||||
|
RUN --mount=type=bind,target=. \
|
||||||
|
--mount=type=cache,target=/root/.cache \
|
||||||
|
--mount=from=gitvalidation,source=/out/git-validation,target=/usr/bin/git-validation \
|
||||||
|
git-validation -q -range "$COMMIT_RANGE" -run short-subject,dangling-whitespace
|
Loading…
Reference in a new issue