From e460698d7a82f28bbcdf191642e173e1358672d6 Mon Sep 17 00:00:00 2001 From: Sterling Hanenkamp Date: Thu, 13 Jun 2024 17:08:05 -0500 Subject: [PATCH] cicd: setup --- .github/workflows/test.yml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..d5f1780 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,32 @@ +name: Test Application +on: + push: + +jobs: + run-tests: + name: Run Tests + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version: 1.19 + - uses: golangci/golangci-lint-action@v6 + with: + version: 1.59 + - run: go test ./... + name: Run All Tests + - run: go test ./... -coverprofile=coverage.out + name: Run Tests with Coverage + - run: go tool cover -func=coverage.out + name: Display Coverage + - name: Coverage Quality Check + env: + REQUIRED_COVERAGE: 90 + run: | + totalCoverage=$(go tool cover -func=coverage.out | grep total | grep -Eo '[0-9]+\.[0-9]+') + echo "Total Coverage: $totalCoverage %" + if (( $(echo "$totalCoverage < $REQUIRED_COVERAGE" | bc -l) )); then + echo "Coverage is less than $REQUIRED_COVERAGE %" + exit 1 + fi