update github action trigger #9
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: golangci-lint | |
on: | |
push: | |
branches: | |
- main | |
- next/cicd | |
pull_request: | |
branches: | |
- main | |
- "release/*.*.*" | |
paths: | |
- "go.mod" | |
- "go.sum" | |
- "**.go" | |
env: | |
GO_VERSION: '1.23' | |
jobs: | |
lint-and-test: | |
# Only run if push to main or not previously run in a pull request | |
if: | | |
github.event_name == 'push' && | |
( | |
github.event.pull_request.head.repo.full_name != github.repository || | |
github.event.pull_request.merged != true | |
) || | |
github.event_name == 'pull_request' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Setup go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: ${{ env.GO_VERSION }} | |
check-latest: true | |
cache: false | |
# Cache Go modules to improve build time. | |
- name: Cache Go Modules | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cache/go-build | |
~/go/pkg/mod | |
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | |
restore-keys: | | |
${{ runner.os }}-go- | |
# Verify go.mod and go.sum are tidy. | |
- name: Verify go.mod is tidy | |
run: | | |
cd src | |
go mod tidy -go=${{ env.GO_VERSION }} | |
git diff --exit-code go.sum | |
git diff --exit-code go.mod | |
# Due to poor unit testing, we comment out it. | |
# | |
# Run unit tests. | |
# - name: Run unit tests | |
# run: | | |
# go test ./... -v -race -coverprofile=coverage.out | |
# env: | |
# GOFLAGS: "-mod=readonly" | |
# Upload code coverage report. | |
# - name: Upload Coverage Report | |
# uses: actions/upload-artifact@v3 | |
# with: | |
# name: coverage-report | |
# path: coverage.out | |
- name: golangci-lint | |
uses: golangci/golangci-lint-action@v6 | |
with: | |
version: v1.61.0 | |
args: --verbose --timeout=3m --config=../.golangci.yaml | |
skip-cache: true | |
working-directory: src |