Skip to content

Commit

Permalink
feat: reusable coverage workflow
Browse files Browse the repository at this point in the history
Signed-off-by: Carlos Alexandro Becker <[email protected]>
  • Loading branch information
caarlos0 committed Feb 1, 2024
1 parent 58b8cdb commit b830752
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 3 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
go_version:
required: false
type: string
default: ^1
default: stable
secrets:
gh_pat:
required: false
Expand All @@ -31,7 +31,6 @@ jobs:
build:
strategy:
matrix:
go-version: ["${{ inputs.go_version }}"]
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
env:
Expand All @@ -46,7 +45,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
go-version: ${{ inputs.go_version }}
cache: true
- name: Download Go modules
run: go mod download
Expand Down
38 changes: 38 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: build

on:
workflow_call:
inputs:
go_version:
required: false
type: string
default: stable
test_timeout:
required: false
type: string
default: 5m
secrets:
gh_pat:
required: false

jobs:
coverage:
runs-on: ubuntu-latest
env:
GH_PAT: ${{ secrets.gh_pat }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- run: |
git config --global url."https://${{ secrets.gh_pat }}@github.com/charmbracelet".insteadOf "https://github.com/charmbracelet"
if: env.GH_PAT != null
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: ${{ inputs.go_version }}
cache: true
- name: Test
run: go test -failfast -race -coverpkg=./... -covermode=atomic -coverprofile=coverage.txt ./... -timeout ${{ inputs.test_timeout }}
- uses: codecov/codecov-action@v4
with:
file: ./coverage.txt

0 comments on commit b830752

Please sign in to comment.