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

Add reusable Github action for testing #855

Merged
merged 4 commits into from
Nov 26, 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
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