diff --git a/.github/workflows/bats-sqlite-coverage.yml b/.github/workflows/bats-sqlite-coverage.yml index d9df89106..b49069b78 100644 --- a/.github/workflows/bats-sqlite-coverage.yml +++ b/.github/workflows/bats-sqlite-coverage.yml @@ -43,15 +43,21 @@ jobs: - name: "Run tests" run: | TEST_COVERAGE=true make bats-test - bzip2 ./tests/local/var/lib/coverage/coverage-bats.out - - - name: "Coverage report artifact" - uses: actions/upload-artifact@v2 - with: - name: coverage-bats.out.bz2 - path: ./tests/local/var/lib/coverage/coverage-bats.out.bz2 - name: "Show crowdsec logs" run: for file in $(find ./tests/local/var/log -type f); do echo ">>>>> $file"; cat $file; echo; done if: ${{ always() }} + + - name: Upload crowdsec coverage to codecov + uses: codecov/codecov-action@v2 + with: + files: ./tests/local/var/lib/coverage/coverage-crowdsec.out + flags: func-crowdsec + + - name: Upload cscli coverage to codecov + uses: codecov/codecov-action@v2 + with: + files: ./tests/local/var/lib/coverage/coverage-cscli.out + flags: func-cscli + diff --git a/.github/workflows/ci-go-test-windows.yml b/.github/workflows/ci-go-test-windows.yml index 91cb2ea83..4c8e3df8e 100644 --- a/.github/workflows/ci-go-test-windows.yml +++ b/.github/workflows/ci-go-test-windows.yml @@ -31,3 +31,10 @@ jobs: run: make build - name: All tests run: go test -coverprofile coverage.out -covermode=atomic ./... + + - name: Upload unit coverage to Codecov + uses: codecov/codecov-action@v2 + with: + files: coverage.out + flags: unit-windows + diff --git a/.github/workflows/ci_tests.yml b/.github/workflows/ci_tests.yml index 3ccc30583..89bbd8ff5 100644 --- a/.github/workflows/ci_tests.yml +++ b/.github/workflows/ci_tests.yml @@ -61,62 +61,3 @@ jobs: GIST_BADGES_ID: ${{ secrets.GIST_BADGES_ID }} GIST_BADGES_SECRET: ${{ secrets.GIST_BADGES_SECRET }} - coverage: - needs: [go-tests, bats-sqlite] - name: Coverage - runs-on: ubuntu-latest - steps: - - name: Check out code into the Go module directory - uses: actions/checkout@v3 - with: - fetch-depth: 1 - path: go/src/github.com/crowdsecurity/crowdsec - - - name: Download unit report - uses: actions/download-artifact@v3 - with: - name: coverage.out.bz2 - - - name: Download bats report - uses: actions/download-artifact@v3 - with: - name: coverage-bats.out.bz2 - -# - name: Environment -# run: env | sort - - - name: merge coverage reports - run: | - go install github.com/wadey/gocovmerge@latest - bunzip2 coverage.out.bz2 - bunzip2 coverage-bats.out.bz2 - ~/go/bin/gocovmerge coverage.out coverage-bats.out > coverage-all.out - bzip2 coverage-all.out.bz2 - -# - name: coverage.out -# run: cat coverage.out - -# - name: coverage-bats.out -# run: cat coverage-bats.out - - - name: gcov2lcov - uses: jandelgado/gcov2lcov-action@v1.0.8 - with: - infile: coverage-all.out - outfile: coverage-all.txt - env: - GOPATH: /home/runner/work/crowdsec/crowdsec/go - - - name: Coverage report artifact (merged) - uses: actions/upload-artifact@v2 - with: - name: coverage-all.out.bz2 - path: ./coverage-all.out.bz2 - - - name: Coveralls - uses: coverallsapp/github-action@master - continue-on-error: true - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - path-to-lcov: coverage-all.txt - diff --git a/.github/workflows/go-tests.yml b/.github/workflows/go-tests.yml index c5d9be91f..15a9dfd58 100644 --- a/.github/workflows/go-tests.yml +++ b/.github/workflows/go-tests.yml @@ -63,10 +63,10 @@ jobs: - name: "Run tests" run: | go run github.com/ory/go-acc ./... -o coverage.out --ignore database,notifications,protobufs,cwversion,cstest,models - bzip2 ./coverage.out - - name: "Coverage report artifact" - uses: actions/upload-artifact@v2 + - name: Upload unit coverage to Codecov + uses: codecov/codecov-action@v2 with: - name: coverage.out.bz2 - path: ./coverage.out.bz2 + files: coverage.out + flags: unit-linux + diff --git a/tests/crowdsec-wrapper b/tests/crowdsec-wrapper index 40628dc37..886e70be4 100755 --- a/tests/crowdsec-wrapper +++ b/tests/crowdsec-wrapper @@ -18,5 +18,5 @@ THIS_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd) # The '=' between flags and values is required. exec "${BIN_DIR}/crowdsec.cover" \ -test.run="^TestBincoverRunMain$" \ - -test.coverprofile="${LOCAL_DIR}/var/lib/coverage/$(date +'%s')-$$.out" \ + -test.coverprofile="${LOCAL_DIR}/var/lib/coverage/crowdsec-$(date +'%s')-$$.out" \ -args-file=<(for i; do echo "$i"; done) # Behold the amazing parameter contraption! diff --git a/tests/cscli-wrapper b/tests/cscli-wrapper index 54386227d..e72f02a83 100755 --- a/tests/cscli-wrapper +++ b/tests/cscli-wrapper @@ -25,7 +25,7 @@ set +e # The '=' between flags and values is required. output=$("${BIN_DIR}/cscli.cover" \ -test.run="^TestBincoverRunMain$" \ - -test.coverprofile="${LOCAL_DIR}/var/lib/coverage/$(date +'%s')-$$.out" \ + -test.coverprofile="${LOCAL_DIR}/var/lib/coverage/cscli-$(date +'%s')-$$.out" \ -args-file=<(for i; do echo "$i"; done)) rc=$? diff --git a/tests/run-tests b/tests/run-tests index 5edc9ec69..559deef14 100755 --- a/tests/run-tests +++ b/tests/run-tests @@ -45,5 +45,6 @@ else fi if [ -n "$TEST_COVERAGE" ]; then - gocovmerge "${LOCAL_DIR}"/var/lib/coverage/* > "${LOCAL_DIR}/var/lib/coverage/coverage-bats.out" + gocovmerge "${LOCAL_DIR}"/var/lib/coverage/crowdsec-* > "${LOCAL_DIR}/var/lib/coverage/coverage-crowdsec.out" + gocovmerge "${LOCAL_DIR}"/var/lib/coverage/cscli-* > "${LOCAL_DIR}/var/lib/coverage/coverage-cscli.out" fi