From 486b5d80ada287adae008bf31f9e5932ef0dcfcd Mon Sep 17 00:00:00 2001 From: alanjino Date: Thu, 20 Jun 2024 22:08:02 +0530 Subject: [PATCH] unit-testcase execution in pr build --- .github/workflows/agent-container-pr.yml | 33 ------------------------ .github/workflows/agent-kubviz-pr.yml | 32 +++++++++++++++++++++++ 2 files changed, 32 insertions(+), 33 deletions(-) diff --git a/.github/workflows/agent-container-pr.yml b/.github/workflows/agent-container-pr.yml index cfec6621..ea98ed0f 100644 --- a/.github/workflows/agent-container-pr.yml +++ b/.github/workflows/agent-container-pr.yml @@ -48,36 +48,3 @@ jobs: tags: ${{ env.REGISTRY }}/${{ github.repository }}/container-agent:pr-${{ github.event.pull_request.number }} build-args: | "GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}" - - test_and_coverage: - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v3 - - - name: Set up Go - uses: actions/setup-go@v5 - with: - go-version: 1.22 - - - name: Run tests with coverage - run: | - go test -coverprofile=coverage.out -covermode=count "./agent/kubviz/plugins/ketall" "./agent/kubviz/plugins/kubescore" "./agent/kubviz/plugins/kuberhealthy" "./agent/kubviz/plugins/outdated" "./agent/kubviz/plugins/rakkess" "./agent/kubviz/plugins/trivy" - go tool cover -func=coverage.out - - - name: Upload coverage report - uses: actions/upload-artifact@v2 - with: - name: coverage-report - path: report/cover.out - - - name: Analyze coverage - run: | - coverage=$(go tool cover -func=report/cover.out | grep total | awk '{print $3}' | sed 's/%//') - if [ $(echo "$coverage < 60" | bc) -eq 1 ]; then - echo "Coverage is below 60% threshold: $coverage%" - exit 1 - else - echo "Coverage is above 60% threshold: $coverage%" - fi \ No newline at end of file diff --git a/.github/workflows/agent-kubviz-pr.yml b/.github/workflows/agent-kubviz-pr.yml index 3aca320e..4ff8b026 100644 --- a/.github/workflows/agent-kubviz-pr.yml +++ b/.github/workflows/agent-kubviz-pr.yml @@ -47,4 +47,36 @@ jobs: tags: ${{ env.REGISTRY }}/${{ github.repository }}/kubviz-agent:pr-${{ github.event.pull_request.number }} build-args: | "GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}" + + test_and_coverage: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: 1.22 + + - name: Run tests with coverage + run: | + go test -coverprofile=coverage.out -covermode=count "./agent/kubviz/plugins/ketall" "./agent/kubviz/plugins/kubescore" "./agent/kubviz/plugins/kuberhealthy" "./agent/kubviz/plugins/outdated" "./agent/kubviz/plugins/rakkess" "./agent/kubviz/plugins/trivy" + go tool cover -func=coverage.out + + - name: Upload coverage report + uses: actions/upload-artifact@v2 + with: + name: coverage-report + path: report/cover.out + - name: Analyze coverage + run: | + coverage=$(go tool cover -func=report/cover.out | grep total | awk '{print $3}' | sed 's/%//') + if [ $(echo "$coverage < 60" | bc) -eq 1 ]; then + echo "Coverage is below 60% threshold: $coverage%" + exit 1 + else + echo "Coverage is above 60% threshold: $coverage%" + fi