Skip to content

Commit

Permalink
WIP - code cov for all
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewSisley committed Sep 8, 2023
1 parent a8c253b commit 22e1511
Show file tree
Hide file tree
Showing 5 changed files with 134 additions and 4 deletions.
31 changes: 30 additions & 1 deletion .github/workflows/detect-change.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
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
Expand Down
29 changes: 29 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
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
29 changes: 29 additions & 0 deletions .github/workflows/test-collection-named.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
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
29 changes: 29 additions & 0 deletions .github/workflows/test-gql-mutations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
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
20 changes: 17 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -297,6 +303,14 @@ 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:
@$(MAKE) deps:coverage
@$(MAKE) deps:lens
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
Expand Down

0 comments on commit 22e1511

Please sign in to comment.