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

Fix: Use a tj-actions for reporting go coverage #42

Merged
merged 7 commits into from
Jan 22, 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
64 changes: 29 additions & 35 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
@@ -1,43 +1,17 @@
name: Unit-Test

on:
push:
branches:
- main
workflow_dispatch: { }
pull_request:
branches:
- main

permissions:
contents: write

jobs:

detect-noop:
permissions:
actions: write # for fkirc/skip-duplicate-actions to skip or stop workflow runs
runs-on: ubuntu-22.04
outputs:
noop: ${{ steps.noop.outputs.should_skip }}
steps:
- name: Detect No-op Changes
id: noop
uses: fkirc/skip-duplicate-actions@f75f66ce1886f00957d99748a42c724f4330bdcf
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
paths_ignore: '["**.md", "**.mdx", "**.png", "**.jpg"]'
do_not_skip: '["workflow_dispatch", "schedule", "push"]'
continue-on-error: true

unit-tests:
runs-on: ubuntu-22.04
needs: detect-noop
permissions:
contents: write
pull_requests: write
actions: write
if: needs.detect-noop.outputs.noop != 'true'

steps:
- name: Set up Go
Expand All @@ -46,7 +20,11 @@ jobs:
go-version: '1.21'

- name: Check out code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
persist-credentials: false
fetch-depth: 0


- name: Install ginkgo
run: |
Expand All @@ -55,12 +33,28 @@ jobs:
- name: Run Make test
run: make test

- name: Update coverage report
uses: ncruces/go-coverage-report@v0
- name: Go Coverage Badge # Pass the `coverage.out` output to this action
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
if: steps.verify-changed-files.outputs.files_changed == 'true'
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:
report: true
chart: true
amend: true
if: |
github.event_name == 'push'
continue-on-error: true
github_token: ${{ github.token }}
branch: ${{ github.head_ref }}
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ cross-compile:
test:
@echo "Testing..."
@ginkgo -r
@ginkgo -r $(TEST_FLAGS) -cover -covermode=count
echo 'mode: count' > coverage.out
find . -name "*.coverprofile" | xargs -I{} tail -q -n +2 {} >> coverage.out
find . -name "*.coverprofile" | xargs -I{} rm {}

docker-build-local: cross-compile
@echo "Building Local Docker image..."
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/Guidewire/fern-reporter/badge)](https://securityscorecards.dev/viewer/?uri=github.com/Guidewire/fern-reporter)
[![Go Coverage](https://github.com/Guidewire/fern-reporter/wiki/coverage.svg)](https://raw.githack.com/wiki/Guidewire/fern-reporter/coverage.html)
![Coverage](https://img.shields.io/badge/Coverage-count-red)

![Fern](https://github.com/guidewire/fern-reporter/raw/main/docs/images/logo-no-background.png)

Expand Down
Loading