Skip to content

Commit

Permalink
Add option to support the -skip argument to go test (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
donatwork authored Aug 19, 2024
1 parent 8990b1c commit 05d5c2f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
7 changes: 6 additions & 1 deletion go-code-tester/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ jobs:
skip-list: "this/pkg1,this/pkg2"
# Optional paramter to enable the race detector
race-detector: "true"
# Optional parameter to skip tests
skip-test: "TestToSkip"
```

The `threshold` for the Action is a coverage percentage threshold that every package must meet. The default `threshold` is 90.
Expand All @@ -38,4 +41,6 @@ The `test-folder` is for specifying what folder to run the test command in. The

The `skip-list` is an optional parameter. It should be a comma delimited string of package names to skip for the testing coverage criteria.

The `race-detector` is an optional boolean parameter to enable or disable the race detector.
The `race-detector` is an optional boolean parameter to enable or disable the race detector.

The `skip-test` is a regex and passed directly as the -skip option to the `go test` command.
7 changes: 6 additions & 1 deletion go-code-tester/action.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2020-2023 Dell Inc., or its subsidiaries. All Rights Reserved.
# Copyright (c) 2020-2024 Dell Inc., or its subsidiaries. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -24,6 +24,10 @@ inputs:
description: 'Boolean to enable the race detector'
required: false
default: "true"
skip-test:
description: 'Regex for skipping tests'
required: false
default: ""
runs:
using: 'docker'
image: 'Dockerfile'
Expand All @@ -32,6 +36,7 @@ runs:
- ${{ inputs.test-folder }}
- ${{ inputs.skip-list }}
- ${{ inputs.race-detector }}
- ${{ inputs.skip-test }}
branding:
icon: 'shield'
color: 'blue'
17 changes: 13 additions & 4 deletions go-code-tester/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

# Copyright (c) 2020-2023 Dell Inc., or its subsidiaries. All Rights Reserved.
# Copyright (c) 2020-2024 Dell Inc., or its subsidiaries. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -12,16 +12,25 @@ THRESHOLD=$1
TEST_FOLDER=$2
SKIP_LIST=$3
RACE_DETECTOR=$4
pkg_skip_list=
SKIP_TEST=$5

skip_options=""

if [[ -z $SKIP_TEST ]]; then
echo "running all tests in packages"
else
echo "skipping the following tests (regex): $SKIP_TEST"
skip_options="-skip $SKIP_TEST"
fi

go clean -testcache

cd ${TEST_FOLDER}
if [[ -z $RACE_DETECTOR ]] || [[ $RACE_DETECTOR == "true" ]]; then
GOEXPERIMENT=nocoverageredesign go test -v -short -race -count=1 -cover ./... > ~/run.log
GOEXPERIMENT=nocoverageredesign go test $skip_options -v -short -race -count=1 -cover ./... > ~/run.log
else
# Run without the race flag
GOEXPERIMENT=nocoverageredesign go test -v -short -count=1 -cover ./... > ~/run.log
GOEXPERIMENT=nocoverageredesign go test $skip_options -v -short -count=1 -cover ./... > ~/run.log
fi

TEST_RETURN_CODE=$?
Expand Down

0 comments on commit 05d5c2f

Please sign in to comment.