-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add test coverage GH action #59
Open
efiacor
wants to merge
11
commits into
nephio-project:main
Choose a base branch
from
Nordix:add_coverage_gh_action
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
1644410
Add test coverage GH action
efiacor 5af9420
Update token for badge push
efiacor 8937953
Add more permissions on gh action
efiacor ea1d283
Lower the pass threshold to 40%
efiacor a3c1fba
Update .github/workflows/porch-go-covergae.yaml
efiacor e042372
Update .github/workflows/porch-go-covergae.yaml
efiacor 4043906
Update porch-go-covergae.yaml
efiacor 373dc50
Update .github/workflows/porch-go-covergae.yaml
efiacor c0e3001
Update .github/workflows/porch-go-covergae.yaml
efiacor e5bb05f
Update .github/workflows/porch-go-covergae.yaml
efiacor 37d8933
Update porch-go-covergae.yaml
efiacor File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,64 @@ | ||
# Copyright 2024 The Nephio Authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
# (mandatory) | ||
# Path to coverprofile file (output of `go test -coverprofile` command). | ||
# | ||
# For cases where there are many coverage profiles, such as when running | ||
# unit tests and integration tests separately, you can combine all those | ||
# profiles into one. In this case, the profile should have a comma-separated list | ||
# of profile files, e.g., 'cover_unit.out,cover_integration.out'. | ||
profile: lcov.info | ||
|
||
# (optional; but recommended to set) | ||
# When specified reported file paths will not contain local prefix in the output | ||
local-prefix: "github.com/nephio-project/porch" | ||
|
||
# Holds coverage thresholds percentages, values should be in range [0-100] | ||
threshold: | ||
# (optional; default 0) | ||
# The minimum coverage that each file should have | ||
file: 0 | ||
|
||
# (optional; default 0) | ||
# The minimum coverage that each package should have | ||
package: 0 | ||
|
||
# (optional; default 0) | ||
# The minimum total coverage project should have | ||
total: 40 | ||
|
||
# Holds regexp rules which will override thresholds for matched files or packages | ||
# using their paths. | ||
# | ||
# First rule from this list that matches file or package is going to apply | ||
# new threshold to it. If project has multiple rules that match same path, | ||
# override rules should be listed in order from specific to more general rules. | ||
override: | ||
# # Increase coverage threshold to 100% for `foo` package | ||
# # (default is 80, as configured above in this example) | ||
# - threshold: 100 | ||
# path: ^pkg/lib/foo$ | ||
|
||
# Holds regexp rules which will exclude matched files or packages | ||
# from coverage statistics | ||
exclude: | ||
# # Exclude files or packages matching their paths | ||
# paths: | ||
# - \.pb\.go$ # excludes all protobuf generated files | ||
# - ^pkg/bar # exclude package `pkg/bar` | ||
|
||
# NOTES: | ||
# - symbol `/` in all path regexps will be replaced by current OS file path separator | ||
# to properly work on Windows |
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,59 @@ | ||
# Copyright 2024 The Nephio Authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
name: "Go test coverage" | ||
on: | ||
push: | ||
paths-ignore: | ||
- "build/**" | ||
- "deployments/**" | ||
- "docs/**" | ||
- "examples/**" | ||
- "release/**" | ||
- "scripts/**" | ||
pull_request: | ||
paths-ignore: | ||
- "build/**" | ||
- "deployments/**" | ||
- "docs/**" | ||
- "examples/**" | ||
- "release/**" | ||
- "scripts/**" | ||
|
||
jobs: | ||
coverage: | ||
name: Go test coverage check | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: checkout repo | ||
uses: actions/checkout@v4 | ||
- uses: actions/create-github-app-token@v1 | ||
id: generate-token | ||
with: | ||
app-id: 897412 | ||
private-key: ${{ secrets.HELPER_APP_KEY }} | ||
- name: setup go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: '1.22.2' | ||
|
||
- name: generate test coverage | ||
run: make test | ||
|
||
- name: check test coverage | ||
uses: vladopajic/go-test-coverage@v2 | ||
with: | ||
# Configure action using config file (option 1) | ||
config: ./.github/.testcoverage.yaml | ||
git-branch: badges | ||
git-token: ${{ steps.generate-token.outputs.token }} |
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Copyright 2023 The Nephio Authors. | ||
# Copyright 2023-2024 The Nephio Authors. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
|
@@ -14,6 +14,7 @@ | |
|
||
GO_VERSION ?= 1.22.2 | ||
TEST_COVERAGE_FILE=lcov.info | ||
TEST_COVERAGE_TMP_FILE=lcov.tmp.info | ||
TEST_COVERAGE_HTML_FILE=coverage_unit.html | ||
TEST_COVERAGE_FUNC_FILE=func_coverage.out | ||
GIT_ROOT_DIR ?= $(dir $(lastword $(MAKEFILE_LIST))) | ||
|
@@ -26,13 +27,15 @@ unit: test | |
test: ## Run unit tests (go test) | ||
ifeq ($(CONTAINER_RUNNABLE), 0) | ||
$(RUN_CONTAINER_COMMAND) docker.io/nephio/gotests:1782782171367346176 \ | ||
sh -e -c "git config --global --add user.name test; \ | ||
git config --global --add user.email [email protected]; \ | ||
go test ./... -v -coverprofile ${TEST_COVERAGE_FILE}; \ | ||
go tool cover -html=${TEST_COVERAGE_FILE} -o ${TEST_COVERAGE_HTML_FILE}; \ | ||
go tool cover -func=${TEST_COVERAGE_FILE} -o ${TEST_COVERAGE_FUNC_FILE}" | ||
sh -e -c "git config --global --add user.name test; \ | ||
git config --global --add user.email [email protected]; \ | ||
go test ./... -v -covermode=atomic -coverpkg=./... -coverprofile ${TEST_COVERAGE_TMP_FILE}; \ | ||
cat ${TEST_COVERAGE_TMP_FILE} | grep -v 'test\|api' > ${TEST_COVERAGE_FILE}; \ | ||
go tool cover -html=${TEST_COVERAGE_FILE} -o ${TEST_COVERAGE_HTML_FILE}; \ | ||
go tool cover -func=${TEST_COVERAGE_FILE} -o ${TEST_COVERAGE_FUNC_FILE}" | ||
else | ||
go test ./... -v -coverprofile ${TEST_COVERAGE_FILE} | ||
go test ./... -v -covermode=atomic -coverpkg=./... -coverprofile ${TEST_COVERAGE_TMP_FILE}; \ | ||
cat ${TEST_COVERAGE_TMP_FILE} | grep -v 'test\|api' > ${TEST_COVERAGE_FILE}; \ | ||
go tool cover -html=${TEST_COVERAGE_FILE} -o ${TEST_COVERAGE_HTML_FILE} | ||
go tool cover -func=${TEST_COVERAGE_FILE} -o ${TEST_COVERAGE_FUNC_FILE} | ||
endif | ||
|
@@ -42,4 +45,4 @@ unit-clean: ## Clean up the artifacts created by the unit tests | |
ifeq ($(CONTAINER_RUNNABLE), 0) | ||
$(CONTAINER_RUNTIME) system prune -f | ||
endif | ||
rm -f ${TEST_COVERAGE_FILE} ${TEST_COVERAGE_HTML_FILE} ${TEST_COVERAGE_FUNC_FILE} > /dev/null 2>&1 | ||
rm -f ${TEST_COVERAGE_TMP_FILE} ${TEST_COVERAGE_FILE} ${TEST_COVERAGE_HTML_FILE} ${TEST_COVERAGE_FUNC_FILE} > /dev/null 2>&1 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo in filename