Skip to content

Commit

Permalink
refactor: split test and test-coverage targets + add cov artifacts to…
Browse files Browse the repository at this point in the history
… gitignore
  • Loading branch information
BarcoMasile committed Mar 19, 2024
1 parent ef85066 commit fb19d10
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-rebac-admin-backend.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:

- name: Build and test Go code
working-directory: ./rebac-admin-backend
run: make ARGS="-count=1" test
run: make ARGS="-count=1" test-coverage


- uses: codecov/codecov-action@c4cf8a4f03f0ac8585acb7c1b7ce3460ec15782f # v4
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ yarn-error.log*

# Output of the go coverage tool, specifically when used with LiteIDE
*.out
test.json
test_source.json

# Dependency directories (remove the comment below to include it)
# vendor/
Expand Down
15 changes: 10 additions & 5 deletions rebac-admin-backend/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,16 @@ mocks:
go generate ./...
.PHONY: mocks

# Run tests
test: mocks
go test ./... -cover -coverprofile coverage_source.out
# this will be cached, just needed to the test.json
go test ./... -cover -coverprofile coverage_source.out -json > test_source.json
# Run tests with coverage
test-coverage: mocks
go test ./... -cover -coverprofile coverage_source.out $(ARGS)
# this will be cached, just needed to get the test.json
go test ./... -cover -coverprofile coverage_source.out $(ARGS) -json > test_source.json
cat coverage_source.out | grep -v "mock_*" | tee coverage.out
cat test_source.json | grep -v "mock_*" | tee test.json
.PHONY: test-coverage

# Run tests
test: mocks
go test ./... $(ARGS)
.PHONY: test

0 comments on commit fb19d10

Please sign in to comment.