diff --git a/.github/workflows/quality-checks.yml b/.github/workflows/quality-checks.yml new file mode 100644 index 0000000..c15d968 --- /dev/null +++ b/.github/workflows/quality-checks.yml @@ -0,0 +1,71 @@ +name: Code check +on: + push: + tags: + - v* + branches: + - master + - main + pull_request: +jobs: + golangci: + name: Static code check + runs-on: ubuntu-latest + steps: + - uses: actions/setup-go@v4 + with: + go-version: '1.20' + cache: false + - uses: actions/checkout@v3 + - name: golangci-lint + uses: golangci/golangci-lint-action@v3 + with: + version: latest + tests: + name: Client tests + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Start testing stack + run: docker-compose -f ./docker-compose-ci.yaml up -d + - name: Prepare go environment + uses: actions/setup-go@v4 + with: + go-version: '1.20' + cache: false + - name: Run client tests + run: env TEST_API_HOST=http://localhost:8080 go test --cover -coverprofile coverage.out -covermode count -v ./... + - name: Coverage check + env: + TESTCOVERAGE_THRESHOLD: 0 + run: | + echo "Checking test coverage is above threshold ..." + echo "Threshold : $TESTCOVERAGE_THRESHOLD %" + 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 + auto-build: + name: Auto build Examples + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Prepare go environment + uses: actions/setup-go@v4 + with: + go-version: '1.20' + cache: false + - name: Build fetch example + run: | + make build-fetch-example + - name: Build delete example + run: | + make build-delete-example + - name: Build create example + run: | + make build-create-example \ No newline at end of file