Skip to content

Commit b810828

Browse files
authored
Add build and test actions and fix conf path for testing.
1 parent 68a5ed9 commit b810828

3 files changed

Lines changed: 56 additions & 337 deletions

File tree

.github/workflows/go.yml

Lines changed: 52 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,61 @@ jobs:
1818
with:
1919
go-version: 1.15
2020

21-
- name: Analyze
21+
- name: Static analysis of code for errors
2222
run: make analyze
2323

24+
# - name: Build
25+
# run: go build -v ./...
26+
2427
- name: Build
2528
run: make build
2629

27-
# - name: Test
28-
# run: make test
29-
30-
# - name: Build
31-
# run: go build -v ./...
30+
- name: Test - go test
31+
env:
32+
PM_CONF_FILE: ${{ github.workspace }}/sample/pm.config.yaml
33+
INTEGRATION_TEST: START
34+
INTEG_TEST_BIN: ${{ github.workspace }}
35+
run: |
36+
mkdir -p ${{ github.workspace }}/cover
37+
go test -mod=vendor -v ./...
38+
39+
# - name: Test - make test
40+
# env:
41+
# TOP: ${{ github.workspace }}
42+
# GOSRC: ${{ github.workspace }}
43+
# GOCOVER: ${{ github.workspace }}/cover
44+
# GOTOOLSBIN: ${{ github.workspace }}/tools/go
45+
# run: make test
3246

33-
- name: Test
34-
run: go test -mod=vendor -v ./...
35-
47+
- name: Test - contents of make test!
48+
run: |
49+
set -x
50+
echo "Running Plugin Manager Go Unit Tests...";
51+
GOSRC=${{ github.workspace }}
52+
GOCOVER=${{ github.workspace }}/cover
53+
TOOLSBIN=${{ github.workspace }}/tools
54+
GOTOOLSBIN=${{ github.workspace }}/tools/go
55+
mkdir -p ${GOCOVER};
56+
export INTEG_TEST_BIN=${GOSRC};
57+
mkdir -p ${INTEG_TEST_BIN};
58+
export PM_CONF_FILE=${GOSRC}/sample/pm.config.yaml;
59+
export INTEGRATION_TEST=START;
60+
cd ${GOSRC};
61+
test_failed=0;
62+
d=pm;
63+
go test -mod=vendor -v --cover -covermode=count -coverprofile=${GOCOVER}/${d}.out ./... | ${GOTOOLSBIN}/go-junit-report > TEST-${d}.xml;
64+
ret=${PIPESTATUS[0]};
65+
if [ ${ret} -ne 0 ]; then
66+
echo "Go unit test failed for ${d}.";
67+
test_failed=1;
68+
fi ;
69+
cat TEST-${d}.xml
70+
awk -f ${TOOLSBIN}/gocoverage-collate.awk ${GOCOVER}/* > ${GOCOVER}/cover.out;
71+
go tool cover -html=${GOCOVER}/cover.out -o go-coverage-${d}.html;
72+
${GOTOOLSBIN}/gocov convert ${GOCOVER}/cover.out | ${GOTOOLSBIN}/gocov-xml > go-coverage-${d}.xml;
73+
rm -rf ${GOCOVER}/*;
74+
export INTEGRATION_TEST=DONE;
75+
if [ ${test_failed} -ne 0 ]; then
76+
echo "Go unit tests failed.";
77+
exit 1;
78+
fi

Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,10 @@ govet: ## Run go vet
7373

7474
.PHONY: test
7575
test: ## Run all tests
76-
echo "Running Plugin Manager Go Unit Tests..."; \
76+
echo "Running Plugin Manager Go Unit Tests...";
7777
mkdir -p $(GOCOVER);
7878
export INTEG_TEST_BIN=$(GOSRC); \
79-
export PM_CONF_FILE=$(GOSRC)/docs/sample/pm.config.yaml; \
79+
export PM_CONF_FILE=$(GOSRC)/sample/pm.config.yaml; \
8080
export INTEGRATION_TEST=START; \
8181
cd $(GOSRC); \
8282
test_failed=0; \
@@ -101,13 +101,13 @@ test: ## Run all tests
101101
.PHONY: go-race
102102
go-race: ## Run Go tests with race detector enabled
103103
echo "Checking Go code for race conditions...";
104-
# NOTE: SUMCOVER directory should be present, along with INTEGRATION_TEST
104+
# NOTE: COVER directory should be present, along with INTEGRATION_TEST
105105
# value being set to "START" for integ_test.go to succeed.
106106
mkdir -p $(GOCOVER);
107107
export INTEGRATION_TEST=START; \
108108
export INTEG_TEST_BIN=$(GOSRC); \
109109
cd $(GOSRC); \
110-
export PM_CONF_FILE=$(GOSRC)/docs/sample/pm.config.yaml; \
110+
export PM_CONF_FILE=$(GOSRC)/sample/pm.config.yaml; \
111111
go test -mod=vendor -v -race ./...;
112112

113113
.NOTPARALLEL:

0 commit comments

Comments
 (0)