.circleci/config.yml
version: 2.1
jobs:
build:
docker:
- image: cimg/go:1.18 #
environment:
TEST_RESULTS: /tmp/test-results
CC_TEST_REPORTER_ID: 35c4dda715818f2d85184d91bb67dbf568d09d0c574bc4e24be04be2618a08f0
steps:
- checkout # check out source code to working directory
- run: go build github.com/simonmittag/p0d
- run: go install github.com/simonmittag/p0d/cmd/p0d
- run:
name: "Create a temp directory for artifacts"
command: |
mkdir -p /tmp/artifacts
- run:
name: "Create a temp directory for tests"
command: |
mkdir -p /tmp/test-results
- run:
name: Setup Code Climate test-reporter
command: |
# download test reporter as a static binary
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
chmod +x ./cc-test-reporter
- run:
name: Run tests with coverage report
command: |
export GIT_COMMITTED_AT="$(date +%s)"
export CIRCLE_SHA="$CIRCLE_SHA1"
export CIRCLE_BRANCH=`git rev-parse --abbrev-ref HEAD`
./cc-test-reporter before-build
go test -cover -coverprofile=c.out ./...
go tool cover -html=c.out -o coverage.html
./cc-test-reporter after-build --coverage-input-type gocov -p "github.com/simonmittag/p0d"
mv coverage.html /tmp/artifacts
- store_artifacts:
path: /tmp/artifacts
- run:
name: Test Summary for CircleCI
command: |
gotestsum --junitfile /tmp/test-results/unit-tests.xml ./...
- store_test_results:
path: /tmp/test-results