From e5f1beb6f315693266b55645f652351ea5c7e91d Mon Sep 17 00:00:00 2001 From: Chris Date: Wed, 13 Jan 2021 09:50:23 +0100 Subject: [PATCH 1/4] Extract unit tests into its own workflow Running tests again when merging a PR to master does not make much sense, since the tests ran in the PR before. Thus skip them. We still run unit tests in the master branch solely for the purpose of publishing CodeClimate test report --- .github/workflows/build.yml | 31 ------------------------------- .github/workflows/test.yml | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 31 deletions(-) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8a6a4d595..cef5f2d37 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,42 +1,11 @@ name: Build on: - push: - branches: - - master - - development - tags-ignore: - - "*" pull_request: branches: - master - - development jobs: - test: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Determine Go version from go.mod - run: echo "GO_VERSION=$(grep "go 1." go.mod | cut -d " " -f 2)" >> $GITHUB_ENV - - uses: actions/setup-go@v2 - with: - go-version: ${{ env.GO_VERSION }} - - uses: actions/cache@v2 - with: - path: ~/go/pkg/mod - key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-go- - - name: Run tests - run: make test - - name: Upload code coverage report to Code Climate - uses: paambaati/codeclimate-action@v2.7.5 - env: - CC_TEST_REPORTER_ID: b25e8875aef082d5eee059d71d76dac6d3e0ed23847f6004c1598afe35dadff5 - with: - coverageLocations: cover.out:gocov - prefix: github.com/vshn/k8up e2e-test: runs-on: ubuntu-latest strategy: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 000000000..70650577f --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,35 @@ +name: Test + +on: + push: + branches: + - master + pull_request: + branches: + - master + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Determine Go version from go.mod + run: echo "GO_VERSION=$(grep "go 1." go.mod | cut -d " " -f 2)" >> $GITHUB_ENV + - uses: actions/setup-go@v2 + with: + go-version: ${{ env.GO_VERSION }} + - uses: actions/cache@v2 + with: + path: ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + - name: Run tests + run: make test + - name: Upload code coverage report to Code Climate + uses: paambaati/codeclimate-action@v2.7.5 + env: + CC_TEST_REPORTER_ID: b25e8875aef082d5eee059d71d76dac6d3e0ed23847f6004c1598afe35dadff5 + with: + coverageLocations: cover.out:gocov + prefix: github.com/vshn/k8up From e2fd7c3bcb7f4c1a33ed2b8bc002bd7257ac0c85 Mon Sep 17 00:00:00 2001 From: Chris Date: Wed, 13 Jan 2021 09:50:39 +0100 Subject: [PATCH 2/4] Add codeclimate maintainability badge --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b7c24502b..1e286b208 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,8 @@ -[![Build](https://img.shields.io/github/workflow/status/vshn/k8up/Build)][build] +[![Build](https://img.shields.io/github/workflow/status/vshn/k8up/Test)][build] ![Go version](https://img.shields.io/github/go-mod/go-version/vshn/k8up) ![Kubernetes version](https://img.shields.io/badge/k8s-v1.20-blue) [![Version](https://img.shields.io/github/v/release/vshn/k8up)][releases] +[![Maintainability](https://img.shields.io/codeclimate/maintainability/vshn/k8up)][codeclimate] [![GitHub downloads](https://img.shields.io/github/downloads/vshn/k8up/total)][releases] [![Docker image](https://img.shields.io/docker/pulls/vshn/k8up)][dockerhub] [![License](https://img.shields.io/github/license/vshn/k8up)][license] @@ -122,8 +123,9 @@ make clean There are a number of example configurations in [`config/samples`](config/samples). Apply them using `kubectl apply -f config/samples/somesample.yaml` -[build]: https://github.com/vshn/k8up/actions?query=workflow%3ABuild +[build]: https://github.com/vshn/k8up/actions?query=workflow%3ATest [releases]: https://github.com/vshn/k8up/releases [license]: https://github.com/vshn/k8up/blob/master/LICENSE [dockerhub]: https://hub.docker.com/r/vshn/k8up [detik]: https://github.com/bats-core/bats-detik +[codeclimate]: https://codeclimate.com/github/vshn/k8up From a1d3a09b504e49dae47697607e8fc67f964dcee6 Mon Sep 17 00:00:00 2001 From: Chris Date: Mon, 18 Jan 2021 15:17:56 +0100 Subject: [PATCH 3/4] Increase timeout of e2e test With KIND K8s 1.20, the node takes a bit longer until its ready, thus the Pod stays in Pending for ~40s, enough to trigger a timeout failure of the test. --- e2e/test1.bats | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/test1.bats b/e2e/test1.bats index 76b8b66a5..539f267bb 100644 --- a/e2e/test1.bats +++ b/e2e/test1.bats @@ -19,6 +19,6 @@ DEBUG_DETIK="true" echo "$output" try "at most 10 times every 2s to find 1 pod named 'k8up-operator' with '.spec.containers[*].image' being '${E2E_IMAGE}'" - try "at most 10 times every 2s to find 1 pod named 'k8up-operator' with 'status' being 'running'" + try "at most 20 times every 2s to find 1 pod named 'k8up-operator' with 'status' being 'running'" } From 1520607ad5518ffe54a6cb75084d50f2f3c15adf Mon Sep 17 00:00:00 2001 From: Chris Date: Mon, 18 Jan 2021 15:26:26 +0100 Subject: [PATCH 4/4] Rename build workflow and remove image build The image build is part of e2e test anyway --- .github/workflows/{build.yml => e2e.yml} | 19 +------------------ .github/workflows/lint.yml | 8 +------- .github/workflows/{push.yml => master.yml} | 2 +- .github/workflows/test.yml | 2 +- 4 files changed, 4 insertions(+), 27 deletions(-) rename .github/workflows/{build.yml => e2e.yml} (71%) rename .github/workflows/{push.yml => master.yml} (98%) diff --git a/.github/workflows/build.yml b/.github/workflows/e2e.yml similarity index 71% rename from .github/workflows/build.yml rename to .github/workflows/e2e.yml index cef5f2d37..1c80cc76f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/e2e.yml @@ -1,4 +1,4 @@ -name: Build +name: E2E on: pull_request: @@ -37,20 +37,3 @@ jobs: report_paths: '**/e2e/TestReport-*.xml' github_token: ${{ secrets.GITHUB_TOKEN }} check_name: e2e-report (${{ matrix.kind-node-version }}, ${{ matrix.crd-spec-version }}) - image: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Determine Go version from go.mod - run: echo "GO_VERSION=$(grep "go 1." go.mod | cut -d " " -f 2)" >> $GITHUB_ENV - - uses: actions/setup-go@v2 - with: - go-version: ${{ env.GO_VERSION }} - - uses: actions/cache@v2 - with: - path: ~/go/pkg/mod - key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-go- - - name: Build image - run: make docker-build diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index d90e7f872..b9d7e4b41 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,16 +1,10 @@ name: Lint on: + pull_request: {} push: branches: - master - - development - tags-ignore: - - "*" - pull_request: - branches: - - master - - development jobs: lint: diff --git a/.github/workflows/push.yml b/.github/workflows/master.yml similarity index 98% rename from .github/workflows/push.yml rename to .github/workflows/master.yml index 762f08971..04bc155a0 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/master.yml @@ -1,4 +1,4 @@ -name: Push +name: Master on: push: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 70650577f..0287b3446 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -32,4 +32,4 @@ jobs: CC_TEST_REPORTER_ID: b25e8875aef082d5eee059d71d76dac6d3e0ed23847f6004c1598afe35dadff5 with: coverageLocations: cover.out:gocov - prefix: github.com/vshn/k8up + prefix: github.com/${{ github.repository }}