File tree Expand file tree Collapse file tree 2 files changed +68
-6
lines changed Expand file tree Collapse file tree 2 files changed +68
-6
lines changed Original file line number Diff line number Diff line change @@ -38,21 +38,23 @@ jobs:
38
38
39
39
- name : Lint Helm Chart
40
40
run : make lint/helm
41
- # TODO(jawnsy): fix linter warnings and remove this
42
- continue-on-error : true
43
41
44
42
- name : Check formatting and docs
45
- if : always()
46
43
run : ./scripts/fmt.sh
47
44
48
45
- name : Lint Shell Scripts
49
- if : always()
50
46
run : make lint/shellcheck
51
47
52
48
- name : Lint Kubernetes Templates
53
- if : always()
54
49
run : make lint/kubernetes
55
50
51
+ - name : Install Go
52
+ uses : actions/setup-go@v2
53
+ with :
54
+ go-version : ' ^1.17'
55
+
56
+ - name : Unit tests
57
+ run : ./scripts/test_go.sh
58
+
56
59
- name : Package Helm Chart
57
- if : always()
58
60
run : ./scripts/package.sh
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bash
2
+ #
3
+ # Run Go-based unit tests
4
+
5
+ set -o errexit
6
+ set -o nounset
7
+ set -o pipefail
8
+
9
+ CI=${CI:- " " }
10
+ PROJECT_ROOT=$( git rev-parse --show-toplevel)
11
+ # shellcheck source=lib.sh
12
+ source " $PROJECT_ROOT /scripts/lib.sh"
13
+
14
+ echo " --- Running go test"
15
+ export FORCE_COLOR=true
16
+
17
+ test_args=(
18
+ -v
19
+ -failfast
20
+ " ${TEST_ARGS:- } "
21
+ )
22
+
23
+ REPORTDIR=" /tmp/testreports"
24
+ mkdir -p " $REPORTDIR "
25
+ TESTREPORT_JSON=" $REPORTDIR /test_go.json"
26
+ TESTREPORT_XML=" $REPORTDIR /test_go.xml"
27
+ COVERAGE=" $REPORTDIR /test_go.coverage"
28
+
29
+ test_args+=(
30
+ " -covermode=set"
31
+ " -coverprofile=$COVERAGE "
32
+ )
33
+
34
+ declare test_status=0
35
+
36
+ pushd " $PROJECT_ROOT /tests" > /dev/null 2>&1
37
+ # Allow failures to ensure that we can report on slow tests
38
+ set +o errexit
39
+
40
+ run_trace false gotestsum \
41
+ --debug \
42
+ --jsonfile=" $TESTREPORT_JSON " \
43
+ --junitfile=" $TESTREPORT_XML " \
44
+ --hide-summary=skipped \
45
+ --packages=" ./..." \
46
+ -- " ${test_args[@]} "
47
+ test_status=$?
48
+
49
+ # Re-enable failures if steps fail
50
+ set -o errexit
51
+ popd > /dev/null 2>&1
52
+
53
+ # These unit tests should all be fast, so this report should be empty
54
+ threshold=" 5s"
55
+ echo " --- ಠ_ಠ The following tests took longer than $threshold to complete:"
56
+ run_trace false gotestsum tool slowest \
57
+ --jsonfile=" $TESTREPORT_JSON " \
58
+ --threshold=" $threshold "
59
+
60
+ exit " $test_status "
You can’t perform that action at this time.
0 commit comments