Skip to content

Commit

Permalink
Add gocover checks for PR's (#74)
Browse files Browse the repository at this point in the history
  • Loading branch information
hsubramanianaks authored Jul 28, 2023
1 parent 5e28e4f commit 11ca27d
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 35 deletions.
12 changes: 1 addition & 11 deletions .github/workflows/pr-validate-fork.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/pr-validate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
34 changes: 14 additions & 20 deletions .github/workflows/unit.yaml
Original file line number Diff line number Diff line change
@@ -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

2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 11ca27d

Please sign in to comment.