Skip to content

Commit

Permalink
Merge pull request #1 from patrickdeangelis/chore/add-test-coverage
Browse files Browse the repository at this point in the history
chore: add test coverage
  • Loading branch information
patrickdeangelis authored May 4, 2024
2 parents 421adc4 + 6d33019 commit 89bb281
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 4 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/coverage_report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go

name: Coverage Report

on:
workflow_run:
workflows: ["Test lint and build"]
branches: [main]
types:
- completed

jobs:

workflow:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
persist-credentials: false
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.22'
cache: false

- uses: extractions/setup-just@v1

- name: Go Coverage Badge
uses: tj-actions/coverage-badge-go@v2
with:
filename: coverage.out

- name: Verify Changed files
uses: tj-actions/verify-changed-files@v16
id: verify-changed-files
with:
files: README.md

- name: Commit changes
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add README.md
git commit -m "chore: Updated coverage badge."
- name: Push changes
if: steps.verify-changed-files.outputs.files_changed == 'true'
uses: ad-m/github-push-action@master
with:
github_token: ${{ github.token }}
branch: ${{ github.head_ref }}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go

name: Go
name: Test lint and build

on:
push:
Expand All @@ -15,6 +15,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
persist-credentials: false
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v4
Expand All @@ -24,14 +27,19 @@ jobs:

- uses: extractions/setup-just@v1

- name: Test
run: just test

- name: Lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.57.2
args: --out-format=colored-line-number -v ./...

- name: Test
run: just test-ci

- name: Go Coverage Badge
uses: tj-actions/coverage-badge-go@v2
with:
filename: coverage.out

- name: Build
run: go build -v ./...
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
coverage.out

playground/
4 changes: 4 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ test:
test-all:
go test -tags=integration ./...

# run test generating coverage
test-ci:
go test -v ./... -covermode=count -coverprofile=coverage.out & go tool cover -func=coverage.out -o=coverage.out

# lint the code
lint:
golangci-lint run -v ./...
Expand Down

0 comments on commit 89bb281

Please sign in to comment.