name: Hub Tests on: push: branches: - master pull_request: branches: - master jobs: hubtest: name: Hub tests runs-on: ubuntu-latest env: PUSH_COVERAGE: ${{ github.ref == 'refs/heads/master' }} steps: - name: Set up Go 1.16 uses: actions/setup-go@v1 with: go-version: 1.16 id: go - name: Check out code into the Go module directory uses: actions/checkout@v2 - id: keydb uses: pozetroninc/github-action-get-latest-release@master with: owner: crowdsecurity repo: crowdsec excludes: draft - name: Build release run: BUILD_VERSION=${{ steps.keydb.outputs.release }} make release - name: "Force machineid" run: | sudo chmod +w /etc/machine-id echo githubciXXXXXXXXXXXXXXXXXXXXXXXX | sudo tee /etc/machine-id - name: Install release run: | cd crowdsec-${{ steps.keydb.outputs.release }} sudo ./wizard.sh --unattended - name: "Clone CrowdSec Hub" run: | git clone https://github.com/crowdsecurity/hub.git - name: "Run tests" run: | cd hub/ git checkout hub_tests cscli hubtest run --all --clean echo "PARSERS_COV=$(cscli hubtest coverage --parsers --percent | cut -d '=' -f2)" >> $GITHUB_ENV echo "SCENARIOS_COV=$(cscli hubtest coverage --scenarios --percent | cut -d '=' -f2)" >> $GITHUB_ENV echo "PARSERS_COV_NUMBER=$(cscli hubtest coverage --parsers --percent | cut -d '=' -f2 | tr -d '%')" echo "SCENARIOS_COV_NUMBER=$(cscli hubtest coverage --scenarios --percent | cut -d '=' -f2 | tr -d '%')" echo "PARSER_BADGE_COLOR=$(if [ $PARSERS_COV_NUMBER -lt '70' ]; then echo 'red'; else echo 'green'; fi)" >> $GITHUB_ENV echo "SCENARIO_BADGE_COLOR=$(if [ $SCENARIOS_COV_NUMBER -lt '70' ]; then echo 'red'; else echo 'green'; fi)" >> $GITHUB_ENV - name: Create Parsers badge uses: schneegans/dynamic-badges-action@v1.1.0 if: ${{ env.PUSH_COVERAGE }} 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 uses: schneegans/dynamic-badges-action@v1.1.0 if: ${{ env.PUSH_COVERAGE }} 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 }}