-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
118 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
name: Master test | ||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
paths: | ||
- '**' | ||
- '!.gitignore' | ||
- '!LICENSE' | ||
- '!*.md' | ||
- '!exampleConfig.yaml' | ||
- '!assets' | ||
|
||
jobs: | ||
test: | ||
name: Test | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
||
- name: Set up Go 1.x | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: ^1.14 | ||
id: go | ||
|
||
- name: Check out code into the Go module directory | ||
uses: actions/checkout@v2 | ||
|
||
- name: Run test steps | ||
run: ./test.sh -a | ||
|
||
- name: Upload coverage to Codecov | ||
uses: codecov/codecov-action@v1 | ||
with: | ||
file: ./coverage.txt | ||
flags: unittests | ||
fail_ci_if_error: true | ||
|
||
- name: Go report card | ||
uses: creekorful/goreportcard-action@v1.0 |
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,30 @@ | ||
name: Pull request test | ||
|
||
on: | ||
pull_request: | ||
branches: [ master ] | ||
paths: | ||
- '**' | ||
- '!.gitignore' | ||
- '!LICENSE' | ||
- '!*.md' | ||
- '!exampleConfig.yaml' | ||
- '!assets' | ||
|
||
jobs: | ||
test: | ||
name: Test | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
||
- name: Set up Go 1.x | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: ^1.14 | ||
id: go | ||
|
||
- name: Check out code into the Go module directory | ||
uses: actions/checkout@v2 | ||
|
||
- name: Run test steps | ||
run: ./test.sh -a |
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,48 @@ | ||
#!/bin/bash | ||
|
||
set -euo pipefail | ||
|
||
RUNALL=false | ||
DEPENDENCIES=false | ||
TESTS=false | ||
BUILD=false | ||
|
||
print_usage() { | ||
echo "Program usage: [./script.sh flags] | ||
Flag: -a [Run everything bellow] | ||
Flag: -d [Get dependencies] | ||
Flag: -t [Run tests with coverage] | ||
Flag: -b [Run a build as test] | ||
Flag: -h [Print help message] | ||
" | ||
} | ||
|
||
while getopts 'hadtb' flag; do | ||
case "${flag}" in | ||
h) print_usage | ||
exit 0 ;; | ||
a) RUNALL=true ;; | ||
d) DEPENDENCIES=true ;; | ||
t) TESTS=true ;; | ||
b) BUILD=true ;; | ||
*) print_usage | ||
exit 1 ;; | ||
esac | ||
done | ||
|
||
if [[ ${DEPENDENCIES} == true || ${RUNALL} == true ]]; then | ||
echo "Get dependencies" | ||
go get -v -t -d ./... | ||
fi | ||
|
||
if [[ ${TESTS} == true || ${RUNALL} == true ]]; then | ||
echo "Run test with coverage" | ||
go test -v ./... -race -coverprofile=coverage.txt -covermode=atomic | ||
fi | ||
|
||
if [[ ${BUILD} == true || ${RUNALL} == true ]]; then | ||
echo "Run a build as test" | ||
go build -v cmd/lcm/main.go | ||
fi |