Files
beelzebub/.github/workflows/ci.yml
Bryan Nolen d677cd20b9 Feature: Enhance Performance, Logging & Stability: Precompile Regex, Command Matching, Golang 1.24, History Cleanup & memLimitMiB Flag. (#182)
* Feat: Add support for logging which "command" was matched for SSH and HTTP strategies.

* Feat: Convert to precompiling regexp at config load time. This allows for errors to be presented to the user during startup, and provides better performance for complex regexp.

* Feat:Bump Golang version to latest stable 1.24

* Feat: Add a cleanup routine for HistoryStore, default TTL for events is 1 hour since last interaction.

* Feat: Add new command line flag "memLimitMiB" with a default value of 100.

---------

Signed-off-by: Bryan Nolen <bryan@arc.net.au>
Signed-off-by: Mario Candela <mario.candela.personal@gmail.com>
Co-authored-by: Mario Candela <mario.candela.personal@gmail.com>
2025-03-23 19:16:34 +01:00

88 lines
2.4 KiB
YAML

name: CI
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
CI:
strategy:
fail-fast: false
matrix:
go-version:
- "1.24.1"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
- name: Dependencies
run: go mod download
- name: Vet
run: |
go vet ./...
- name: Build
run: go build -v ./...
- name: Unit tests
run: |
go test ./... -v -coverprofile coverage.tmp.out -covermode count
go tool cover -func coverage.tmp.out
- name: Quality Gate - Test coverage shall be above threshold
env:
TESTCOVERAGE_THRESHOLD: 80
run: |
echo "Quality Gate: checking test coverage is above threshold ..."
echo "Threshold : $TESTCOVERAGE_THRESHOLD %"
# Excluded the concrete strategy from the unit test coverage, because covered by integration tests
cat coverage.tmp.out | grep -v "ssh.go" | grep -v "http.go" | grep -v "tcp.go" | grep -v "builder.go" | grep -v "director.go" > coverage.out
totalCoverage=`go tool cover -func=coverage.out | grep total | grep -Eo '[0-9]+\.[0-9]+'`
echo "Current test coverage : $totalCoverage %"
if (( $(echo "$totalCoverage $TESTCOVERAGE_THRESHOLD" | awk '{print ($1 > $2)}') )); then
echo "OK"
else
echo "Current test coverage is below threshold. Please add more unit tests or adjust threshold to a lower value."
echo "Failed"
exit 1
fi
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
with:
files: ./coverage.out
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- name: Start integration test dependencies
run: |
make test.dependencies.start
- name: Wait for RabbitMQ to be ready
run: |
sleep 2
count=0
until docker exec rabbitmq rabbitmqctl list_queues > /dev/null 2>&1; do
count=$((count+1))
if [ $count -gt 10 ]; then
echo "RabbitMQ did not start within the specified time"
exit 1
fi
echo "Waiting for RabbitMQ to start..."
sleep 5
done
- name: Integration tests
run: |
make test.integration.verbose
make test.dependencies.down