Skip to content

Commit

Permalink
Add reusable Github action for testing (#855)
Browse files Browse the repository at this point in the history
* Add reusable Github action for testing
  • Loading branch information
LandonTClipp authored Nov 26, 2024
1 parent 971ce32 commit 3a3fb6e
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 30 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/reusable-testing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Reusable Go Test

on:
workflow_call:

jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: ["macos-latest", "ubuntu-latest"]
go_vers: ["1.22", "1.23"]
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go_vers }}

- name: Download dependencies
run: go mod download -x

- name: Test
run: go run github.com/go-task/task/v3/cmd/task test.ci
5 changes: 4 additions & 1 deletion .github/workflows/tag-and-release.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Create new Git tag
name: Test and maybe create a new release

on:
push:
Expand All @@ -7,8 +7,11 @@ on:
permissions:
contents: write
jobs:
test:
uses: ./.github/workflows/reusable-testing.yml
tag:
runs-on: ubuntu-latest
needs: test
outputs:
tag_result: ${{ steps.tag.outputs.tag_result }}
steps:
Expand Down
31 changes: 2 additions & 29 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,10 @@
name: Go Test

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ macos-latest, ubuntu-latest]
go_vers: ['1.22', '1.23']
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go_vers }}

- name: Download dependencies
run: go mod download -x

- name: Test
run: go run github.com/go-task/task/v3/cmd/task test.ci
test:
uses: ./.github/workflows/reusable-testing.yml

- name: Upload coverage to codecov
uses: codecov/codecov-action@v2
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.txt
verbose: true

0 comments on commit 3a3fb6e

Please sign in to comment.