Skip to content

Commit

Permalink
fix: add unit test coverage
Browse files Browse the repository at this point in the history
Signed-off-by: Shubharanshu Mahapatra <[email protected]>
  • Loading branch information
Shubhranshu153 committed Nov 1, 2024
1 parent 9c72ad1 commit 0cc6d86
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci-docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ on:
- '!.github/workflows/e2e-macos.yaml'
- '!.github/workflows/e2e-windows.yaml'
- '!.github/workflows/e2e-linux.yaml'
- '!.github/workflows/ci.yaml'
pull_request:
branches:
- main
Expand All @@ -39,6 +40,7 @@ on:
- '!.github/workflows/e2e-macos.yaml'
- '!.github/workflows/e2e-windows.yaml'
- '!.github/workflows/e2e-linux.yaml'
- '!.github/workflows/ci.yaml'

jobs:
git-secrets:
Expand Down
10 changes: 10 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,16 @@ jobs:
go-version-file: go.mod
cache: false
- run: make test-unit
- run:
go test -cover -coverprofile="coverage.out" ./cmd/... ./pkg/...
COVERAGE=$(go tool cover -func=coverage.out | awk '/total:/ {print substr($3, 1, length($3)-1)}')
THRESHOLD=75
if [ "$(printf "%.0f" "$COVERAGE")" -lt "$THRESHOLD" ]; then
echo "Coverage $COVERAGE% is below $THRESHOLD% threshold"
exit 1
else
echo "Coverage is $COVERAGE%, which meets the threshold"
fi
# It's recommended to run golangci-lint in a job separate from other jobs (go test, etc) because different jobs run in parallel.
go-linter:
name: lint
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/e2e-linux.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ jobs:
- name: Check repo out manually
if: ${{ (startsWith(inputs.os, 'amazon') && inputs.version == '2' ) }}
run: |
echo Hello
git clone https://github.com/${GITHUB_REPOSITORY}.git .
if [ "$GITHUB_EVENT_NAME" == "pull_request" ]; then
git config --add remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
Expand Down

0 comments on commit 0cc6d86

Please sign in to comment.