-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
53 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
name: Unit test-case | ||
|
||
on: | ||
push: | ||
paths-ignore: | ||
- '**.md' | ||
- 'charts/**' | ||
branches: | ||
- 'main' | ||
|
||
|
||
jobs: | ||
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 | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters