Skip to content

Commit

Permalink
ci: add action (#136)
Browse files Browse the repository at this point in the history
自动对导入排序
lint和test分别使用多个go版本以测试兼容性
  • Loading branch information
Redmomn authored Feb 5, 2025
1 parent 4e57de8 commit 5d76d30
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 2 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
on:
push:
branches:
- 'master'
paths:
- '**.go'
- 'go.mod'
- '**.yml'

name: ci

env:
GO111MODULE: on

jobs:
ci:
runs-on: ubuntu-latest

concurrency:
group: ${{ github.ref }}
cancel-in-progress: true

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install Go
uses: actions/setup-go@v5
with:
go-version: '1.20'
cache: false

- name: Sort Imports
run: |
export PATH="$PATH:$GOPATH/bin"
go install github.com/incu6us/goimports-reviser@latest
pwd
find . -name "*.go" | xargs -I {} goimports-reviser -file-path {} -project-name "github.com/LagraneDev/LagrangeGo"
- name: GolangCI-Lint
uses: golangci/golangci-lint-action@v6
with:
version: 'v1.61.0'
args: '--timeout 9999s'
only-new-issues: true
skip-save-cache: true

- name: commit back
run: |
git config --local user.name 'github-actions[bot]'
git config --local user.email '41898282+github-actions[bot]@users.noreply.github.com'
git add .
git commit -m "ci(chore): Fix stylings"
git push
15 changes: 13 additions & 2 deletions .github/workflows/test_and_lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,40 @@ env:
jobs:
test:
runs-on: ubuntu-latest

strategy:
matrix:
go-version: [ '1.20', '1.21', '1.22', '1.23' ]

steps:
- name: Code
uses: actions/checkout@v4

- name: Install Go
uses: actions/setup-go@v5
with:
go-version: '^1.23'
go-version: ${{ matrix.go-version }}
cache: false
- run: go get
- run: go test -v -race ./...

lint:
runs-on: ubuntu-latest

strategy:
matrix:
go-version: [ '1.20', '1.21', '1.22', '1.23' ]

steps:
- name: Code
uses: actions/checkout@v4

- name: Install Go
uses: actions/setup-go@v5
with:
go-version: '^1.23'
go-version: ${{ matrix.go-version }}
cache: false

- run: go get

- name: Go vet
Expand Down

0 comments on commit 5d76d30

Please sign in to comment.