nuts-foundation/nuts-node

View on GitHub
.circleci/config.yml

Summary

Maintainability
Test Coverage
version: 2.1

workflows:
  tests:
    jobs:
      - build
      - report:
          requires:
            - build

jobs:
  build:
    parallelism: 8
    docker:
      - image: cimg/go:1.22
    steps:
      - checkout

      - restore_cache:
          keys:
            - go-mod-v2-{{ checksum "go.sum" }}

      - run: go get -t -v ./...

      - save_cache:
          key: go-mod-v2-{{ checksum "go.sum" }}
          paths:
            - "/go/pkg/mod"

      - run: mkdir cov
      - run: go test -p 1 -v $(go list ./... | circleci tests split) -race -coverprofile=cov/c_raw_$CIRCLE_NODE_INDEX.out
      - persist_to_workspace:
          root: .
          paths:
            - cov

  report:
    docker:
      - image: cimg/go:1.22
    steps:
      - checkout
      - attach_workspace:
          at: .
      - run:
          name: Merge test files
          command: |
            cat "cov/c_raw_0.out" >> c_raw.out
            for f in $(seq 1 7)
            do
              tail -n +2 "cov/c_raw_$f.out" >> c_raw.out
            done
      - run:
          name: Remove test, mock and generated code
          command: |
            cat c_raw.out | grep -v generated | grep -v mock | grep -v test.go > c.out
      # Run coverage report for Code Climate
      - run:
          name: Setup Code Climate test-reporter
          command: |
            mkdir -p tmp/
            # download test reporter as a static binary
            curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./tmp/cc-test-reporter
            chmod +x ./tmp/cc-test-reporter
            ./tmp/cc-test-reporter before-build
      # Upload results
      - run:
          name: Upload coverage
          command: |
            ./tmp/cc-test-reporter after-build -t gocov --prefix github.com/nuts-foundation/nuts-node