Skip to content
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 code coverage to pull requests and main golang workflows #38

Merged
merged 2 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .github/workflows/go_app_pull_requests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,11 @@ jobs:
# Run unit test for evet Go module.
- name: go test
run: find . -name vendor -prune -o -name go.mod -print | xargs -n1 dirname
| xargs -n1 -I{} bash -c "pushd {}; go test --race -v ./..."
| xargs -n1 -I{} bash -c "pushd {}; go test -coverprofile=coverage.txt --race -v ./..."
- name: Upload test coverage results to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
docker-build:
#
# ensures the docker image will build without pushing to the registry
Expand Down
38 changes: 38 additions & 0 deletions .github/workflows/go_app_push_main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,49 @@ on:
required: true

jobs:
test:
#
# ensure go standards and tests pass
#
runs-on: ubuntu-latest
strategy:
matrix:
# List of go versions to test on.
go: ['^1']
steps:
# Checkout go code to test.
- name: Checkout repo
uses: actions/checkout@v3
# Setup Go for each version in the matrix.
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go }}
# Use auth to get access to private Git repos for Go code dependencies.
- name: Configure git for private modules
env:
TOKEN: ${{ secrets.GH_CI_PAT }}
GITHUB_USERNAME: ${{ inputs.GH_CI_USER }}
run: git config --global url."https://${GITHUB_USERNAME}:${TOKEN}@github.com".insteadOf
"https://github.com"
# Go vet every Go module.
- name: go vet
run: find . -name vendor -prune -o -name go.mod -print | xargs -n1 dirname
| xargs -n1 -I{} bash -c "pushd {}; go vet ./..."
# Run unit test for evet Go module.
- name: go test
run: find . -name vendor -prune -o -name go.mod -print | xargs -n1 dirname
| xargs -n1 -I{} bash -c "pushd {}; go test -coverprofile=coverage.txt --race -v ./..."
- name: Upload test coverage results to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
release:
#
# Create a GitHub Release based on conventional commits.
#
name: 'Release to GitHub'
# needs: test
runs-on: ubuntu-latest
steps:
# Checkout code to release.
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/go_lib_pull_requests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,8 @@ jobs:
- name: go test
run:
find . -name vendor -prune -o -name go.mod -print | xargs -n1 dirname
| xargs -n1 -I{} bash -c "pushd {}; go test --race -v ./..."
| xargs -n1 -I{} bash -c "pushd {}; go test -coverprofile=coverage.txt --race -v ./..."
- name: Upload test coverage results to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
41 changes: 41 additions & 0 deletions .github/workflows/go_lib_push_main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,52 @@ on:
required: true

jobs:
test:
#
# ensure go standards and tests pass
#
runs-on: ubuntu-latest
strategy:
matrix:
# List of go versions to test on.
go: ["^1"]
steps:
# Checkout go code to test.
- name: Checkout repo
uses: actions/checkout@v3
# Setup Go for each version in the matrix.
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go }}
# Use auth to get access to private Git repos for Go code dependencies.
- name: Configure git for private modules
env:
TOKEN: ${{ secrets.GH_CI_PAT }}
GITHUB_USERNAME: ${{ inputs.GH_CI_USER }}
run:
git config --global url."https://${GITHUB_USERNAME}:${TOKEN}@github.com".insteadOf
"https://github.com"
# Go vet every Go module.
- name: go vet
run:
find . -name vendor -prune -o -name go.mod -print | xargs -n1 dirname
| xargs -n1 -I{} bash -c "pushd {}; go vet ./..."
# Run unit test for evet Go module.
- name: go test
run:
find . -name vendor -prune -o -name go.mod -print | xargs -n1 dirname
| xargs -n1 -I{} bash -c "pushd {}; go test -coverprofile=coverage.txt --race -v ./..."
- name: Upload test coverage results to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
release:
#
# Create a GitHub Release based on conventional commits.
#
name: 'Release to GitHub'
# needs: test
runs-on: ubuntu-latest
steps:
# Checkout code to release.
Expand Down