Skip to content

Commit

Permalink
Merge pull request #38 from Kochava/codecov
Browse files Browse the repository at this point in the history
add code coverage to pull requests and main golang workflows
  • Loading branch information
otternq authored Oct 24, 2024
2 parents 7c5cf55 + 1f63a56 commit a4e0ba3
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 2 deletions.
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

0 comments on commit a4e0ba3

Please sign in to comment.