fix: test on minimal and stable golang versions (#183)

fix: test on minimal and stable golang versions
---------

Signed-off-by: Mario Candela <mario.candela.personal@gmail.com>
Signed-off-by: James Hodgkinson <james@terminaloutcomes.com>
Co-authored-by: Mario Candela <mario.candela.personal@gmail.com>
This commit is contained in:
James Hodgkinson
2025-03-19 19:18:44 +10:00
committed by GitHub
parent a79937c5ae
commit 16b012784c
2 changed files with 13 additions and 4 deletions

View File

@ -9,6 +9,12 @@ on:
jobs: jobs:
CI: CI:
strategy:
fail-fast: false
matrix:
go-version:
- "1.20.0"
- "stable"
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
@ -16,7 +22,7 @@ jobs:
- name: Set up Go - name: Set up Go
uses: actions/setup-go@v3 uses: actions/setup-go@v3
with: with:
go-version: 1.20.0 go-version: ${{ matrix.go-version }}
- name: Dependencies - name: Dependencies
run: go mod download run: go mod download
@ -35,12 +41,12 @@ jobs:
- name: Quality Gate - Test coverage shall be above threshold - name: Quality Gate - Test coverage shall be above threshold
env: env:
TESTCOVERAGE_THRESHOLD: 65 TESTCOVERAGE_THRESHOLD: 75
run: | run: |
echo "Quality Gate: checking test coverage is above threshold ..." echo "Quality Gate: checking test coverage is above threshold ..."
echo "Threshold : $TESTCOVERAGE_THRESHOLD %" echo "Threshold : $TESTCOVERAGE_THRESHOLD %"
# Excluded the concrete strategy from the unit test coverage, because covered by integration tests # 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" > coverage.out 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]+'` totalCoverage=`go tool cover -func=coverage.out | grep total | grep -Eo '[0-9]+\.[0-9]+'`
echo "Current test coverage : $totalCoverage %" echo "Current test coverage : $totalCoverage %"
if (( $(echo "$totalCoverage $TESTCOVERAGE_THRESHOLD" | awk '{print ($1 > $2)}') )); then if (( $(echo "$totalCoverage $TESTCOVERAGE_THRESHOLD" | awk '{print ($1 > $2)}') )); then
@ -53,6 +59,8 @@ jobs:
- name: Upload coverage reports to Codecov - name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3 uses: codecov/codecov-action@v3
with:
files: ./coverage.out
env: env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

1
.gitignore vendored
View File

@ -3,3 +3,4 @@
logs logs
.vscode .vscode
.history .history
coverage*.out