From e42f7db45050e63d2ec66f1f59cd933a72402c8f Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Thu, 8 Sep 2022 21:27:41 +0200 Subject: [PATCH] ci(test): validate job matrix Signed-off-by: CrazyMax (cherry picked from commit a73d78f8d5ef524659499c5911f01474cf1d1bba) --- .github/workflows/test.yml | 69 ++++++++++++++++++++++++++++++++++++++ Makefile | 5 ++- 2 files changed, 73 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e5d9af9aab..46caf56da0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 diff --git a/Makefile b/Makefile index 93868c487d..cfe3c17e4b 100644 --- a/Makefile +++ b/Makefile @@ -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