github.com/crowdsecurity/crowdsec@v1.6.1/.github/workflows/bats-sqlite-coverage.yml (about) 1 name: (sub) Bats / sqlite + coverage 2 3 on: 4 workflow_call: 5 6 env: 7 TEST_COVERAGE: true 8 9 jobs: 10 build: 11 name: "Functional tests" 12 runs-on: ubuntu-latest 13 timeout-minutes: 20 14 15 steps: 16 17 - name: "Force machineid" 18 run: | 19 sudo chmod +w /etc/machine-id 20 echo githubciXXXXXXXXXXXXXXXXXXXXXXXX | sudo tee /etc/machine-id 21 22 - name: "Check out CrowdSec repository" 23 uses: actions/checkout@v4 24 with: 25 fetch-depth: 0 26 submodules: true 27 28 - name: "Set up Go" 29 uses: actions/setup-go@v5 30 with: 31 go-version: "1.21.9" 32 33 - name: "Install bats dependencies" 34 env: 35 GOBIN: /usr/local/bin 36 run: | 37 sudo apt -qq -y -o=Dpkg::Use-Pty=0 install build-essential daemonize jq libre2-dev 38 39 - name: "Build crowdsec and fixture" 40 run: | 41 make clean bats-build bats-fixture BUILD_STATIC=1 42 43 - name: "Run tests" 44 run: ./test/run-tests ./test/bats --formatter $(pwd)/test/lib/color-formatter 45 46 - name: "Collect coverage data" 47 run: | 48 go tool covdata textfmt -i test/coverage -o coverage-bats-raw.out 49 # filter out unwanted packages, should match the argument to "go-acc --ignore" 50 grep -v \ 51 -e '/pkg/database' \ 52 -e '/plugins/notifications' \ 53 -e '/pkg/protobufs' \ 54 -e '/pkg/cwversions' \ 55 -e '/pkg/models' \ 56 < coverage-bats-raw.out \ 57 > coverage-bats.out 58 59 # 60 # In case you need to inspect the database status after the failure of a given test 61 # 62 # - name: "Run specified tests" 63 # run: ./test/run-tests test/bats/<filename>.bats -f "<test name>" 64 65 - name: "Show database dump" 66 run: | 67 ./test/instance-crowdsec stop 68 sqlite3 ./test/local/var/lib/crowdsec/data/crowdsec.db '.dump' 69 if: ${{ always() }} 70 71 - name: "Show stack traces" 72 run: for file in $(find /tmp/crowdsec-crash.*.txt); do echo ">>>>> $file"; cat $file; echo; done 73 if: ${{ always() }} 74 75 - name: "Show crowdsec logs" 76 run: for file in $(find ./test/local/var/log -type f); do echo ">>>>> $file"; cat $file; echo; done 77 if: ${{ always() }} 78 79 - name: Upload crowdsec coverage to codecov 80 uses: codecov/codecov-action@v4 81 with: 82 files: ./coverage-bats.out 83 flags: bats