Skip to content

Commit

Permalink
ci: fix ci lint
Browse files Browse the repository at this point in the history
  • Loading branch information
jianggb committed Jun 4, 2024
1 parent 5ce9f58 commit 25817e0
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 37 deletions.
32 changes: 17 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ name: Tests
on:
push:
paths-ignore:
- '**.md'
- "**.md"
pull_request:
paths-ignore:
- '**.md'
- "**.md"

env:
GO111MODULE: on
Expand All @@ -18,17 +18,18 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
go-version: ["1.15.x", "1.16.x"]
os: [ubuntu-latest, macos-latest, windows-latest]
go-version: ["1.22.x"]
os: [ubuntu-latest, windows-latest, macos-latest]

steps:
- name: Set up Go ${{ matrix.go-version }}
uses: actions/setup-go@v2
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
cache: false

- name: Check out code into the Go module directory
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Print Go environment
id: vars
Expand All @@ -40,26 +41,27 @@ jobs:
printf "\n\nSystem environment:\n\n"
env
# Calculate the short SHA1 hash of the git commit
echo "::set-output name=short_sha::$(git rev-parse --short HEAD)"
echo "::set-output name=go_cache::$(go env GOCACHE)"
echo "short_sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
echo "go_cache=$(go env GOCACHE)" >> $GITHUB_OUTPUT
- name: Cache go modules
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: |
${{ steps.vars.outputs.go_cache }}
${{ steps.vars.outputs.GO_CACHE }}
~/go/pkg/mod
key: ${{ runner.os }}-${{ matrix.go-version }}-go-ci-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-${{ matrix.go-version }}-go-ci
${{ runner.os }}-${{ matrix.go-version }}-go-ci-
- name: Unit test
run: |
cd thinkgos && go test -v -race -coverprofile=coverage -covermode=atomic ./...
go test -v -race -coverprofile=coverage -covermode=atomic ./...
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
uses: codecov/codecov-action@v4
with:
files: ./thinkgos/coverage
files: ./coverage
flags: unittests
verbose: true
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true
24 changes: 16 additions & 8 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,42 @@ name: CodeQL
on:
push:
paths-ignore:
- '**.md'
- "**.md"
pull_request:
paths-ignore:
- '**.md'
- "**.md"
schedule:
- cron: '0 5 * * 6'
- cron: "0 5 * * 6"

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
# We must fetch at least the immediate parents so that if this is
# a pull request then we can checkout the head.
fetch-depth: 2

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.22.x"
cache: false
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
uses: github/codeql-action/init@v3

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1
uses: github/codeql-action/autobuild@v3

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
Expand All @@ -44,4 +52,4 @@ jobs:
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
uses: github/codeql-action/analyze@v3
20 changes: 13 additions & 7 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,21 @@ name: Lint
on:
push:
paths-ignore:
- '**.md'
- "**.md"

jobs:
golangci:
name: Golangci-Lint
golang-ci:
name: GolangCi-Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v2
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
args: -E goimports -E gocritic -E misspell -E revive
go-version: "1.22.x"
cache: false
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v6
with: # BUG: typecheck error when enable all
args: --disable-all -E goimports,misspell,whitespace
version: latest
15 changes: 8 additions & 7 deletions .github/workflows/pr_review_dog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Reviewdog
on:
pull_request:
paths-ignore:
- '**.md'
- "**.md"

jobs:
golangci-lint:
Expand All @@ -12,14 +12,15 @@ jobs:
steps:
# optionally use a specific version of Go rather than the default one
- name: Set up Go
uses: actions/setup-go@v2
uses: actions/setup-go@v5
with:
go-version: '1.16.x'
go-version: "1.22.x"

- name: Check out code into the Go module directory
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: golangci-lint
uses: reviewdog/action-golangci-lint@v1
with:
golangci_lint_flags: "-E goimports -E gocritic -E misspell -E revive"
uses: reviewdog/action-golangci-lint@v2
with: # BUG: typecheck error when enable all
args: --disable-all -E goimports,misspell,whitespace
version: latest

0 comments on commit 25817e0

Please sign in to comment.