Skip to content

Commit

Permalink
Fix PR, master builds
Browse files Browse the repository at this point in the history
  • Loading branch information
arminc committed May 23, 2020
1 parent d51fe9c commit a716762
Show file tree
Hide file tree
Showing 3 changed files with 118 additions and 0 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/master.yml
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
30 changes: 30 additions & 0 deletions .github/workflows/pull-request.yml
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
48 changes: 48 additions & 0 deletions test.sh
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

0 comments on commit a716762

Please sign in to comment.