Skip to content

Commit

Permalink
ci: Add codecov integration and test workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Jesse Schmidt committed Aug 15, 2024
1 parent d898a0b commit 26d1b31
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 2 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Test
on:
push:
branches:
- '**' # Run on every branch
# pull_request:
# branches-ignore:
# - '**' # Ignore all branches for pull requests
workflow_call:

jobs:
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Get go version from go.mod
run: |
echo "GO_VERSION=$(grep '^go ' go.mod | cut -d " " -f 2)" >> $GITHUB_ENV
- uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
- name: Write feature keys
env:
FEATURES_CONF : ${{secrets.FEATURES_CONF}}

run: |
echo "$FEATURES_CONF" > docker/vanilla/config/features.conf
echo "$FEATURES_CONF" > docker/tls/config/features.conf
echo "$FEATURES_CONF" > docker/mtls/config/features.conf
echo "$FEATURES_CONF" > docker/auth/config/features.conf
- name: Login to Aerospike Jfrog
run: |
docker login aerospike.jfrog.io --username ${{ secrets.JFROG_USERNAME }} --password ${{ secrets.JFROG_ACCESS_TOKEN }}
- name: Run tests
run: |
make coverage
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{secrets.CODECOV_TOKEN}}
files: ./coverage/total.cov
verbose: false
32 changes: 30 additions & 2 deletions makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,34 @@
PROTO_DIR = ./protos
ROOT_DIR = $(shell pwd)
PROTO_DIR = $(ROOT_DIR)/protos
COVERAGE_DIR = $(ROOT_DIR)/coverage
COV_UNIT_DIR = $(COVERAGE_DIR)/unit
COV_INTEGRATION_DIR = $(COVERAGE_DIR)/integration

.PHONY: protos
protos:
protoc --proto_path=$(PROTO_DIR) --go_out=$(PROTO_DIR) --go_opt=paths=source_relative \
--go-grpc_out=$(PROTO_DIR) --go-grpc_opt=paths=source_relative $(PROTO_DIR)/*.proto
--go-grpc_out=$(PROTO_DIR) --go-grpc_opt=paths=source_relative $(PROTO_DIR)/*.proto

.PHONY: test
test: integration unit

.PHONY: integration
integration:
mkdir -p $(COV_INTEGRATION_DIR) || true
go test -tags=integration -timeout 30m -cover ./... -args -test.gocoverdir=$(COV_INTEGRATION_DIR)

.PHONY: unit
unit:
mkdir -p $(COV_UNIT_DIR) || true
go test -tags=unit -cover ./... -args -test.gocoverdir=$(COV_UNIT_DIR)

.PHONY: coverage
coverage: test
go tool covdata textfmt -i="$(COV_INTEGRATION_DIR),$(COV_UNIT_DIR)" -o=$(COVERAGE_DIR)/tmp.cov
go tool cover -func=$(COVERAGE_DIR)/tmp.cov
grep -v 'testutils.go' $(COVERAGE_DIR)/tmp.cov > $(COVERAGE_DIR)/total.cov


PHONY: view-coverage
view-coverage: $(COVERAGE_DIR)/total.cov
go tool cover -html=$(COVERAGE_DIR)/total.cov

0 comments on commit 26d1b31

Please sign in to comment.