ci(test): validate job matrix

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
(cherry picked from commit a73d78f8d5)
This commit is contained in:
CrazyMax 2022-09-08 21:27:41 +02:00
parent 8af2e62556
commit e42f7db450
No known key found for this signature in database
GPG Key ID: 3248E46B6BB8C7F7
2 changed files with 73 additions and 1 deletions

View File

@ -55,10 +55,75 @@ jobs:
*.cache-to=type=gha,scope=dev${{ matrix.mode }},mode=max
*.output=type=cacheonly
validate:
runs-on: ubuntu-20.04
needs:
- build-dev
strategy:
fail-fast: true
matrix:
script:
- dco
- default-seccomp
- pkg-imports
- yamllint
- swagger
- swagger-gen
- toml
- changelog-well-formed
- changelog-date-descending
- golangci-lint
- shfmt
- vendor
steps:
-
name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
-
name: Dump context
uses: actions/github-script@v6
with:
script: |
console.log(JSON.stringify(context, null, 2));
-
name: Get base ref
id: base-ref
uses: actions/github-script@v6
with:
result-encoding: string
script: |
if (/^refs\/pull\//.test(context.ref) && context.payload?.pull_request?.base?.ref != undefined) {
return context.payload.pull_request.base.ref;
}
return context.ref.replace(/^refs\/heads\//g, '');
-
name: Set up runner
uses: ./.github/actions/setup-runner
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
-
name: Build dev image
uses: docker/bake-action@v2
with:
targets: dev
set: |
dev.cache-from=type=gha,scope=dev
-
name: Validate
run: |
make -o build validate-${{ matrix.script }}
env:
VALIDATE_REPO: ${{ github.server_url }}/${{ github.repository }}.git
VALIDATE_BRANCH: ${{ steps.base-ref.outputs.result }}
unit:
runs-on: ubuntu-20.04
needs:
- build-dev
- validate
steps:
-
name: Checkout
@ -108,6 +173,7 @@ jobs:
runs-on: ubuntu-20.04
needs:
- build-dev
- validate
steps:
-
name: Checkout
@ -155,6 +221,7 @@ jobs:
runs-on: ubuntu-20.04
needs:
- build-dev
- validate
steps:
-
name: Checkout
@ -183,6 +250,7 @@ jobs:
runs-on: ${{ matrix.os }}
needs:
- build-dev
- validate
strategy:
fail-fast: false
matrix:
@ -299,6 +367,7 @@ jobs:
runs-on: ubuntu-20.04
needs:
- build-dev
- validate
- integration-cli-prepare
strategy:
fail-fast: false

View File

@ -1,4 +1,4 @@
.PHONY: all binary dynbinary build cross help install manpages run shell test test-docker-py test-integration test-unit validate win
.PHONY: all binary dynbinary build cross help install manpages run shell test test-docker-py test-integration test-unit validate validate-% win
BUILDX_VERSION ?= v0.9.1
@ -247,6 +247,9 @@ test-unit: build ## run the unit tests
validate: build ## validate DCO, Seccomp profile generation, gofmt,\n./pkg/ isolation, golint, tests, tomls, go vet and vendor
$(DOCKER_RUN_DOCKER) hack/validate/all
validate-%: build ## validate specific check
$(DOCKER_RUN_DOCKER) hack/validate/$*
win: build ## cross build the binary for windows
$(DOCKER_RUN_DOCKER) DOCKER_CROSSPLATFORMS=windows/amd64 hack/make.sh cross