Skip to content

Merge pull request #41 from gotd/dependabot/github_actions/golangci/g… #124

Merge pull request #41 from gotd/dependabot/github_actions/golangci/g…

Merge pull request #41 from gotd/dependabot/github_actions/golangci/g… #124

Workflow file for this run

---
name: CI
on:
push:
tags:
- v*
branches:
- main
pull_request:
jobs:
# Check if there any dirty change for go mod tidy
go-mod:
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: 1.18
- name: Checkout code
uses: actions/checkout@v4
- name: Check go mod
run: |
go mod tidy
git diff --exit-code go.mod
golangci-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: lint
uses: golangci/golangci-lint-action@v5.0.0
with:
version: latest
tests-on-windows:
needs: golangci-lint # run after golangci-lint action to not produce duplicated errors
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: 1.18 # test only the latest go version to speed up CI
- name: Run tests
run: go test ./...
continue-on-error: true
tests-on-macos:
needs: golangci-lint # run after golangci-lint action to not produce duplicated errors
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: 1.18 # test only the latest go version to speed up CI
- name: Run tests
run: make test
tests-on-unix:
needs: golangci-lint # run after golangci-lint action to not produce duplicated errors
runs-on: ubuntu-latest
strategy:
matrix:
golang:
- 1.18
steps:
- uses: actions/checkout@v4
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.golang }}
- uses: actions/cache@v4
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ matrix.golang }}-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-${{ matrix.golang }}-
- name: Run tests
run: make test
coverage:
runs-on: ubuntu-latest
timeout-minutes: 5
needs: [tests-on-unix]
steps:
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: 1.18
- name: Get Go environment
id: go-env
run: |
echo "::set-output name=cache::$(go env GOCACHE)"
echo "::set-output name=modcache::$(go env GOMODCACHE)"
- name: Set up cache
uses: actions/cache@v4
with:
path: |
${{ steps.go-env.outputs.cache }}
${{ steps.go-env.outputs.modcache }}
key: cover-${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
cover-${{ runner.os }}-go-
- name: Checkout code
uses: actions/checkout@v4
- name: Run tests with coverage
run: make coverage
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: coverage
path: coverage.out
if-no-files-found: error
retention-days: 1
- name: Send coverage
uses: codecov/codecov-action@v4
with:
file: coverage.out