diff --git a/.github/workflows/pr-check.yml b/.github/workflows/pr-check.yml index ffa860b..15d2dea 100644 --- a/.github/workflows/pr-check.yml +++ b/.github/workflows/pr-check.yml @@ -4,9 +4,9 @@ on: [ pull_request ] jobs: compliant: - runs-on: [ self-hosted, X64 ] + runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Check License Header uses: apache/skywalking-eyes/header@v0.4.0 @@ -16,45 +16,21 @@ jobs: - name: Check Spell uses: crate-ci/typos@master - staticcheck: - runs-on: [ self-hosted, X64 ] - steps: - - uses: actions/checkout@v3 - - name: Set up Go - uses: actions/setup-go@v3 - with: - go-version: "1.22" - - - uses: actions/cache@v3 - with: - path: ~/go/pkg/mod - key: reviewdog-${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} - restore-keys: | - reviewdog-${{ runner.os }}-go- - - - uses: reviewdog/action-staticcheck@v1 - with: - github_token: ${{ secrets.github_token }} - # Change reviewdog reporter if you need [github-pr-check,github-check,github-pr-review]. - reporter: github-pr-review - # Report all results. - filter_mode: nofilter - # Exit with 1 when it find at least one finding. - fail_on_error: true - # Set staticcheck flags - staticcheck_flags: -checks=inherit,-SA1029 - lint: - runs-on: [ self-hosted, X64 ] + runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Go - uses: actions/setup-go@v3 + uses: actions/setup-go@v5 with: - go-version: "1.22" + go-version: stable + # For self-hosted, the cache path is shared across projects + # And it works well without the cache of GitHub actions + # Enable it if we're going to use GitHub only + cache: true - - name: Golangci Lint + - name: GolangCI Lint # https://golangci-lint.run/ - uses: golangci/golangci-lint-action@v3 + uses: golangci/golangci-lint-action@v6 with: version: latest diff --git a/.github/workflows/release-check.yml b/.github/workflows/release-check.yml deleted file mode 100644 index fb6cfcd..0000000 --- a/.github/workflows/release-check.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: Release Check - -on: - pull_request: - branches: - - main - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - - name: Check Source Branch - run: python2 -c "exit(0 if '${{ github.head_ref }}'.startswith('release') or '${{ github.head_ref }}'.startswith('hotfix') else 1)" - - - name: Check Version - run: | - # get version code, runner not support grep -E here - SOURCE_VERSION=`grep 'Version\s*=\s*\"v[0-9]\{1,\}\.[0-9]\{1,\}\.[0-9]\{1,\}\"' *.go | awk -F '\"' '{print $(NF-1)}'` - git checkout main - MASTER_VERSION=`grep 'Version\s*=\s*\"v[0-9]\{1,\}\.[0-9]\{1,\}\.[0-9]\{1,\}\"' *.go | awk -F '\"' '{print $(NF-1)}'` - git checkout ${{Head.SHA}} - # check version update - python2 -c "exit(0 if list(map(int,'${SOURCE_VERSION#v}'.split('.')[:3])) > list(map(int,'${MASTER_VERSION#v}'.split('.')[:3])) else 1)" diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 1b96ef5..7d73813 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -4,21 +4,31 @@ on: [ push, pull_request ] jobs: unit-benchmark-test: - strategy: - matrix: - go: [ "1.18", "1.19", "1.20", "1.21", "1.22" ] - os: [ X64 ] - runs-on: ${{ matrix.os }} + runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - + - uses: actions/checkout@v4 - name: Set up Go - uses: actions/setup-go@v3 + uses: actions/setup-go@v5 with: - go-version: ${{ matrix.go }} + go-version: stable - name: Unit Test - run: go test -race -covermode=atomic -coverprofile=coverage.out ./... + run: go test -race -coverprofile=coverage.out -covermode=atomic ./... - name: Benchmark run: go test -bench=. -benchmem -run=none ./... + + compatibility-test: + strategy: + matrix: + go: [ "1.19", oldstable ] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: ${{ matrix.go }} + cache: true # don't use cache for self-hosted runners + - name: Unit Test + run: go test -race -covermode=atomic ./... \ No newline at end of file diff --git a/.golangci.yaml b/.golangci.yaml index ec7a899..b4a4281 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -1,36 +1,27 @@ # Options for analysis running. run: - # include `vendor` `third_party` `testdata` `examples` `Godeps` `builtin` - skip-dirs-use-default: true - skip-dirs: - skip-files: - - ".*\\.mock\\.go$" -# output configuration options -output: - # Format: colored-line-number|line-number|json|tab|checkstyle|code-climate|junit-xml|github-actions - format: colored-line-number -# All available settings of specific linters. + timeout: 3m + # Refer to https://golangci-lint.run/usage/linters linters-settings: gofumpt: # Choose whether to use the extra rules. # Default: false extra-rules: true - govet: - # Disable analyzers by name. - # Run `go tool vet help` to see all analyzers. - disable: - - stdmethods + linters: + disable-all: true enable: - - gofumpt - - goimports - - gofmt - disable: - - errcheck - - typecheck - - deadcode - - varcheck + - gosimple + - govet + - ineffassign - staticcheck + - unused + - unconvert + - goimports + - gofumpt + issues: exclude-use-default: true + exclude-dirs: + - kitex_gen \ No newline at end of file diff --git a/_typos.toml b/_typos.toml index 47b5bea..dfd475b 100644 --- a/_typos.toml +++ b/_typos.toml @@ -1,4 +1,4 @@ # Typo check: https://github.com/crate-ci/typos [files] -extend-exclude = ["go.mod", "go.sum", "check_branch_name.sh"] +extend-exclude = ["go.mod", "go.sum"] diff --git a/check_branch_name.sh b/check_branch_name.sh deleted file mode 100755 index 1876fc0..0000000 --- a/check_branch_name.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env bash - -current=$(git status | head -n1 | sed 's/On branch //') -name=${1:-$current} -if [[ ! $name =~ ^(((opt(imize)?|feat(ure)?|(bug|hot)?fix|test|refact(or)?|ci)/.+)|(main|develop)|(release-v[0-9]+\.[0-9]+)|(release/v[0-9]+\.[0-9]+\.[0-9]+(-[a-z0-9.]+(\+[a-z0-9.]+)?)?)|revert-[a-z0-9]+)$ ]]; then - echo "branch name '$name' is invalid" - exit 1 -else - echo "branch name '$name' is valid" -fi