parent
1a293a2a27
commit
8ea9e83798
20
.github/workflows/bats-sqlite-coverage.yml
vendored
20
.github/workflows/bats-sqlite-coverage.yml
vendored
|
@ -43,15 +43,21 @@ jobs:
|
||||||
- name: "Run tests"
|
- name: "Run tests"
|
||||||
run: |
|
run: |
|
||||||
TEST_COVERAGE=true make bats-test
|
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"
|
- name: "Show crowdsec logs"
|
||||||
run:
|
run:
|
||||||
for file in $(find ./tests/local/var/log -type f); do echo ">>>>> $file"; cat $file; echo; done
|
for file in $(find ./tests/local/var/log -type f); do echo ">>>>> $file"; cat $file; echo; done
|
||||||
if: ${{ always() }}
|
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
|
||||||
|
|
||||||
|
|
7
.github/workflows/ci-go-test-windows.yml
vendored
7
.github/workflows/ci-go-test-windows.yml
vendored
|
@ -31,3 +31,10 @@ jobs:
|
||||||
run: make build
|
run: make build
|
||||||
- name: All tests
|
- name: All tests
|
||||||
run: go test -coverprofile coverage.out -covermode=atomic ./...
|
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
|
||||||
|
|
||||||
|
|
59
.github/workflows/ci_tests.yml
vendored
59
.github/workflows/ci_tests.yml
vendored
|
@ -61,62 +61,3 @@ jobs:
|
||||||
GIST_BADGES_ID: ${{ secrets.GIST_BADGES_ID }}
|
GIST_BADGES_ID: ${{ secrets.GIST_BADGES_ID }}
|
||||||
GIST_BADGES_SECRET: ${{ secrets.GIST_BADGES_SECRET }}
|
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 >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
|
|
||||||
|
|
||||||
|
|
10
.github/workflows/go-tests.yml
vendored
10
.github/workflows/go-tests.yml
vendored
|
@ -63,10 +63,10 @@ jobs:
|
||||||
- name: "Run tests"
|
- name: "Run tests"
|
||||||
run: |
|
run: |
|
||||||
go run github.com/ory/go-acc ./... -o coverage.out --ignore database,notifications,protobufs,cwversion,cstest,models
|
go run github.com/ory/go-acc ./... -o coverage.out --ignore database,notifications,protobufs,cwversion,cstest,models
|
||||||
bzip2 ./coverage.out
|
|
||||||
|
|
||||||
- name: "Coverage report artifact"
|
- name: Upload unit coverage to Codecov
|
||||||
uses: actions/upload-artifact@v2
|
uses: codecov/codecov-action@v2
|
||||||
with:
|
with:
|
||||||
name: coverage.out.bz2
|
files: coverage.out
|
||||||
path: ./coverage.out.bz2
|
flags: unit-linux
|
||||||
|
|
||||||
|
|
|
@ -18,5 +18,5 @@ THIS_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
|
||||||
# The '=' between flags and values is required.
|
# The '=' between flags and values is required.
|
||||||
exec "${BIN_DIR}/crowdsec.cover" \
|
exec "${BIN_DIR}/crowdsec.cover" \
|
||||||
-test.run="^TestBincoverRunMain$" \
|
-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!
|
-args-file=<(for i; do echo "$i"; done) # Behold the amazing parameter contraption!
|
||||||
|
|
|
@ -25,7 +25,7 @@ set +e
|
||||||
# The '=' between flags and values is required.
|
# The '=' between flags and values is required.
|
||||||
output=$("${BIN_DIR}/cscli.cover" \
|
output=$("${BIN_DIR}/cscli.cover" \
|
||||||
-test.run="^TestBincoverRunMain$" \
|
-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))
|
-args-file=<(for i; do echo "$i"; done))
|
||||||
rc=$?
|
rc=$?
|
||||||
|
|
||||||
|
|
|
@ -45,5 +45,6 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$TEST_COVERAGE" ]; then
|
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
|
fi
|
||||||
|
|
Loading…
Reference in a new issue