diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 00000000000..2e73eb4ae95 --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,31 @@ +on: + pull_request: + +jobs: + check-coverage: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-go@v3 + with: + go-version: '^1.19' + + + - name: Unit tests + run: | + go test `go list ./... | grep -v e2e` -coverprofile coverage.out -covermode count + go tool cover -func coverage.out + - name: Quality Gate - Test coverage shall be above threshold + env: + TESTCOVERAGE_THRESHOLD: 0 + run: | + echo "Quality Gate: 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 "Failed" + exit 1 + fi diff --git a/.github/workflows/coveralls.yml b/.github/workflows/coveralls.yml new file mode 100644 index 00000000000..deeff13794d --- /dev/null +++ b/.github/workflows/coveralls.yml @@ -0,0 +1,27 @@ + +on: + pull_request: + +jobs: + coveralls: + runs-on: ubuntu-latest + steps: + - name: Install Go + if: success() + uses: actions/setup-go@v3 + with: + go-version: 1.18 + - name: Checkout code + uses: actions/checkout@v2 + - name: Calc coverage + run: go test `go list ./... | grep -v e2e` -coverprofile coverageRaw.out -covermode count + - name: Remove mocks.go lines + run: | + sed '/mocks.go/d' coverage_raw.out > coverage.out + - name: Convert coverage to lcov + uses: jandelgado/gcov2lcov-action@v1 + - name: Coveralls + uses: coverallsapp/github-action@v2 + with: + path-to-lcov: coverage.lcov + diff --git a/README.md b/README.md index b64f74fa862..9ad39553839 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # Agentbaker +[![Coverage Status](https://coveralls.io/repos/github/UtheMan/AgentBaker/badge.svg?branch=master)](https://coveralls.io/github/UtheMan/AgentBaker?branch=master) Agentbaker is a collection of components used to provision Kubernetes nodes in Azure. diff --git a/parts/linux/cloud-init/artifacts/cse_config.sh b/parts/linux/cloud-init/artifacts/cse_config.sh index c4a2a1635de..cb4a55f4e45 100755 --- a/parts/linux/cloud-init/artifacts/cse_config.sh +++ b/parts/linux/cloud-init/artifacts/cse_config.sh @@ -114,7 +114,7 @@ configureHTTPProxyCA() { update_cmd="update-ca-trust" else cert_dest="/usr/local/share/ca-certificates" - update_cmd="update-ca-certificates" + update_cmd="update-ca-certificates-test" fi echo "${HTTP_PROXY_TRUSTED_CA}" | base64 -d > "${cert_dest}/proxyCA.crt" || exit $ERR_UPDATE_CA_CERTS $update_cmd || exit $ERR_UPDATE_CA_CERTS