2022-04-01 12:12:03 +00:00
|
|
|
name: Hub tests
|
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
|
|
|
|
2022-06-17 14:12:49 +00:00
|
|
|
env:
|
|
|
|
PREFIX_TEST_NAMES_WITH_FILE: true
|
|
|
|
|
2022-03-09 13:45:36 +00:00
|
|
|
jobs:
|
|
|
|
build:
|
2023-02-28 16:25:09 +00:00
|
|
|
strategy:
|
|
|
|
matrix:
|
2023-12-06 11:38:36 +00:00
|
|
|
go-version: ["1.21.5"]
|
2023-02-28 16:25:09 +00:00
|
|
|
|
2022-04-01 12:12:03 +00:00
|
|
|
name: "Build + 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"
|
2022-04-05 09:00:11 +00:00
|
|
|
uses: actions/checkout@v3
|
2022-03-09 13:45:36 +00:00
|
|
|
with:
|
|
|
|
fetch-depth: 0
|
|
|
|
submodules: true
|
|
|
|
|
2023-06-27 12:50:45 +00:00
|
|
|
- name: "Set up Go ${{ matrix.go-version }}"
|
|
|
|
uses: actions/setup-go@v4
|
2023-02-28 16:25:09 +00:00
|
|
|
with:
|
2023-06-27 12:50:45 +00:00
|
|
|
go-version: ${{ matrix.go-version }}
|
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: |
|
2023-06-23 12:25:29 +00:00
|
|
|
sudo apt -qq -y -o=Dpkg::Use-Pty=0 install build-essential daemonize jq netcat-openbsd 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"
|
2022-03-21 14:51:05 +00:00
|
|
|
run: make bats-test-hub
|
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"
|
2023-02-01 15:55:34 +00:00
|
|
|
uses: schneegans/dynamic-badges-action@v1.6.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"
|
2023-02-01 15:55:34 +00:00
|
|
|
uses: schneegans/dynamic-badges-action@v1.6.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 }}
|