diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 8221c258..dd847b36 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -45,6 +45,9 @@ jobs: uses: actions/checkout@v3 if: github.event.pull_request.head.sha == '' lint: + concurrency: + group: lint-golangci-${{ github.head_ref || github.ref_name }} + cancel-in-progress: true needs: - start-runner - smart-checkout @@ -62,6 +65,9 @@ jobs: with: version: v1.52.2 code-format-check: + concurrency: + group: lint-autoformat-${{ github.head_ref || github.ref_name }} + cancel-in-progress: true needs: - start-runner - smart-checkout @@ -82,13 +88,65 @@ jobs: run: bash ./.github/scripts/format-all-go-code.sh "$PWD" - name: Check repository diff run: bash ./.github/scripts/check-work-copy-equals-to-committed.sh "auto-format broken" - run-tests: + run-unit-tests: + concurrency: + group: run-unit-tests-${{ github.head_ref || github.ref_name }} + cancel-in-progress: true needs: - start-runner - smart-checkout + - lint + - code-format-check + runs-on: ${{ needs.start-runner.outputs.runner-label }} + outputs: + result: ${{ steps.run-unit-tests.outputs.result }} + steps: + - name: set-env-vars + run: | + echo "HOME=/actions-runner" >> $GITHUB_ENV + - name: setup-go + uses: actions/setup-go@v3 + with: + go-version: '1.20' + - name: setup-medium-test-class-binaries + run: | + # This installs kube-apiserver and etcd binaries for `medium` + # class tests. Refer to the writing tests docs for more info. + make envtest + KUBEBUILDER_ASSETS=$(./bin/setup-envtest use 1.26 -p path) + echo "KUBEBUILDER_ASSETS=$KUBEBUILDER_ASSETS" >> $GITHUB_ENV + - name: setup-gotestsum + run: | + go install gotest.tools/gotestsum@v1.12.0 + - name: run-unit-tests + id: run-unit-tests + run: | + gotestsum --format pkgname --jsonfile log.json -- -v -timeout 900s -p 1 ./internal/... -ginkgo.vv -coverprofile cover.out + - name: convert-to-human-readable + run: jq -r '.Output| gsub("[\\n]"; "")' log.json 2>/dev/null 1>log.txt || true + - name: artifact-upload-step + uses: actions/upload-artifact@v4 + id: artifact-upload-step + if: always() + with: + name: unit-tests-log + path: log.txt + if-no-files-found: error + - name: echo-tests-log-url + run: echo 'Unit tests log URL is ${{ steps.artifact-upload-step.outputs.artifact-url }}' + run-e2e-tests: + concurrency: + group: run-e2e-tests-${{ github.head_ref || github.ref_name }} + cancel-in-progress: true + needs: + - start-runner + - smart-checkout + - lint + - code-format-check + - run-unit-tests runs-on: ${{ needs.start-runner.outputs.runner-label }} outputs: - result: ${{ steps.run-tests.outputs.result }} + result: ${{ steps.run-e2e-tests.outputs.result }} steps: - name: set-env-vars run: | @@ -128,13 +186,6 @@ jobs: kind version kubectl version --client=true helm version - - name: setup-medium-test-class-binaries - run: | - # This installs kube-apiserver and etcd binaries for `medium` - # class tests. Refer to the writing tests docs for more info. - make envtest - KUBEBUILDER_ASSETS=$(./bin/setup-envtest use 1.26 -p path) - echo "KUBEBUILDER_ASSETS=$KUBEBUILDER_ASSETS" >> $GITHUB_ENV - name: setup-k8s-cluster run: | kind delete cluster @@ -153,26 +204,49 @@ jobs: - name: load-and-deploy-operator run: | kind load docker-image kind/ydb-operator:current - - name: pull-and-load-other-images + - name: pull-and-load-kube-webhook-certgen-image + uses: nick-fields/retry@v3 + with: + timeout_minutes: 5 + retry_wait_seconds: 20 + max_attempts: 3 + command: | + docker pull k8s.gcr.io/ingress-nginx/kube-webhook-certgen:v1.0 + kind load docker-image k8s.gcr.io/ingress-nginx/kube-webhook-certgen:v1.0 + - name: pull-and-load-ydb-image run: | - docker pull k8s.gcr.io/ingress-nginx/kube-webhook-certgen:v1.0 - kind load docker-image k8s.gcr.io/ingress-nginx/kube-webhook-certgen:v1.0 - # TODO would be cool to parse YDB image from manifests to avoid duplicating information docker pull cr.yandex/crptqonuodf51kdj7a7d/ydb:23.3.17 kind load docker-image cr.yandex/crptqonuodf51kdj7a7d/ydb:23.3.17 - - name: run-tests + - name: setup-gotestsum run: | - go test -v -timeout 3600s -p 1 ./... -args -ginkgo.v + go install gotest.tools/gotestsum@v1.12.0 + - name: run-e2e-tests + id: run-e2e-tests + run: | + gotestsum --format pkgname --jsonfile log.json -- -v -timeout 3600s -p 1 ./e2e/... -ginkgo.vv + - name: convert-to-human-readable + run: jq -r '.Output| gsub("[\\n]"; "")' log.json 2>/dev/null 1>log.txt || true + - name: artifact-upload-step + uses: actions/upload-artifact@v4 + id: artifact-upload-step + if: always() + with: + name: e2e-tests-log + path: log.txt + if-no-files-found: error + - name: echo-tests-log-url + run: echo 'Unit tests log URL is ${{ steps.artifact-upload-step.outputs.artifact-url }}' - name: teardown-k8s-cluster run: | kind delete cluster stop-runner: needs: - start-runner - - run-tests - lint - code-format-check + - run-unit-tests + - run-e2e-tests runs-on: ubuntu-latest if: always() steps: diff --git a/Makefile b/Makefile index 8807f845..9962da2f 100644 --- a/Makefile +++ b/Makefile @@ -83,7 +83,7 @@ unit-test: manifests generate fmt vet envtest ## Run unit tests .PHONY: e2e-test e2e-test: manifests generate fmt vet docker-build kind-init kind-load ## Run e2e tests - go test -v -timeout 3600s -p 1 ./e2e/... -args -ginkgo.v + go test -v -timeout 3600s -p 1 ./e2e/... -ginkgo.v .PHONY: test test: unit-test e2e-test ## Run all tests