2022-06-17 14:12:49 +00:00
|
|
|
name: Functional tests (sqlite)
|
2022-04-05 09:00:11 +00:00
|
|
|
|
|
|
|
on:
|
|
|
|
workflow_call:
|
|
|
|
|
2022-06-17 14:12:49 +00:00
|
|
|
env:
|
|
|
|
PREFIX_TEST_NAMES_WITH_FILE: true
|
|
|
|
TEST_COVERAGE: true
|
|
|
|
|
2022-04-05 09:00:11 +00:00
|
|
|
jobs:
|
2022-04-13 13:44:23 +00:00
|
|
|
|
2022-04-05 09:00:11 +00:00
|
|
|
build:
|
|
|
|
name: "Build + tests"
|
|
|
|
runs-on: ubuntu-latest
|
2022-04-13 13:44:23 +00:00
|
|
|
timeout-minutes: 20
|
|
|
|
|
2022-04-05 09:00:11 +00:00
|
|
|
steps:
|
|
|
|
|
|
|
|
- name: "Force machineid"
|
|
|
|
run: |
|
|
|
|
sudo chmod +w /etc/machine-id
|
|
|
|
echo githubciXXXXXXXXXXXXXXXXXXXXXXXX | sudo tee /etc/machine-id
|
|
|
|
|
2022-08-26 11:31:49 +00:00
|
|
|
- name: "Set up Go 1.19"
|
2022-04-05 09:00:11 +00:00
|
|
|
uses: actions/setup-go@v3
|
|
|
|
with:
|
2022-08-26 11:31:49 +00:00
|
|
|
go-version: 1.19
|
2022-04-05 09:00:11 +00:00
|
|
|
id: go
|
|
|
|
|
2022-06-17 14:12:49 +00:00
|
|
|
- name: "Check out CrowdSec repository"
|
2022-04-05 09:00:11 +00:00
|
|
|
uses: actions/checkout@v3
|
|
|
|
with:
|
|
|
|
fetch-depth: 0
|
|
|
|
submodules: true
|
|
|
|
|
|
|
|
- name: "Install bats dependencies"
|
|
|
|
run: |
|
2022-06-17 14:12:49 +00:00
|
|
|
sudo apt -qq -y -o=Dpkg::Use-Pty=0 install build-essential daemonize jq netcat-openbsd
|
2022-06-08 14:05:52 +00:00
|
|
|
go install github.com/mikefarah/yq/v4@latest
|
2022-08-26 11:31:49 +00:00
|
|
|
go install github.com/cloudflare/cfssl/cmd/cfssl@master
|
|
|
|
go install github.com/cloudflare/cfssl/cmd/cfssljson@master
|
2022-06-17 14:12:49 +00:00
|
|
|
sudo cp -u ~/go/bin/yq ~/go/bin/cfssl ~/go/bin/cfssljson /usr/local/bin/
|
2022-04-05 09:00:11 +00:00
|
|
|
go install github.com/wadey/gocovmerge@latest
|
2022-06-17 14:12:49 +00:00
|
|
|
sudo cp -u ~/go/bin/gocovmerge /usr/local/bin/
|
2022-04-05 09:00:11 +00:00
|
|
|
|
|
|
|
- name: "Build crowdsec and fixture"
|
2022-06-17 14:12:49 +00:00
|
|
|
run: |
|
|
|
|
make clean bats-build bats-fixture
|
2022-04-05 09:00:11 +00:00
|
|
|
|
2022-04-13 13:44:23 +00:00
|
|
|
- name: "Run tests"
|
2022-06-17 14:12:49 +00:00
|
|
|
run: make bats-test
|
|
|
|
|
|
|
|
#
|
|
|
|
# In case you need to inspect the database status after the failure of a given test
|
|
|
|
#
|
|
|
|
# - name: "Run specified tests"
|
|
|
|
# run: ./tests/run-tests tests/bats/<filename>.bats -f "<test name>"
|
|
|
|
|
|
|
|
- name: "Show database dump"
|
2022-04-13 13:44:23 +00:00
|
|
|
run: |
|
2022-06-17 14:12:49 +00:00
|
|
|
./tests/instance-crowdsec stop
|
|
|
|
sqlite3 ./tests/local/var/lib/crowdsec/data/crowdsec.db '.dump'
|
|
|
|
if: ${{ always() }}
|
2022-04-13 13:03:37 +00:00
|
|
|
|
|
|
|
- name: "Show crowdsec logs"
|
|
|
|
run:
|
|
|
|
for file in $(find ./tests/local/var/log -type f); do echo ">>>>> $file"; cat $file; echo; done
|
|
|
|
if: ${{ always() }}
|
2022-05-24 15:22:08 +00:00
|
|
|
|
|
|
|
- name: Upload crowdsec coverage to codecov
|
2022-10-24 10:48:25 +00:00
|
|
|
uses: codecov/codecov-action@v3
|
2022-05-24 15:22:08 +00:00
|
|
|
with:
|
|
|
|
files: ./tests/local/var/lib/coverage/coverage-crowdsec.out
|
|
|
|
flags: func-crowdsec
|
|
|
|
|
|
|
|
- name: Upload cscli coverage to codecov
|
2022-10-24 10:48:25 +00:00
|
|
|
uses: codecov/codecov-action@v3
|
2022-05-24 15:22:08 +00:00
|
|
|
with:
|
|
|
|
files: ./tests/local/var/lib/coverage/coverage-cscli.out
|
|
|
|
flags: func-cscli
|