Skip to content

Add input to configure GitHub Actions workflow filename (#44) #90

Add input to configure GitHub Actions workflow filename (#44)

Add input to configure GitHub Actions workflow filename (#44) #90

Workflow file for this run

name: CI
on:
pull_request:
types: [opened, reopened, synchronize]
push:
branches:
- 'main'
env:
GO_VERSION: "^1.22"
jobs:
unit_tests:
name: "Unit tests"
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: Restore Go modules cache
uses: actions/cache@v4
with:
path: ~/go/pkg/mod
key: go-${{ runner.os }}-${{ hashFiles('go.mod') }}
restore-keys: |
go-${{ runner.os }}-
- name: Download dependencies
run: go mod download
- name: Test
run: go test -cover -coverprofile=coverage.txt -mod=readonly ./...
- name: Archive code coverage results
uses: actions/upload-artifact@v4
with:
name: code-coverage
path: coverage.txt
- name: Build
run: go build -v -mod=readonly ./...
code_coverage:
name: "Code coverage report"
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
needs: unit_tests
permissions:
# Grant permission to add comments to the PR.
pull-requests: write
steps:
# Normally,users of the action don't have to check out the source code or setup Go.
# We need this here however because we are using a local action.yml.
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- uses: ./
with:
version: local
trim: "github.com/fgrosse/go-coverage-report/"