2024-01-31 11:07:27 +00:00
|
|
|
name: (sub) Bats / Hub
|
2022-03-09 13:45:36 +00:00
|
|
|
|
|
|
|
on:
|
2022-04-05 09:00:11 +00:00
|
|
|
workflow_call:
|
|
|
|
secrets:
|
|
|
|
GIST_BADGES_SECRET:
|
|
|
|
required: true
|
|
|
|
GIST_BADGES_ID:
|
|
|
|
required: true
|
2022-03-09 13:45:36 +00:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
build:
|
2023-02-28 16:25:09 +00:00
|
|
|
strategy:
|
|
|
|
matrix:
|
2023-12-15 17:30:20 +00:00
|
|
|
test-file: ["hub-1.bats", "hub-2.bats", "hub-3.bats"]
|
2023-02-28 16:25:09 +00:00
|
|
|
|
2024-01-31 11:07:27 +00:00
|
|
|
name: "Functional tests"
|
2022-03-09 13:45:36 +00:00
|
|
|
runs-on: ubuntu-latest
|
2023-03-28 14:26:47 +00:00
|
|
|
timeout-minutes: 30
|
2022-03-09 13:45:36 +00:00
|
|
|
steps:
|
|
|
|
|
2022-03-22 11:33:36 +00:00
|
|
|
- name: "Force machineid"
|
|
|
|
run: |
|
|
|
|
sudo chmod +w /etc/machine-id
|
|
|
|
echo githubciXXXXXXXXXXXXXXXXXXXXXXXX | sudo tee /etc/machine-id
|
|
|
|
|
2023-02-28 16:25:09 +00:00
|
|
|
- name: "Check out CrowdSec repository"
|
2024-01-30 09:20:25 +00:00
|
|
|
uses: actions/checkout@v4
|
2022-03-09 13:45:36 +00:00
|
|
|
with:
|
|
|
|
fetch-depth: 0
|
|
|
|
submodules: true
|
|
|
|
|
2023-12-15 17:30:20 +00:00
|
|
|
- name: "Set up Go"
|
2024-01-30 09:20:25 +00:00
|
|
|
uses: actions/setup-go@v5
|
2023-02-28 16:25:09 +00:00
|
|
|
with:
|
2024-03-19 09:03:54 +00:00
|
|
|
go-version: "1.21.8"
|
2023-02-28 16:25:09 +00:00
|
|
|
|
2022-03-09 13:45:36 +00:00
|
|
|
- name: "Install bats dependencies"
|
2023-02-15 13:27:47 +00:00
|
|
|
env:
|
|
|
|
GOBIN: /usr/local/bin
|
2022-03-09 13:45:36 +00:00
|
|
|
run: |
|
2024-01-19 12:55:28 +00:00
|
|
|
sudo apt -qq -y -o=Dpkg::Use-Pty=0 install build-essential daemonize jq libre2-dev
|
2022-03-09 13:45:36 +00:00
|
|
|
|
2022-04-01 12:12:03 +00:00
|
|
|
- name: "Build crowdsec and fixture"
|
2023-06-23 12:25:29 +00:00
|
|
|
run: make bats-clean bats-build bats-fixture BUILD_STATIC=1
|
2022-03-09 13:45:36 +00:00
|
|
|
|
2022-04-01 12:12:03 +00:00
|
|
|
- name: "Run hub tests"
|
2023-12-15 17:30:20 +00:00
|
|
|
run: |
|
|
|
|
./test/bin/generate-hub-tests
|
2024-02-12 19:15:16 +00:00
|
|
|
./test/run-tests ./test/dyn-bats/${{ matrix.test-file }} --formatter $(pwd)/test/lib/color-formatter
|
2022-03-09 13:45:36 +00:00
|
|
|
|
2022-04-01 12:12:03 +00:00
|
|
|
- name: "Collect hub coverage"
|
2023-03-03 14:54:49 +00:00
|
|
|
run: ./test/bin/collect-hub-coverage >> $GITHUB_ENV
|
2022-03-09 13:45:36 +00:00
|
|
|
|
|
|
|
- name: "Create Parsers badge"
|
2024-03-14 13:04:45 +00:00
|
|
|
uses: schneegans/dynamic-badges-action@v1.7.0
|
2022-10-28 08:11:15 +00:00
|
|
|
if: ${{ github.ref == 'refs/heads/master' && github.repository_owner == 'crowdsecurity' }}
|
2022-03-09 13:45:36 +00:00
|
|
|
with:
|
|
|
|
auth: ${{ secrets.GIST_BADGES_SECRET }}
|
|
|
|
gistID: ${{ secrets.GIST_BADGES_ID }}
|
|
|
|
filename: crowdsec_parsers_badge.json
|
|
|
|
label: Hub Parsers
|
|
|
|
message: ${{ env.PARSERS_COV }}
|
|
|
|
color: ${{ env.SCENARIO_BADGE_COLOR }}
|
|
|
|
|
|
|
|
- name: "Create Scenarios badge"
|
2024-03-14 13:04:45 +00:00
|
|
|
uses: schneegans/dynamic-badges-action@v1.7.0
|
2022-10-28 08:11:15 +00:00
|
|
|
if: ${{ github.ref == 'refs/heads/master' && github.repository_owner == 'crowdsecurity' }}
|
2022-03-09 13:45:36 +00:00
|
|
|
with:
|
|
|
|
auth: ${{ secrets.GIST_BADGES_SECRET }}
|
|
|
|
gistID: ${{ secrets.GIST_BADGES_ID }}
|
|
|
|
filename: crowdsec_scenarios_badge.json
|
|
|
|
label: Hub Scenarios
|
|
|
|
message: ${{ env.SCENARIOS_COV }}
|
|
|
|
color: ${{ env.SCENARIO_BADGE_COLOR }}
|