1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2024-12-14 11:57:48 +00:00

chore: simplify tests workflow (#5920)

* chore: simplify tests workflow

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>

* makefile

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
This commit is contained in:
Charles-Edouard Brétéché 2023-01-06 21:42:21 +01:00 committed by GitHub
parent 7ab9d95970
commit d84ce8f9d9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 42 deletions

View file

@ -16,11 +16,9 @@ concurrency:
permissions:
contents: read
packages: write
id-token: write
jobs:
pre-checks:
tests:
runs-on: ubuntu-latest
steps:
- name: Checkout
@ -34,44 +32,13 @@ jobs:
with:
version: v1.48
skip-cache: true
- name: gofmt check
run: |
if [ "$(gofmt -s -l . | wc -l)" -ne 0 ]
then
echo "The following files were found to be not go formatted:"
gofmt -s -l .
echo "Please run 'make fmt' to go format the above files."
exit 1
fi
- name: goimports
run: |
go install golang.org/x/tools/cmd/goimports@f112c43328372460f7ac5bc951711609e22b01cc # v0.2.0
if [ "$(goimports -l . | wc -l)" -ne 0 ]
then
echo "The following files were found to have import formatting issues:"
goimports -l -l .
echo "Please run 'make fmt' to go format the above files."
exit 1
fi
- name: go fmt check
run: make fmt-check
- name: goimports check
run: make imports-check
- name: Checking unused pkgs using go mod tidy
run: |
make unused-package-check
run: make unused-package-check
- name: Go vet
run: |
make vet
tests:
runs-on: ubuntu-latest
needs: pre-checks
steps:
- name: Checkout
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
- name: Setup build env
uses: ./.github/actions/setup-build-env
- name: Kyverno unit test
run: |
export PROJECT_PATH=$(pwd)
make test-unit
run: make vet
- name: Unit test
run: make test-unit

View file

@ -155,6 +155,27 @@ vet: ## Run go vet
@echo Go vet... >&2
@go vet ./...
.PHONY: imports
imports: $(GOIMPORTS)
@echo Go imports... >&2
@$(GOIMPORTS) -w .
.PHONY: fmt-check
fmt-check: fmt
@echo Checking code format... >&2
@git --no-pager diff .
@echo 'If this test fails, it is because the git diff is non-empty after running "make fmt".' >&2
@echo 'To correct this, locally run "make fmt" and commit the changes.' >&2
@git diff --quiet --exit-code .
.PHONY: imports-check
imports-check: imports
@echo Checking go imports... >&2
@git --no-pager diff .
@echo 'If this test fails, it is because the git diff is non-empty after running "make imports-check".' >&2
@echo 'To correct this, locally run "make imports" and commit the changes.' >&2
@git diff --quiet --exit-code .
.PHONY: unused-package-check
unused-package-check:
@tidy=$$(go mod tidy); \