diff --git a/.github/workflows/reusable-testing.yml b/.github/workflows/reusable-testing.yml new file mode 100644 index 00000000..0174f925 --- /dev/null +++ b/.github/workflows/reusable-testing.yml @@ -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 diff --git a/.github/workflows/tag-and-release.yml b/.github/workflows/tag-and-release.yml index 27a11abf..704f637a 100644 --- a/.github/workflows/tag-and-release.yml +++ b/.github/workflows/tag-and-release.yml @@ -1,4 +1,4 @@ -name: Create new Git tag +name: Test and maybe create a new release on: push: @@ -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: diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index bac829eb..6fa307f4 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -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