- update bats-core to the last release - renamed 01_base.bats to 01_cscli.bats - separate stderr for all the run commands in 01_*.bats, fix out/err check where appropriate - cache go modules for bats build too - add configuration file for buildx jobs
99 lines
2.7 KiB
YAML
99 lines
2.7 KiB
YAML
name: Functional tests (sqlite)
|
|
|
|
on:
|
|
workflow_call:
|
|
|
|
env:
|
|
PREFIX_TEST_NAMES_WITH_FILE: true
|
|
TEST_COVERAGE: true
|
|
|
|
jobs:
|
|
build:
|
|
strategy:
|
|
matrix:
|
|
go-version: ["1.20.1"]
|
|
|
|
name: "Build + tests"
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 20
|
|
|
|
steps:
|
|
|
|
- name: "Force machineid"
|
|
run: |
|
|
sudo chmod +w /etc/machine-id
|
|
echo githubciXXXXXXXXXXXXXXXXXXXXXXXX | sudo tee /etc/machine-id
|
|
|
|
- name: "Set up Go ${{ matrix.go-version }}"
|
|
uses: actions/setup-go@v3
|
|
with:
|
|
go-version: ${{ matrix.go-version }}
|
|
id: go
|
|
|
|
- name: "Check out CrowdSec repository"
|
|
uses: actions/checkout@v3
|
|
with:
|
|
fetch-depth: 0
|
|
submodules: true
|
|
|
|
- name: Cache Go modules
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: |
|
|
~/go/pkg/mod
|
|
~/.cache/go-build
|
|
~/Library/Caches/go-build
|
|
%LocalAppData%\go-build
|
|
key: ${{ runner.os }}-${{ matrix.go-version }}-go-${{ hashFiles('**/go.sum') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-${{ matrix.go-version }}-go-
|
|
|
|
- name: "Install bats dependencies"
|
|
env:
|
|
GOBIN: /usr/local/bin
|
|
run: |
|
|
sudo apt -qq -y -o=Dpkg::Use-Pty=0 install build-essential daemonize jq netcat-openbsd
|
|
go install github.com/mikefarah/yq/v4@latest
|
|
go install github.com/cloudflare/cfssl/cmd/cfssl@master
|
|
go install github.com/cloudflare/cfssl/cmd/cfssljson@master
|
|
go install github.com/wadey/gocovmerge@latest
|
|
|
|
- name: "Build crowdsec and fixture"
|
|
run: |
|
|
make clean bats-build bats-fixture
|
|
|
|
- name: "Run tests"
|
|
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"
|
|
run: |
|
|
./tests/instance-crowdsec stop
|
|
sqlite3 ./tests/local/var/lib/crowdsec/data/crowdsec.db '.dump'
|
|
if: ${{ always() }}
|
|
|
|
- name: "Show stack traces"
|
|
run: for file in $(find /tmp/crowdsec-crash.*.txt); do echo ">>>>> $file"; cat $file; echo; done
|
|
if: ${{ always() }}
|
|
|
|
- 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@v3
|
|
with:
|
|
files: ./tests/local/var/lib/coverage/coverage-crowdsec.out
|
|
flags: func-crowdsec
|
|
|
|
- name: Upload cscli coverage to codecov
|
|
uses: codecov/codecov-action@v3
|
|
with:
|
|
files: ./tests/local/var/lib/coverage/coverage-cscli.out
|
|
flags: func-cscli
|