| version: 2.1 |
| jobs: |
| test: |
| docker: |
| - image: circleci/golang:1.14 |
| working_directory: /go/src/github.com/lrills/helm-unittest |
| environment: |
| TEST_ARTIFACTS: /tmp/test-artifacts |
| TEST_RESULTS: /tmp/test-results # path to where test results will be saved |
| steps: |
| - checkout |
| - run: |
| name: Create temp directories for artifacts |
| command: | |
| mkdir -p $TEST_ARTIFACTS |
| mkdir -p $TEST_RESULTS |
| - run: |
| name: Install JUnit plugin for saving test /tmp/test-results |
| command: go get -u github.com/jstemmer/go-junit-report |
| - run: |
| name: Test include Codecoverage |
| command: | |
| trap "go-junit-report < ${TEST_RESULTS}/go-test-output > ${TEST_RESULTS}/go-test-report.xml" EXIT |
| go test ./unittest/... -coverprofile=coverage -v | tee ${TEST_RESULTS}/go-test-output |
| go tool cover -html=coverage -o $TEST_ARTIFACTS/coverage.html |
| - run: |
| name: Cleanup and Check formated |
| command: | |
| go mod tidy |
| "! gofmt -l . 2>&1 | read" |
| - store_test_results: |
| path: $TEST_ARTIFACTS |
| - store_artifacts: |
| path: $TEST_RESULTS |
| |
| distribute: |
| docker: |
| - image: golang:1.14 |
| working_directory: /go/src/github.com/lrills/helm-unittest |
| steps: |
| - checkout |
| - run: |
| name: Insatll ghr |
| command: go get -u github.com/tcnksm/ghr |
| - run: |
| name: Build binaries |
| command: make dist |
| - run: |
| name: Upload binaries |
| command: ghr -u $CIRCLE_USERNAME $CIRCLE_TAG _dist |
| |
| workflows: |
| version: 2 |
| test-and-build: |
| jobs: |
| - test: |
| filters: |
| tags: |
| only: /.*/ |
| - distribute: |
| requires: |
| - test |
| filters: |
| tags: |
| only: /v[0-9]+(\.[0-9]+)*(-.*)?/ |
| branches: |
| ignore: /.*/ |