From 7d452ac410a950af6b083cf7f4fb3d588b8823c9 Mon Sep 17 00:00:00 2001 From: Andrew Sisley Date: Fri, 8 Sep 2023 13:10:31 -0400 Subject: [PATCH] WIP - code cov for all --- .github/workflows/detect-change.yml | 31 ++++++++++++++++++++- .github/workflows/run-tests.yml | 29 +++++++++++++++++++ .github/workflows/test-collection-named.yml | 29 +++++++++++++++++++ .github/workflows/test-gql-mutations.yml | 29 +++++++++++++++++++ Makefile | 19 +++++++++++-- 5 files changed, 133 insertions(+), 4 deletions(-) diff --git a/.github/workflows/detect-change.yml b/.github/workflows/detect-change.yml index b6272c21cd..ff1f13c1fa 100644 --- a/.github/workflows/detect-change.yml +++ b/.github/workflows/detect-change.yml @@ -45,7 +45,36 @@ jobs: make deps:test - name: Run detection for changes - run: make test:changes + run: make test:changes-ci + + - name: Upload coverage to Codecov without token, retry on failure + env: + codecov_secret: ${{ secrets.CODECOV_TOKEN }} + if: env.codecov_secret == '' + uses: Wandalen/wretry.action@v1.0.36 + with: + attempt_limit: 5 + attempt_delay: 10000 + action: codecov/codecov-action@v3 + with: | + name: defradb-codecov + files: ./coverage.txt + os: 'linux' + fail_ci_if_error: true + verbose: true + + - name: Upload coverage to Codecov with token + env: + codecov_secret: ${{ secrets.CODECOV_TOKEN }} + if: env.codecov_secret != '' + uses: codecov/codecov-action@v3 + with: + token: ${{ env.codecov_secret }} + name: defradb-codecov + files: ./coverage.txt + os: 'linux' + fail_ci_if_error: true + verbose: true ## Uncomment to enable ability to SSH into the runner. #- name: Setup upterm ssh session for debugging diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index bfa696a283..9e4501a5af 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -48,3 +48,32 @@ jobs: - name: Run the tests, showing name of each test run: make test:ci + + - name: Upload coverage to Codecov without token, retry on failure + env: + codecov_secret: ${{ secrets.CODECOV_TOKEN }} + if: env.codecov_secret == '' + uses: Wandalen/wretry.action@v1.0.36 + with: + attempt_limit: 5 + attempt_delay: 10000 + action: codecov/codecov-action@v3 + with: | + name: defradb-codecov + files: ./coverage.txt + os: 'linux' + fail_ci_if_error: true + verbose: true + + - name: Upload coverage to Codecov with token + env: + codecov_secret: ${{ secrets.CODECOV_TOKEN }} + if: env.codecov_secret != '' + uses: codecov/codecov-action@v3 + with: + token: ${{ env.codecov_secret }} + name: defradb-codecov + files: ./coverage.txt + os: 'linux' + fail_ci_if_error: true + verbose: true diff --git a/.github/workflows/test-collection-named.yml b/.github/workflows/test-collection-named.yml index 5adabe4fdf..3f22e584bc 100644 --- a/.github/workflows/test-collection-named.yml +++ b/.github/workflows/test-collection-named.yml @@ -52,3 +52,32 @@ jobs: - name: Run tests with Collection Named mutations run: make test:ci-col-named-mutations + + - name: Upload coverage to Codecov without token, retry on failure + env: + codecov_secret: ${{ secrets.CODECOV_TOKEN }} + if: env.codecov_secret == '' + uses: Wandalen/wretry.action@v1.0.36 + with: + attempt_limit: 5 + attempt_delay: 10000 + action: codecov/codecov-action@v3 + with: | + name: defradb-codecov + files: ./coverage.txt + os: 'linux' + fail_ci_if_error: true + verbose: true + + - name: Upload coverage to Codecov with token + env: + codecov_secret: ${{ secrets.CODECOV_TOKEN }} + if: env.codecov_secret != '' + uses: codecov/codecov-action@v3 + with: + token: ${{ env.codecov_secret }} + name: defradb-codecov + files: ./coverage.txt + os: 'linux' + fail_ci_if_error: true + verbose: true diff --git a/.github/workflows/test-gql-mutations.yml b/.github/workflows/test-gql-mutations.yml index 827dd22098..b0c1c3e449 100644 --- a/.github/workflows/test-gql-mutations.yml +++ b/.github/workflows/test-gql-mutations.yml @@ -46,3 +46,32 @@ jobs: - name: Run tests with gql mutations run: make test:ci-gql-mutations + + - name: Upload coverage to Codecov without token, retry on failure + env: + codecov_secret: ${{ secrets.CODECOV_TOKEN }} + if: env.codecov_secret == '' + uses: Wandalen/wretry.action@v1.0.36 + with: + attempt_limit: 5 + attempt_delay: 10000 + action: codecov/codecov-action@v3 + with: | + name: defradb-codecov + files: ./coverage.txt + os: 'linux' + fail_ci_if_error: true + verbose: true + + - name: Upload coverage to Codecov with token + env: + codecov_secret: ${{ secrets.CODECOV_TOKEN }} + if: env.codecov_secret != '' + uses: codecov/codecov-action@v3 + with: + token: ${{ env.codecov_secret }} + name: defradb-codecov + files: ./coverage.txt + os: 'linux' + fail_ci_if_error: true + verbose: true diff --git a/Makefile b/Makefile index 6eb3456fcc..1d8b5d51b4 100644 --- a/Makefile +++ b/Makefile @@ -187,15 +187,19 @@ test\:build: .PHONY: test\:ci test\:ci: + @$(MAKE) deps:coverage DEFRA_BADGER_MEMORY=true DEFRA_BADGER_FILE=true \ DEFRA_CLIENT_GO=true DEFRA_CLIENT_HTTP=true \ - $(MAKE) test:all + go-acc ./... --output=coverage.txt --covermode=atomic -- -coverpkg=./... $(TEST_FLAGS) + go tool cover -func coverage.txt | grep total | awk '{print $$3}' .PHONY: test\:ci-gql-mutations test\:ci-gql-mutations: + @$(MAKE) deps:coverage DEFRA_MUTATION_TYPE=gql DEFRA_BADGER_MEMORY=true \ DEFRA_CLIENT_GO=true DEFRA_CLIENT_HTTP=true \ - $(MAKE) test:all + go-acc ./... --output=coverage.txt --covermode=atomic -- -coverpkg=./... $(TEST_FLAGS) + go tool cover -func coverage.txt | grep total | awk '{print $$3}' .PHONY: test\:gql-mutations test\:gql-mutations: @@ -208,9 +212,11 @@ test\:gql-mutations: # UpdateDoc will call [Collection.Update]. .PHONY: test\:ci-col-named-mutations test\:ci-col-named-mutations: + @$(MAKE) deps:coverage DEFRA_MUTATION_TYPE=collection-named DEFRA_BADGER_MEMORY=true \ DEFRA_CLIENT_GO=true DEFRA_CLIENT_HTTP=true \ - $(MAKE) test:all + go-acc ./... --output=coverage.txt --covermode=atomic -- -coverpkg=./... $(TEST_FLAGS) + go tool cover -func coverage.txt | grep total | awk '{print $$3}' .PHONY: test\:col-named-mutations test\:col-named-mutations: @@ -297,6 +303,13 @@ test\:changes: @$(MAKE) deps:lens env DEFRA_DETECT_DATABASE_CHANGES=true DEFRA_CLIENT_GO=true gotestsum -- ./... -shuffle=on -p 1 +.PHONY: test\:changes-ci +test\:changes-ci: + @$(MAKE) deps:coverage + env DEFRA_DETECT_DATABASE_CHANGES=true DEFRA_CLIENT_GO=true \ + go-acc ./... --output=coverage.txt --covermode=atomic -- -coverpkg=./... -shuffle=on -p 1 + go tool cover -func coverage.txt | grep total | awk '{print $$3}' + .PHONY: validate\:codecov validate\:codecov: curl --data-binary @.github/codecov.yml https://codecov.io/validate