-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: implement a new command to support gotestsum (#93)
- Loading branch information
1 parent
a6304f1
commit e2df0e6
Showing
11 changed files
with
174 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
description: | | ||
Runs 'go test ./...' but includes extensive parameterization for finer tuning | ||
parameters: | ||
project-path: | ||
description: | | ||
The path to the directory containing your Go project files: | ||
.goreleaser.yaml, go.mod, main.go. | ||
Defaults to $HOME. | ||
type: string | ||
default: "" | ||
packages: | ||
description: import tests to run, by path glob. | ||
type: string | ||
default: "./..." | ||
junitfile: | ||
description: file to save junit format xml file | ||
type: string | ||
default: "unit-tests.xml" | ||
covermode: | ||
description: mode used to count coverage | ||
type: string | ||
default: "atomic" | ||
coverprofile: | ||
description: file to save coverage profile | ||
type: string | ||
default: "cover-source.out" | ||
steps: | ||
- run: | ||
environment: | ||
ORB_EVAL_PROJECT_PATH: <<parameters.project-path>> | ||
ORB_VAL_PACKAGES: <<parameters.packages>> | ||
ORB_VAL_JUNITFILE: <<parameters.junitfile>> | ||
ORB_VAL_COVERMODE: <<parameters.covermode>> | ||
ORB_EVAL_COVER_PROFILE: <<parameters.coverprofile>> | ||
command: <<include(scripts/gotestsum.sh)>> | ||
name: "gotestsum" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#! /bin/bash | ||
|
||
if [ ! "$(which gotestsum)" ]; then | ||
echo The gotestsum command is not available in this executor. | ||
exit 1 | ||
fi | ||
|
||
if [ -n "${ORB_EVAL_PROJECT_PATH}" ]; then | ||
cd "${ORB_EVAL_PROJECT_PATH}" || exit | ||
fi | ||
|
||
if [ -n "$ORB_VAL_PACKAGES" ];then | ||
set -- "$@" --packages "${ORB_VAL_PACKAGES}" | ||
fi | ||
|
||
if [ -n "$ORB_VAL_JUNITFILE" ];then | ||
set -- "$@" --junitfile "${ORB_VAL_JUNITFILE}" | ||
fi | ||
|
||
if [ -n "$ORB_VAL_COVERMODE" ];then | ||
COVERMODE="-covermode=${ORB_VAL_COVERMODE}" | ||
fi | ||
|
||
if [ -n "$ORB_EVAL_COVER_PROFILE" ];then | ||
INPUT_COVER_PROFILE=$(eval echo "$ORB_EVAL_COVER_PROFILE") | ||
COVER_PROFILE="-coverprofile=${INPUT_COVER_PROFILE}" | ||
fi | ||
|
||
set -x | ||
gotestsum \ | ||
"$@" \ | ||
-- \ | ||
"${COVERMODE}" \ | ||
"${COVER_PROFILE}" \ | ||
-coverpkg="$ORB_VAL_PACKAGES" | ||
set +x |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module main | ||
module circleci.com/go-orb | ||
|
||
go 1.20 | ||
go 1.23.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,15 @@ | ||
// main.go | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
|
||
"circleci.com/go-orb/numbers" | ||
"circleci.com/go-orb/words" | ||
) | ||
|
||
func main() { | ||
println("Hello, World!") | ||
} | ||
word := words.Word() | ||
number := numbers.Number() | ||
fmt.Printf("%s %d\n", word, number) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package numbers | ||
|
||
func Number() int { | ||
return 1987 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package numbers | ||
|
||
import "testing" | ||
|
||
func TestNumber(t *testing.T) { | ||
result := Number() | ||
if result != 1987 { | ||
t.FailNow() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package words | ||
|
||
func Word() string { | ||
return "Word" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package words | ||
|
||
import "testing" | ||
|
||
func TestWord(t *testing.T) { | ||
result := Word() | ||
if result != "Word" { | ||
t.FailNow() | ||
} | ||
} |