File tree Expand file tree Collapse file tree 11 files changed +174
-5
lines changed
Expand file tree Collapse file tree 11 files changed +174
-5
lines changed Original file line number Diff line number Diff line change @@ -137,6 +137,42 @@ jobs:
137137 - go/install :
138138 version : 1.16.4
139139 - run : go version && go build ./...
140+ go-test-default :
141+ docker :
142+ - image : cimg/go:1.23.3
143+ steps :
144+ - checkout
145+ - go/test :
146+ project-path : tests
147+ int-test-gotestsum-1-test :
148+ docker :
149+ - image : cimg/go:1.23.3
150+ steps :
151+ - checkout
152+ - go/gotestsum :
153+ project-path : tests
154+ packages : circleci.com/go-orb/numbers
155+ - store_test_results :
156+ path : /home/circleci/project/tests
157+ int-test-gotestsum-2-test :
158+ docker :
159+ - image : cimg/go:1.23.3
160+ steps :
161+ - checkout
162+ - go/gotestsum :
163+ project-path : tests
164+ packages : circleci.com/go-orb/numbers circleci.com/go-orb/words
165+ - store_test_results :
166+ path : /home/circleci/project/tests
167+ int-test-gotestsum-all-test :
168+ docker :
169+ - image : cimg/go:1.23.3
170+ steps :
171+ - checkout
172+ - go/gotestsum :
173+ project-path : tests
174+ - store_test_results :
175+ path : /home/circleci/project/tests
140176workflows :
141177 test-deploy :
142178 jobs :
@@ -164,6 +200,14 @@ workflows:
164200 filters : *filters
165201 - int-test-vm-arm64 :
166202 filters : *filters
203+ - go-test-default :
204+ filters : *filters
205+ - int-test-gotestsum-1-test :
206+ filters : *filters
207+ - int-test-gotestsum-2-test :
208+ filters : *filters
209+ - int-test-gotestsum-all-test :
210+ filters : *filters
167211 - orb-tools/pack :
168212 filters : *release-filters
169213 - orb-tools/publish :
Original file line number Diff line number Diff line change 1+ description : |
2+ Runs 'go test ./...' but includes extensive parameterization for finer tuning
3+ parameters :
4+ project-path :
5+ description : |
6+ The path to the directory containing your Go project files:
7+ .goreleaser.yaml, go.mod, main.go.
8+ Defaults to $HOME.
9+ type : string
10+ default : " "
11+ packages :
12+ description : import tests to run, by path glob.
13+ type : string
14+ default : " ./..."
15+ junitfile :
16+ description : file to save junit format xml file
17+ type : string
18+ default : " unit-tests.xml"
19+ covermode :
20+ description : mode used to count coverage
21+ type : string
22+ default : " atomic"
23+ coverprofile :
24+ description : file to save coverage profile
25+ type : string
26+ default : " cover-source.out"
27+ steps :
28+ - run :
29+ environment :
30+ ORB_EVAL_PROJECT_PATH : <<parameters.project-path>>
31+ ORB_VAL_PACKAGES : <<parameters.packages>>
32+ ORB_VAL_JUNITFILE : <<parameters.junitfile>>
33+ ORB_VAL_COVERMODE : <<parameters.covermode>>
34+ ORB_EVAL_COVER_PROFILE : <<parameters.coverprofile>>
35+ command : <<include(scripts/gotestsum.sh)>>
36+ name : " gotestsum"
Original file line number Diff line number Diff line change @@ -60,12 +60,19 @@ parameters:
6060 (Sets -cover.)
6161 type : string
6262 default : " ./..."
63+ project-path :
64+ description : |
65+ The path to the directory containing your Go project files:
66+ .goreleaser.yaml, go.mod, main.go.
67+ Defaults to $HOME.
68+ type : string
69+ default : " "
6370steps :
6471 - run :
6572 environment :
6673 ORB_VAL_RACE : <<parameters.race>>
6774 ORB_VAL_COUNT : <<parameters.count>>
68- ORB_VAL_FAIL_FAST : <<parameters.failfast>>
75+ ORB_VAL_FAILFAST : <<parameters.failfast>>
6976 ORB_VAL_SHORT : <<parameters.short>>
7077 ORB_VAL_TIMEOUT : <<parameters.timeout>>
7178 ORB_VAL_PARALLEL : <<parameters.parallel>>
7481 ORB_VAL_PACKAGES : <<parameters.packages>>
7582 ORB_VAL_COVERPKG : <<parameters.coverpkg>>
7683 ORB_EVAL_COVER_PROFILE : <<parameters.coverprofile>>
84+ ORB_EVAL_PROJECT_PATH : <<parameters.project-path>>
7785 command : <<include(scripts/test.sh)>>
7886 name : " go test"
7987 no_output_timeout : <<parameters.no_output_timeout>>
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ if [ ! " $( which gotestsum) " ]; then
4+ echo The gotestsum command is not available in this executor.
5+ exit 1
6+ fi
7+
8+ if [ -n " ${ORB_EVAL_PROJECT_PATH} " ]; then
9+ cd " ${ORB_EVAL_PROJECT_PATH} " || exit
10+ fi
11+
12+ if [ -n " $ORB_VAL_PACKAGES " ]; then
13+ set -- " $@ " --packages " ${ORB_VAL_PACKAGES} "
14+ fi
15+
16+ if [ -n " $ORB_VAL_JUNITFILE " ]; then
17+ set -- " $@ " --junitfile " ${ORB_VAL_JUNITFILE} "
18+ fi
19+
20+ if [ -n " $ORB_VAL_COVERMODE " ]; then
21+ COVERMODE=" -covermode=${ORB_VAL_COVERMODE} "
22+ fi
23+
24+ if [ -n " $ORB_EVAL_COVER_PROFILE " ]; then
25+ INPUT_COVER_PROFILE=$( eval echo " $ORB_EVAL_COVER_PROFILE " )
26+ COVER_PROFILE=" -coverprofile=${INPUT_COVER_PROFILE} "
27+ fi
28+
29+ set -x
30+ gotestsum \
31+ " $@ " \
32+ -- \
33+ " ${COVERMODE} " \
34+ " ${COVER_PROFILE} " \
35+ -coverpkg=" $ORB_VAL_PACKAGES "
36+ set +x
Original file line number Diff line number Diff line change 11#! /usr/bin/env bash
2+
3+ if [ -n " ${ORB_EVAL_PROJECT_PATH} " ]; then
4+ cd " ${ORB_EVAL_PROJECT_PATH} " || exit
5+ fi
6+
27COVER_PROFILE=$( eval echo " $ORB_EVAL_COVER_PROFILE " )
38
49if [ -n " $ORB_VAL_RACE " ]; then
510 set -- " $@ " -race
11+ ORB_VAL_COVER_MODE=atomic
612fi
713
814if [ " $ORB_VAL_FAILFAST " != " false" ]; then
Original file line number Diff line number Diff line change 1- module main
1+ module circleci.com/go-orb
22
3- go 1.20
3+ go 1.23.3
Original file line number Diff line number Diff line change 11// main.go
22package main
33
4+ import (
5+ "fmt"
6+
7+ "circleci.com/go-orb/numbers"
8+ "circleci.com/go-orb/words"
9+ )
10+
411func main () {
5- println ("Hello, World!" )
6- }
12+ word := words .Word ()
13+ number := numbers .Number ()
14+ fmt .Printf ("%s %d\n " , word , number )
15+ }
Original file line number Diff line number Diff line change 1+ package numbers
2+
3+ func Number () int {
4+ return 1987
5+ }
Original file line number Diff line number Diff line change 1+ package numbers
2+
3+ import "testing"
4+
5+ func TestNumber (t * testing.T ) {
6+ result := Number ()
7+ if result != 1987 {
8+ t .FailNow ()
9+ }
10+ }
Original file line number Diff line number Diff line change 1+ package words
2+
3+ func Word () string {
4+ return "Word"
5+ }
You can’t perform that action at this time.
0 commit comments