Skip to content

CTHL-5402: coverage #16

CTHL-5402: coverage

CTHL-5402: coverage #16

Workflow file for this run

name: Generate code coverage badge
on:
pull_request:
branches: [ master ]
jobs:
test:
runs-on: ubuntu-latest
env:
GOPATH: ${{ github.workspace }}
name: Update coverage badge
defaults:
run:
working-directory: ${{ env.GOPATH }}/src/github.com/${{ github.repository }}
steps:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.25.5
- uses: actions/checkout@v2
with:
path: ${{ env.GOPATH }}/src/github.com/${{ github.repository }}
persist-credentials: false
fetch-depth: 0
# - name: Checkout
# uses: actions/checkout@v4
# with:
# persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal access token.
# fetch-depth: 0 # otherwise, there would be errors pushing refs to the destination repository.
#
# - name: Setup go
# uses: actions/setup-go@v4
# with:
# go-version-file: 'go.mod'
- name: Install dependencies
run: make install-dependencies
- name: Install tools
run: make install-tools
- name: Run Test
run: |
make test-verbose-with-coverage-for-budge
- name: Debug coverage file
run: |
echo "Current directory:"
pwd
echo "Files in directory:"
ls -la
echo "Looking for coverage files:"
find . -name "coverage.out" 2>/dev/null || echo "No coverage.out files found"
- name: Copy coverage file to root
run: |
cp coverage.out ${{ github.workspace }} || echo "Failed to copy coverage.out"
ls -la ${{ github.workspace }}/coverage.out
- name: Go Coverage Badge # Pass the `coverage.out` output to this action
uses: tj-actions/coverage-badge-go@v3
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 "action@github.com"
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 }}