diff --git a/.github/codecov.yml b/.github/codecov.yml new file mode 100644 index 0000000000..838d86e912 --- /dev/null +++ b/.github/codecov.yml @@ -0,0 +1,43 @@ +comment: + layout: "header, diff, flags, files" # show flag info in the PR comment +flag_management: + default_rules: # default rules that will be inherited by all flags + statuses: + - type: project # in this case every flag that doens't have a status defined will have a project type + target: auto + threshold: 5% + branches: + - master + individual_flags: + - name: backend-apis # only Golang backend APIs + paths: + - "webv2/**" + - "!webv2/webCmd.go" + statuses: # each component has its own status and corresponding configuration + - type: project + target: auto + - name: backend-library # only library code + paths: + - "!webv2/**" + - "!ui/**" + - "!cmd/**" + statuses: # each component has its own status and corresponding configuration + - type: project + target: auto + - name: cli # only the CLI + paths: + - "cmd/**" + - "webv2/webCmd.go" + statuses: # each component has its own status and corresponding configuration + - type: project + target: auto + - name: frontend # only frontend components + paths: + - ui/** + statuses: # the core component has its own statuses + - type: project + target: auto +ignore: + - ".docker" + - ".github" + - "docs" diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml index c09ea2332f..5bb596a97a 100644 --- a/.github/workflows/test-coverage.yaml +++ b/.github/workflows/test-coverage.yaml @@ -17,33 +17,37 @@ on: branches: - master pull_request: -name: code-coverage-check +name: code-coverage-check jobs: coverage: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/setup-go@v2 - with: - go-version: '1.19' + - uses: actions/checkout@v3 + - uses: actions/setup-go@v2 + with: + go-version: "1.19" - - name: Unit tests - run: | - go test ./... -coverprofile coverage.out -covermode count - go tool cover -func coverage.out + - name: Unit tests + run: | + go test ./... -coverprofile coverage.out -covermode count + go tool cover -func coverage.out - - name: Quality Gate - Test coverage should be above threshold - env: + - name: Quality Gate - Test coverage should be above threshold + env: TESTCOVERAGE_THRESHOLD: 50 - run: | - echo "Quality Gate: checking if 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 + run: | + echo "Quality Gate: checking if 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 + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v3 + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}