forked from TrueCloudLab/distribution
Merge pull request #3644 from crazy-max/cleanup-ci
ci: cleanup ci workflow
This commit is contained in:
commit
df14ebe142
10 changed files with 118 additions and 114 deletions
29
.github/workflows/build.yml
vendored
29
.github/workflows/build.yml
vendored
|
@ -15,8 +15,37 @@ env:
|
|||
DOCKERHUB_SLUG: distribution/distribution
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
go:
|
||||
- 1.17
|
||||
- 1.18
|
||||
steps:
|
||||
-
|
||||
name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
-
|
||||
name: Set up Go
|
||||
uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: ${{ matrix.go }}
|
||||
-
|
||||
name: Test
|
||||
run: |
|
||||
make coverage
|
||||
-
|
||||
name: Codecov
|
||||
uses: codecov/codecov-action@v3
|
||||
with:
|
||||
directory: ./
|
||||
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
needs:
|
||||
- test
|
||||
steps:
|
||||
-
|
||||
name: Checkout
|
||||
|
|
56
.github/workflows/ci.yml
vendored
56
.github/workflows/ci.yml
vendored
|
@ -1,56 +0,0 @@
|
|||
name: CI
|
||||
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
|
||||
build:
|
||||
strategy:
|
||||
matrix:
|
||||
go-version: ["1.17.x", "1.18.x"]
|
||||
platform: ["ubuntu-latest"]
|
||||
runs-on: ${{ matrix.platform }}
|
||||
env:
|
||||
DOCKER_BUILDTAGS: "include_oss include_gcs"
|
||||
CGO_ENABLED: 1
|
||||
GO111MODULE: "auto"
|
||||
GOPATH: ${{ github.workspace }}
|
||||
GOOS: linux
|
||||
COMMIT_RANGE: ${{ github.event_name == 'pull_request' && format('{0}..{1}',github.event.pull_request.base.sha, github.event.pull_request.head.sha) || format('{0}..{1}', github.event.before, github.event.after) }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
path: src/github.com/distribution/distribution
|
||||
fetch-depth: 50
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: ${{ matrix.go-version }}
|
||||
|
||||
- name: Dependencies
|
||||
run: |
|
||||
sudo apt-get -q update
|
||||
sudo -E apt-get -yq --no-install-suggests --no-install-recommends install python2-minimal
|
||||
cd /tmp && go install github.com/vbatts/git-validation@latest
|
||||
|
||||
- name: Build
|
||||
working-directory: ./src/github.com/distribution/distribution
|
||||
run: |
|
||||
DCO_VERBOSITY=-q script/validate/dco
|
||||
go build -i .
|
||||
make build
|
||||
make binaries
|
||||
if [ "$GOOS" = "linux" ]; then make coverage ; fi
|
||||
|
||||
- uses: codecov/codecov-action@v1
|
||||
with:
|
||||
directory: ./src/github.com/distribution/distribution
|
7
.github/workflows/validate.yml
vendored
7
.github/workflows/validate.yml
vendored
|
@ -8,8 +8,6 @@ on:
|
|||
tags:
|
||||
- 'v*'
|
||||
pull_request:
|
||||
branches:
|
||||
- '*'
|
||||
|
||||
jobs:
|
||||
validate:
|
||||
|
@ -20,11 +18,14 @@ jobs:
|
|||
target:
|
||||
- lint
|
||||
- validate-vendor
|
||||
- validate-git
|
||||
steps:
|
||||
-
|
||||
name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v3
|
||||
-
|
||||
name: Run
|
||||
run: |
|
||||
make ${{ matrix.target }}
|
||||
env:
|
||||
COMMIT_RANGE: ${{ format('{0}..{1}', github.sha, 'HEAD') }}
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
# syntax=docker/dockerfile:1
|
||||
|
||||
ARG GO_VERSION=1.18
|
||||
ARG ALPINE_VERSION=3.16
|
||||
ARG XX_VERSION=1.1.1
|
||||
|
||||
FROM --platform=$BUILDPLATFORM tonistiigi/xx:${XX_VERSION} AS xx
|
||||
FROM --platform=$BUILDPLATFORM golang:${GO_VERSION}-alpine AS base
|
||||
FROM --platform=$BUILDPLATFORM golang:${GO_VERSION}-alpine${ALPINE_VERSION} AS base
|
||||
COPY --from=xx / /
|
||||
RUN apk add --no-cache bash coreutils file git
|
||||
ENV GO111MODULE=auto
|
||||
|
@ -49,7 +50,7 @@ RUN --mount=from=binary,target=/build \
|
|||
FROM scratch AS artifact
|
||||
COPY --from=releaser /out /
|
||||
|
||||
FROM alpine:3.16
|
||||
FROM alpine:${ALPINE_VERSION}
|
||||
RUN apk add --no-cache ca-certificates
|
||||
COPY cmd/registry/config-dev.yml /etc/docker/registry/config.yml
|
||||
COPY --from=binary /registry /bin/registry
|
||||
|
|
5
Makefile
5
Makefile
|
@ -38,7 +38,7 @@ BINARIES=$(addprefix bin/,$(COMMANDS))
|
|||
TESTFLAGS ?= -v $(TESTFLAGS_RACE)
|
||||
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
|
||||
|
||||
all: binaries
|
||||
|
@ -103,6 +103,9 @@ validate: ## run all validators
|
|||
lint: ## run all linters
|
||||
docker buildx bake $@
|
||||
|
||||
validate-git: ## validate git
|
||||
docker buildx bake $@
|
||||
|
||||
validate-vendor: ## validate vendor
|
||||
docker buildx bake $@
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ group "default" {
|
|||
}
|
||||
|
||||
group "validate" {
|
||||
targets = ["lint", "validate-vendor"]
|
||||
targets = ["lint", "validate-git", "validate-vendor"]
|
||||
}
|
||||
|
||||
target "lint" {
|
||||
|
@ -11,6 +11,19 @@ target "lint" {
|
|||
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" {
|
||||
dockerfile = "./dockerfiles/vendor.Dockerfile"
|
||||
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
|
|
@ -1,11 +1,12 @@
|
|||
# syntax=docker/dockerfile:1
|
||||
|
||||
ARG GO_VERSION=1.18
|
||||
ARG ALPINE_VERSION=3.16
|
||||
ARG GOLANGCI_LINT_VERSION=v1.45
|
||||
|
||||
FROM golangci/golangci-lint:${GOLANGCI_LINT_VERSION}-alpine AS golangci-lint
|
||||
|
||||
FROM golang:${GO_VERSION}-alpine AS base
|
||||
FROM golang:${GO_VERSION}-alpine${ALPINE_VERSION} AS base
|
||||
RUN apk add --no-cache gcc musl-dev
|
||||
WORKDIR /src
|
||||
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
# syntax=docker/dockerfile:1
|
||||
|
||||
ARG GO_VERSION=1.18
|
||||
ARG ALPINE_VERSION=3.16
|
||||
ARG MODOUTDATED_VERSION=v0.8.0
|
||||
|
||||
FROM golang:${GO_VERSION}-alpine AS base
|
||||
FROM golang:${GO_VERSION}-alpine${ALPINE_VERSION} AS base
|
||||
RUN apk add --no-cache git rsync
|
||||
WORKDIR /src
|
||||
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -eu -o pipefail
|
||||
|
||||
if ! command -v git-validation; then
|
||||
>&2 echo "ERROR: git-validation not found. Install with:"
|
||||
>&2 echo " go install github.com/vbatts/git-validation@latest"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
verbosity="${DCO_VERBOSITY--v}"
|
||||
GIT_CHECK_EXCLUDE="./vendor:./script/validate/template" git-validation "$verbosity" -range "$COMMIT_RANGE" -run DCO,short-subject,dangling-whitespace
|
Loading…
Reference in a new issue