From 3e34c9cea59d471090b39a6f08069aef18fe54fd Mon Sep 17 00:00:00 2001 From: Manit Gupta Date: Wed, 4 Oct 2023 14:52:05 +0530 Subject: [PATCH 1/9] code cov --- .github/workflows/test-coverage.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml index c09ea2332f..bdf8fe01fe 100644 --- a/.github/workflows/test-coverage.yaml +++ b/.github/workflows/test-coverage.yaml @@ -47,3 +47,7 @@ jobs: echo "Failed" exit 1 fi + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v3 + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} From 3fa59cf4ef05ae0738778183ffc7b12014ce6e6f Mon Sep 17 00:00:00 2001 From: Manit Gupta Date: Thu, 5 Oct 2023 11:29:33 +0530 Subject: [PATCH 2/9] code cov --- .github/workflows/test-coverage.yaml | 83 +++++++++++++++++++--------- 1 file changed, 57 insertions(+), 26 deletions(-) diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml index bdf8fe01fe..94e2062a26 100644 --- a/.github/workflows/test-coverage.yaml +++ b/.github/workflows/test-coverage.yaml @@ -17,37 +17,68 @@ 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 - - name: Upload coverage reports to Codecov - uses: codecov/codecov-action@v3 - env: + 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 }} + comment: + layout: "header, diff, components" # show component info in the PR comment + + component_management: + default_rules: # default rules that will be inherited by all components + statuses: + - type: project # in this case every component that doens't have a status defined will have a project type one + target: auto + base: auto + threshold: 50% + branches: + - master + individual_components: + - component_id: backend-apis # this is an identifier that should not be changed + name: backend-apis # this is a display name, and can be changed freely + paths: + - "webv2/**" + - component_id: backend-library + name: backend-library + paths: + - "!webv2/**" + - "!ui/**" + - component_id: frontend + name: frontend + paths: + - ui/** + statuses: # the core component has its own statuses + - type: project + target: auto + base: auto + threshold: 0% From bcc3eca881633e8ca80572683c2a4fddaa30ec13 Mon Sep 17 00:00:00 2001 From: Manit Gupta Date: Thu, 5 Oct 2023 11:38:20 +0530 Subject: [PATCH 3/9] fix code cov --- .github/codecov.yml | 30 +++++++++++++++++++++++++++ .github/workflows/test-coverage.yaml | 31 ---------------------------- 2 files changed, 30 insertions(+), 31 deletions(-) create mode 100644 .github/codecov.yml diff --git a/.github/codecov.yml b/.github/codecov.yml new file mode 100644 index 0000000000..baee11e591 --- /dev/null +++ b/.github/codecov.yml @@ -0,0 +1,30 @@ +comment: + layout: "header, diff, components" # show component info in the PR comment +component_management: + default_rules: # default rules that will be inherited by all components + statuses: + - type: project # in this case every component that doens't have a status defined will have a project type one + target: auto + base: auto + threshold: 50% + branches: + - master + individual_components: + - component_id: backend-apis # this is an identifier that should not be changed + name: backend-apis # this is a display name, and can be changed freely + paths: + - "webv2/**" + - component_id: backend-library + name: backend-library + paths: + - "!webv2/**" + - "!ui/**" + - component_id: frontend + name: frontend + paths: + - ui/** + statuses: # the core component has its own statuses + - type: project + target: auto + base: auto + threshold: 0% diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml index 94e2062a26..5bb596a97a 100644 --- a/.github/workflows/test-coverage.yaml +++ b/.github/workflows/test-coverage.yaml @@ -51,34 +51,3 @@ jobs: uses: codecov/codecov-action@v3 env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} - comment: - layout: "header, diff, components" # show component info in the PR comment - - component_management: - default_rules: # default rules that will be inherited by all components - statuses: - - type: project # in this case every component that doens't have a status defined will have a project type one - target: auto - base: auto - threshold: 50% - branches: - - master - individual_components: - - component_id: backend-apis # this is an identifier that should not be changed - name: backend-apis # this is a display name, and can be changed freely - paths: - - "webv2/**" - - component_id: backend-library - name: backend-library - paths: - - "!webv2/**" - - "!ui/**" - - component_id: frontend - name: frontend - paths: - - ui/** - statuses: # the core component has its own statuses - - type: project - target: auto - base: auto - threshold: 0% From 10a59cda5c349f1e2525acb3288a22d303707e4d Mon Sep 17 00:00:00 2001 From: Manit Gupta Date: Thu, 5 Oct 2023 11:46:10 +0530 Subject: [PATCH 4/9] fix code cov 2 --- .github/codecov.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/codecov.yml b/.github/codecov.yml index baee11e591..d78033ac90 100644 --- a/.github/codecov.yml +++ b/.github/codecov.yml @@ -6,7 +6,7 @@ component_management: - type: project # in this case every component that doens't have a status defined will have a project type one target: auto base: auto - threshold: 50% + threshold: 5% branches: - master individual_components: @@ -27,4 +27,3 @@ component_management: - type: project target: auto base: auto - threshold: 0% From c31249282d837e63a7a990537f21b6af6d524f8c Mon Sep 17 00:00:00 2001 From: Manit Gupta Date: Thu, 5 Oct 2023 11:49:28 +0530 Subject: [PATCH 5/9] remove base --- .github/codecov.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/codecov.yml b/.github/codecov.yml index d78033ac90..db83023469 100644 --- a/.github/codecov.yml +++ b/.github/codecov.yml @@ -5,7 +5,6 @@ component_management: statuses: - type: project # in this case every component that doens't have a status defined will have a project type one target: auto - base: auto threshold: 5% branches: - master @@ -14,11 +13,17 @@ component_management: name: backend-apis # this is a display name, and can be changed freely paths: - "webv2/**" + statuses: # the core component has its own statuses + - type: project + target: auto - component_id: backend-library name: backend-library paths: - "!webv2/**" - "!ui/**" + statuses: # the core component has its own statuses + - type: project + target: auto - component_id: frontend name: frontend paths: @@ -26,4 +31,3 @@ component_management: statuses: # the core component has its own statuses - type: project target: auto - base: auto From 26b16eca6a47a90af02201b031227d63428b7d6d Mon Sep 17 00:00:00 2001 From: Manit Gupta Date: Thu, 5 Oct 2023 11:59:55 +0530 Subject: [PATCH 6/9] final --- .github/codecov.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/codecov.yml b/.github/codecov.yml index db83023469..5b696c4dff 100644 --- a/.github/codecov.yml +++ b/.github/codecov.yml @@ -31,3 +31,7 @@ component_management: statuses: # the core component has its own statuses - type: project target: auto +ignore: + - ".docker" + - ".github" + - "docs" From e81b034864c61bd1ad1f9b29e9d1b4e766140aaa Mon Sep 17 00:00:00 2001 From: Manit Gupta Date: Thu, 5 Oct 2023 12:09:00 +0530 Subject: [PATCH 7/9] amend codecov yml --- .github/codecov.yml | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/.github/codecov.yml b/.github/codecov.yml index 5b696c4dff..352b01fd09 100644 --- a/.github/codecov.yml +++ b/.github/codecov.yml @@ -3,25 +3,35 @@ comment: component_management: default_rules: # default rules that will be inherited by all components statuses: - - type: project # in this case every component that doens't have a status defined will have a project type one + - type: project # in this case every component that doens't have a status defined will have a project type target: auto threshold: 5% branches: - master individual_components: - - component_id: backend-apis # this is an identifier that should not be changed - name: backend-apis # this is a display name, and can be changed freely + - component_id: backend-apis + name: backend-apis # only Golang backend APIs paths: - "webv2/**" - statuses: # the core component has its own statuses + - "!webv2/webCmd.go" + statuses: # each component has its own status and corresponding configuration - type: project target: auto - component_id: backend-library - name: backend-library + name: backend-library # only library code paths: - "!webv2/**" - "!ui/**" - statuses: # the core component has its own statuses + - "!cmd/**" + statuses: # each component has its own status and corresponding configuration + - type: project + target: auto + - component_id: cli + name: cli + paths: + - "cmd/**" + - "webv2/webCmd.go" + statuses: # each component has its own status and corresponding configuration - type: project target: auto - component_id: frontend From 3a96b876fbd44be7b5424688cf1cfd46ee08a9d1 Mon Sep 17 00:00:00 2001 From: Manit Gupta Date: Thu, 5 Oct 2023 12:14:36 +0530 Subject: [PATCH 8/9] amend codecov yml --- .github/codecov.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/codecov.yml b/.github/codecov.yml index 352b01fd09..a04dd7bede 100644 --- a/.github/codecov.yml +++ b/.github/codecov.yml @@ -1,5 +1,5 @@ comment: - layout: "header, diff, components" # show component info in the PR comment + layout: "header, diff, components, files" # show component info in the PR comment component_management: default_rules: # default rules that will be inherited by all components statuses: @@ -27,7 +27,7 @@ component_management: - type: project target: auto - component_id: cli - name: cli + name: cli # only the CLI paths: - "cmd/**" - "webv2/webCmd.go" @@ -35,7 +35,7 @@ component_management: - type: project target: auto - component_id: frontend - name: frontend + name: frontend # only frontend components paths: - ui/** statuses: # the core component has its own statuses From 325c70e6d8b2bce7dafafd88e69c45b3abdeaf5a Mon Sep 17 00:00:00 2001 From: Manit Gupta Date: Thu, 5 Oct 2023 14:08:39 +0530 Subject: [PATCH 9/9] switch to flags from components --- .github/codecov.yml | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/.github/codecov.yml b/.github/codecov.yml index a04dd7bede..838d86e912 100644 --- a/.github/codecov.yml +++ b/.github/codecov.yml @@ -1,24 +1,22 @@ comment: - layout: "header, diff, components, files" # show component info in the PR comment -component_management: - default_rules: # default rules that will be inherited by all components + 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 component that doens't have a status defined will have a project type + - 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_components: - - component_id: backend-apis - name: backend-apis # only Golang backend APIs + 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 - - component_id: backend-library - name: backend-library # only library code + - name: backend-library # only library code paths: - "!webv2/**" - "!ui/**" @@ -26,16 +24,14 @@ component_management: statuses: # each component has its own status and corresponding configuration - type: project target: auto - - component_id: cli - name: cli # only the CLI + - name: cli # only the CLI paths: - "cmd/**" - "webv2/webCmd.go" statuses: # each component has its own status and corresponding configuration - type: project target: auto - - component_id: frontend - name: frontend # only frontend components + - name: frontend # only frontend components paths: - ui/** statuses: # the core component has its own statuses