From 3bd15423e495af476f6cd5105b58f0c0225b4af9 Mon Sep 17 00:00:00 2001 From: stefanprodan Date: Mon, 13 Apr 2020 19:57:47 +0300 Subject: [PATCH] ci: Check if working tree is dirty - run unit tests in a dedicated CI step - check if working tree is dirty and fail CI build --- .github/workflows/e2e.yaml | 8 +++++++- Makefile | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index 8822f0c9..7481d12b 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -29,7 +29,13 @@ jobs: uses: ./.github/actions/kustomize - name: Setup Kubebuilder uses: ./.github/actions/kubebuilder - - name: Run tests and build image + - name: Run tests + run: make test + env: + KUBEBUILDER_ASSETS: ${{ github.workspace }}/kubebuilder/bin + - name: Check if working tree is dirty + run: git diff --quiet || echo 'run make test and commit changes' && exit 1 + - name: Build container image run: make docker-build IMG=test/source-controller:latest env: KUBEBUILDER_ASSETS: ${{ github.workspace }}/kubebuilder/bin diff --git a/Makefile b/Makefile index 5fa45923..770fe259 100644 --- a/Makefile +++ b/Makefile @@ -62,7 +62,7 @@ generate: controller-gen $(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..." # Build the docker image -docker-build: test +docker-build: docker build . -t ${IMG} # Push the docker image