From 11ca27dd15273c539856293a0c4c24c95c5ea8b2 Mon Sep 17 00:00:00 2001 From: Hariharan Subramanian <105889062+hsubramanianaks@users.noreply.github.com> Date: Fri, 28 Jul 2023 15:54:47 -0400 Subject: [PATCH] Add gocover checks for PR's (#74) --- .github/workflows/pr-validate-fork.yaml | 12 +-------- .github/workflows/pr-validate.yaml | 5 +--- .github/workflows/unit.yaml | 34 ++++++++++--------------- README.md | 2 ++ 4 files changed, 18 insertions(+), 35 deletions(-) diff --git a/.github/workflows/pr-validate-fork.yaml b/.github/workflows/pr-validate-fork.yaml index a4497bab..b74efec7 100644 --- a/.github/workflows/pr-validate-fork.yaml +++ b/.github/workflows/pr-validate-fork.yaml @@ -50,21 +50,11 @@ jobs: ref: 'refs/pull/${{ github.event.client_payload.pull_request.number }}/merge' skipRefCheck: false secrets: inherit - unit: - needs: setup - if: - github.event_name == 'repository_dispatch' && - github.event.client_payload.slash_command.args.named.sha != '' && - contains(github.event.client_payload.pull_request.head.sha, github.event.client_payload.slash_command.args.named.sha) - uses: ./.github/workflows/unit.yaml - with: - ref: 'refs/pull/${{ github.event.client_payload.pull_request.number }}/merge' - skipRefCheck: false status: permissions: checks: write pull-requests: read - needs: [e2e, unit] + needs: [e2e] runs-on: ubuntu-latest if: ${{ always() }} steps: diff --git a/.github/workflows/pr-validate.yaml b/.github/workflows/pr-validate.yaml index a8330489..8eebe58a 100644 --- a/.github/workflows/pr-validate.yaml +++ b/.github/workflows/pr-validate.yaml @@ -13,14 +13,11 @@ jobs: if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository uses: ./.github/workflows/e2e.yaml secrets: inherit - unit: - if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository - uses: ./.github/workflows/unit.yaml status: permissions: checks: write pull-requests: read - needs: [e2e, unit] + needs: [e2e] runs-on: ubuntu-latest steps: - name: Update status diff --git a/.github/workflows/unit.yaml b/.github/workflows/unit.yaml index 7f8fd948..f1909a9d 100644 --- a/.github/workflows/unit.yaml +++ b/.github/workflows/unit.yaml @@ -1,37 +1,31 @@ name: Unit Tests on: - workflow_call: - inputs: - ref: - type: string - skipRefCheck: - type: boolean - default: true + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] jobs: unit-test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - with: - ref: ${{ inputs.ref }} - name: Set up Go - uses: actions/setup-go@v2 + uses: actions/setup-go@v3 with: go-version: ~1.20.0 - name: Run Unit Tests - if: - (github.event_name == 'repository_dispatch' && - github.event.client_payload.slash_command.args.named.sha != '' && - contains(github.event.client_payload.pull_request.head.sha, github.event.client_payload.slash_command.args.named.sha)) || - inputs.skipRefCheck - run: go test -race -v ./... + run: go test -race -v ./... -coverprofile=coverage.out + + - name: Convert coverage to lcov + uses: jandelgado/gcov2lcov-action@c680c0f7c7442485f1749eb2a13e54a686e76eb5 #v1.0.8 - - name: Ensure ref - uses: actions/github-script@v6 - if: ${{ !((github.event_name == 'repository_dispatch' && github.event.client_payload.slash_command.args.named.sha != '' && contains(github.event.client_payload.pull_request.head.sha, github.event.client_payload.slash_command.args.named.sha)) || inputs.skipRefCheck) }} + - name: Coveralls + uses: coverallsapp/github-action@95b1a2355bd0e526ad2fd62da9fd386ad4c98474 #v2.2.1 with: - script: core.setFailed('Ref is not latest') + flag-name: unit-test + path-to-lcov: coverage.lcov + diff --git a/README.md b/README.md index 477168fc..68b2f547 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # AKS Web Application Routing Operator +[![Coverage Status](https://coveralls.io/repos/github/Azure/aks-app-routing-operator/badge.svg?branch=main)](https://coveralls.io/github/Azure/aks-app-routing-operator?branch=main) + A Kubernetes operator that manages resources related to AKS Application Routing functionality. ## Docs