mirror of
https://github.com/mariocandela/beelzebub.git
synced 2025-07-01 18:47:26 -04:00
Rename github action
This commit is contained in:
52
.github/workflows/ci.yml
vendored
Normal file
52
.github/workflows/ci.yml
vendored
Normal file
@ -0,0 +1,52 @@
|
||||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
pull_request:
|
||||
branches: [ main ]
|
||||
|
||||
jobs:
|
||||
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: 1.16
|
||||
|
||||
- name: Dependences
|
||||
run: go mod download
|
||||
|
||||
- name: Vet
|
||||
run: |
|
||||
go vet ./...
|
||||
|
||||
- name: Build
|
||||
run: go build -v ./...
|
||||
|
||||
- name: Unit tests
|
||||
run: |
|
||||
go test ./... -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: 70
|
||||
run: |
|
||||
echo "Quality Gate: checking test coverage is above threshold ..."
|
||||
echo "Threshold : $TESTCOVERAGE_THRESHOLD %"
|
||||
# Excluded the concrete strategy
|
||||
cat coverage.tmp.out | grep -v "secureShellStrategy.go" | grep -v "hypertextTransferProtocolStrategy.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
|
Reference in New Issue
Block a user