From 6c047959e814116a3a1dc74dfe7d1188e54bf41e Mon Sep 17 00:00:00 2001 From: Viacheslav Poturaev Date: Mon, 20 Jan 2025 13:17:54 +0100 Subject: [PATCH 1/2] Update actions --- .github/workflows/cloc.yml | 4 +- README.md | 2 +- makefiles/base.mk | 2 +- scripts/lint.sh | 2 +- templates/github/workflows/bench.yml | 91 +++++++------------ templates/github/workflows/cloc.yml | 4 +- templates/github/workflows/golangci-lint.yml | 10 +- templates/github/workflows/gorelease.yml | 20 +--- templates/github/workflows/release-assets.yml | 18 +--- .../github/workflows/test-integration.yml | 22 ++--- templates/github/workflows/test-unit.yml | 29 ++---- 11 files changed, 69 insertions(+), 135 deletions(-) diff --git a/.github/workflows/cloc.yml b/.github/workflows/cloc.yml index 619ca74..70bd18b 100644 --- a/.github/workflows/cloc.yml +++ b/.github/workflows/cloc.yml @@ -13,11 +13,11 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: path: pr - name: Checkout base code - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: ref: ${{ github.event.pull_request.base.sha }} path: base diff --git a/README.md b/README.md index daa6a29..9bfacb0 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ import _ "github.com/bool64/dev" // Include development helpers to project. Add `Makefile` to your module with includes standard targets. ```Makefile -#GOLANGCI_LINT_VERSION := "v1.61.0" # Optional configuration to pinpoint golangci-lint version. +#GOLANGCI_LINT_VERSION := "v1.63.4" # Optional configuration to pinpoint golangci-lint version. # The head of Makefile determines location of dev-go to include standard targets. GO ?= go diff --git a/makefiles/base.mk b/makefiles/base.mk index d1ea9ce..f22bfa4 100644 --- a/makefiles/base.mk +++ b/makefiles/base.mk @@ -1,4 +1,4 @@ -#GOLANGCI_LINT_VERSION := "v1.61.0" # Optional configuration to pinpoint golangci-lint version. +#GOLANGCI_LINT_VERSION := "v1.63.4" # Optional configuration to pinpoint golangci-lint version. # The head of Makefile determines location of dev-go to include standard targets. GO ?= go diff --git a/scripts/lint.sh b/scripts/lint.sh index 332ad41..b71254d 100755 --- a/scripts/lint.sh +++ b/scripts/lint.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash [ -z "$GO" ] && GO=go -[ -z "$GOLANGCI_LINT_VERSION" ] && GOLANGCI_LINT_VERSION="v1.61.0" +[ -z "$GOLANGCI_LINT_VERSION" ] && GOLANGCI_LINT_VERSION="v1.63.4" # detecting GOPATH and removing trailing "/" if any GOPATH="$(go env GOPATH)" diff --git a/templates/github/workflows/bench.yml b/templates/github/workflows/bench.yml index a97f7e7..ef52f43 100644 --- a/templates/github/workflows/bench.yml +++ b/templates/github/workflows/bench.yml @@ -12,43 +12,27 @@ on: description: 'New Ref' required: true -# Cancel the workflow in progress in newer build is about to start. -concurrency: - group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} - cancel-in-progress: true - env: GO111MODULE: "on" CACHE_BENCHMARK: "off" # Enables benchmark result reuse between runs, may skew latency results. RUN_BASE_BENCHMARK: "on" # Runs benchmark for PR base in case benchmark result is missing. - GO_VERSION: 1.23.x jobs: bench: + strategy: + matrix: + go-version: [ stable ] runs-on: ubuntu-latest steps: - - name: Install Go stable - if: env.GO_VERSION != 'tip' - uses: actions/setup-go@v4 + - name: Install Go + uses: actions/setup-go@v5 with: - go-version: ${{ env.GO_VERSION }} - - - name: Install Go tip - if: env.GO_VERSION == 'tip' - run: | - curl -sL https://storage.googleapis.com/go-build-snap/go/linux-amd64/$(git ls-remote https://github.com/golang/go.git HEAD | awk '{print $1;}').tar.gz -o gotip.tar.gz - ls -lah gotip.tar.gz - mkdir -p ~/sdk/gotip - tar -C ~/sdk/gotip -xzf gotip.tar.gz - ~/sdk/gotip/bin/go version - echo "PATH=$HOME/go/bin:$HOME/sdk/gotip/bin/:$PATH" >> $GITHUB_ENV - + go-version: ${{ matrix.go-version }} - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: ref: ${{ (github.event.inputs.new != '') && github.event.inputs.new || github.event.ref }} - - name: Go cache - uses: actions/cache@v3 + uses: actions/cache@v4 with: # In order: # * Module download cache @@ -59,58 +43,49 @@ jobs: key: ${{ runner.os }}-go-cache-${{ hashFiles('**/go.sum') }} restore-keys: | ${{ runner.os }}-go-cache - - name: Restore benchstat - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/go/bin/benchstat - key: ${{ runner.os }}-benchstat-legacy - + key: ${{ runner.os }}-benchstat - name: Restore base benchmark result - id: base-benchmark if: env.CACHE_BENCHMARK == 'on' - uses: actions/cache@v3 + id: benchmark-base + uses: actions/cache@v4 with: path: | bench-master.txt bench-main.txt # Use base sha for PR or new commit hash for master/main push in benchmark result key. key: ${{ runner.os }}-bench-${{ (github.event.pull_request.base.sha != github.event.after) && github.event.pull_request.base.sha || github.event.after }} - - - name: Run benchmark - run: | - export REF_NAME=new - make bench - OUTPUT=$(make bench-stat-diff) - echo "${OUTPUT}" - echo "diff<> $GITHUB_OUTPUT && echo "$OUTPUT" >> $GITHUB_OUTPUT && echo "EOF" >> $GITHUB_OUTPUT - OUTPUT=$(make bench-stat) - echo "${OUTPUT}" - echo "result<> $GITHUB_OUTPUT && echo "$OUTPUT" >> $GITHUB_OUTPUT && echo "EOF" >> $GITHUB_OUTPUT - - - name: Run benchmark for base code - if: env.RUN_BASE_BENCHMARK == 'on' && steps.base-benchmark.outputs.cache-hit != 'true' && (github.event.pull_request.base.sha != '' || github.event.inputs.old != '') + - name: Checkout base code + if: env.RUN_BASE_BENCHMARK == 'on' && steps.benchmark-base.outputs.cache-hit != 'true' && (github.event.pull_request.base.sha != '' || github.event.inputs.old != '') + uses: actions/checkout@v4 + with: + ref: ${{ (github.event.pull_request.base.sha != '' ) && github.event.pull_request.base.sha || github.event.inputs.old }} + path: __base + - name: Run base benchmark + if: env.RUN_BASE_BENCHMARK == 'on' && steps.benchmark-base.outputs.cache-hit != 'true' && (github.event.pull_request.base.sha != '' || github.event.inputs.old != '') run: | - git fetch origin master ${{ github.event.pull_request.base.sha }} - HEAD=$(git rev-parse HEAD) - git reset --hard ${{ github.event.pull_request.base.sha }} export REF_NAME=master - make bench-run bench-stat - git reset --hard $HEAD - - - name: Benchmark stats + cd __base + make | grep bench-run && (BENCH_COUNT=5 make bench-run bench-stat && cp bench-master.txt ../bench-master.txt) || echo "No benchmarks in base" + - name: Benchmark id: bench run: | export REF_NAME=new + BENCH_COUNT=5 make bench OUTPUT=$(make bench-stat-diff) - echo "${OUTPUT}" - echo "diff<> $GITHUB_OUTPUT && echo "$OUTPUT" >> $GITHUB_OUTPUT && echo "EOF" >> $GITHUB_OUTPUT + OUTPUT="${OUTPUT//'%'/'%25'}" + OUTPUT="${OUTPUT//$'\n'/'%0A'}" + OUTPUT="${OUTPUT//$'\r'/'%0D'}" + echo "::set-output name=diff::$OUTPUT" OUTPUT=$(make bench-stat) - echo "${OUTPUT}" - echo "result<> $GITHUB_OUTPUT && echo "$OUTPUT" >> $GITHUB_OUTPUT && echo "EOF" >> $GITHUB_OUTPUT - - - name: Comment benchmark result - continue-on-error: true + OUTPUT="${OUTPUT//'%'/'%25'}" + OUTPUT="${OUTPUT//$'\n'/'%0A'}" + OUTPUT="${OUTPUT//$'\r'/'%0D'}" + echo "::set-output name=result::$OUTPUT" + - name: Comment Benchmark Result uses: marocchino/sticky-pull-request-comment@v2 with: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/templates/github/workflows/cloc.yml b/templates/github/workflows/cloc.yml index 3f1fc19..e0c3825 100644 --- a/templates/github/workflows/cloc.yml +++ b/templates/github/workflows/cloc.yml @@ -13,11 +13,11 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: path: pr - name: Checkout base code - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: ref: ${{ github.event.pull_request.base.sha }} path: base diff --git a/templates/github/workflows/golangci-lint.yml b/templates/github/workflows/golangci-lint.yml index 9acf314..ae2c76d 100644 --- a/templates/github/workflows/golangci-lint.yml +++ b/templates/github/workflows/golangci-lint.yml @@ -19,15 +19,15 @@ jobs: name: golangci-lint runs-on: ubuntu-latest steps: - - uses: actions/setup-go@v3 + - uses: actions/setup-go@v5 with: - go-version: 1.23.x - - uses: actions/checkout@v2 + go-version: stable + - uses: actions/checkout@v4 - name: golangci-lint - uses: golangci/golangci-lint-action@v6.1.0 + uses: golangci/golangci-lint-action@v6.2.0 with: # Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version. - version: v1.61.0 + version: v1.63.4 # Optional: working directory, useful for monorepos # working-directory: somedir diff --git a/templates/github/workflows/gorelease.yml b/templates/github/workflows/gorelease.yml index c031db4..531f975 100644 --- a/templates/github/workflows/gorelease.yml +++ b/templates/github/workflows/gorelease.yml @@ -9,29 +9,19 @@ concurrency: cancel-in-progress: true env: - GO_VERSION: 1.23.x + GO_VERSION: stable jobs: gorelease: runs-on: ubuntu-latest steps: - - name: Install Go stable - if: env.GO_VERSION != 'tip' - uses: actions/setup-go@v4 + - name: Install Go + uses: actions/setup-go@v5 with: go-version: ${{ env.GO_VERSION }} - - name: Install Go tip - if: env.GO_VERSION == 'tip' - run: | - curl -sL https://storage.googleapis.com/go-build-snap/go/linux-amd64/$(git ls-remote https://github.com/golang/go.git HEAD | awk '{print $1;}').tar.gz -o gotip.tar.gz - ls -lah gotip.tar.gz - mkdir -p ~/sdk/gotip - tar -C ~/sdk/gotip -xzf gotip.tar.gz - ~/sdk/gotip/bin/go version - echo "PATH=$HOME/go/bin:$HOME/sdk/gotip/bin/:$PATH" >> $GITHUB_ENV - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Gorelease cache - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: | ~/go/bin/gorelease diff --git a/templates/github/workflows/release-assets.yml b/templates/github/workflows/release-assets.yml index 2686396..6a3e1b9 100644 --- a/templates/github/workflows/release-assets.yml +++ b/templates/github/workflows/release-assets.yml @@ -8,28 +8,18 @@ on: - created env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GO_VERSION: 1.23.x + GO_VERSION: stable jobs: build: name: Upload Release Assets runs-on: ubuntu-latest steps: - - name: Install Go stable - if: env.GO_VERSION != 'tip' - uses: actions/setup-go@v4 + - name: Install Go + uses: actions/setup-go@v5 with: go-version: ${{ env.GO_VERSION }} - - name: Install Go tip - if: env.GO_VERSION == 'tip' - run: | - curl -sL https://storage.googleapis.com/go-build-snap/go/linux-amd64/$(git ls-remote https://github.com/golang/go.git HEAD | awk '{print $1;}').tar.gz -o gotip.tar.gz - ls -lah gotip.tar.gz - mkdir -p ~/sdk/gotip - tar -C ~/sdk/gotip -xzf gotip.tar.gz - ~/sdk/gotip/bin/go version - echo "PATH=$HOME/go/bin:$HOME/sdk/gotip/bin/:$PATH" >> $GITHUB_ENV - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Build artifacts run: | make release-assets diff --git a/templates/github/workflows/test-integration.yml b/templates/github/workflows/test-integration.yml index 62028b0..514ed4c 100644 --- a/templates/github/workflows/test-integration.yml +++ b/templates/github/workflows/test-integration.yml @@ -16,32 +16,22 @@ env: GO111MODULE: "on" RUN_BASE_COVERAGE: "on" # Runs test for PR base in case base test coverage is missing. DOCKER_COMPOSE_FILE: ./docker-compose.yml - GO_VERSION: 1.23.x + GO_VERSION: stable TARGET_DELTA_COV: 90 # Target coverage of changed lines, in percents jobs: test: runs-on: ubuntu-latest steps: - - name: Install Go stable - if: env.GO_VERSION != 'tip' - uses: actions/setup-go@v4 + - name: Install Go + uses: actions/setup-go@v5 with: go-version: ${{ env.GO_VERSION }} - - name: Install Go tip - if: env.GO_VERSION == 'tip' - run: | - curl -sL https://storage.googleapis.com/go-build-snap/go/linux-amd64/$(git ls-remote https://github.com/golang/go.git HEAD | awk '{print $1;}').tar.gz -o gotip.tar.gz - ls -lah gotip.tar.gz - mkdir -p ~/sdk/gotip - tar -C ~/sdk/gotip -xzf gotip.tar.gz - ~/sdk/gotip/bin/go version - echo "PATH=$HOME/go/bin:$HOME/sdk/gotip/bin/:$PATH" >> $GITHUB_ENV - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Go cache - uses: actions/cache@v3 + uses: actions/cache@v4 with: # In order: # * Module download cache @@ -56,7 +46,7 @@ jobs: - name: Restore base test coverage id: base-coverage if: github.event.pull_request.base.sha != '' - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: | integration-base.txt diff --git a/templates/github/workflows/test-unit.yml b/templates/github/workflows/test-unit.yml index 41ae308..a91bfee 100644 --- a/templates/github/workflows/test-unit.yml +++ b/templates/github/workflows/test-unit.yml @@ -15,36 +15,25 @@ concurrency: env: GO111MODULE: "on" RUN_BASE_COVERAGE: "on" # Runs test for PR base in case base test coverage is missing. - COV_GO_VERSION: 1.22.x # Version of Go to collect coverage + COV_GO_VERSION: stable # Version of Go to collect coverage TARGET_DELTA_COV: 90 # Target coverage of changed lines, in percents jobs: test: strategy: matrix: - go-version: [ 1.21.x, 1.22.x, 1.23.x ] + go-version: [ stable, oldstable ] runs-on: ubuntu-latest steps: - - name: Install Go stable - if: matrix.go-version != 'tip' - uses: actions/setup-go@v4 + - name: Install Go + uses: actions/setup-go@v5 with: go-version: ${{ matrix.go-version }} - - name: Install Go tip - if: matrix.go-version == 'tip' - run: | - curl -sL https://storage.googleapis.com/go-build-snap/go/linux-amd64/$(git ls-remote https://github.com/golang/go.git HEAD | awk '{print $1;}').tar.gz -o gotip.tar.gz - ls -lah gotip.tar.gz - mkdir -p ~/sdk/gotip - tar -C ~/sdk/gotip -xzf gotip.tar.gz - ~/sdk/gotip/bin/go version - echo "PATH=$HOME/go/bin:$HOME/sdk/gotip/bin/:$PATH" >> $GITHUB_ENV - - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Go cache - uses: actions/cache@v3 + uses: actions/cache@v4 with: # In order: # * Module download cache @@ -59,7 +48,7 @@ jobs: - name: Restore base test coverage id: base-coverage if: matrix.go-version == env.COV_GO_VERSION && github.event.pull_request.base.sha != '' - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: | unit-base.txt @@ -130,7 +119,7 @@ jobs: - name: Upload code coverage if: matrix.go-version == env.COV_GO_VERSION - uses: codecov/codecov-action@v1 + uses: codecov/codecov-action@v5 with: - file: ./unit.coverprofile + files: ./unit.coverprofile flags: unittests From b3c0b6ac1209e78055f90e0e6937941f86f5a572 Mon Sep 17 00:00:00 2001 From: Viacheslav Poturaev Date: Mon, 20 Jan 2025 16:54:29 +0100 Subject: [PATCH 2/2] Remove deprecated linters --- scripts/.golangci.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/.golangci.yml b/scripts/.golangci.yml index 690c24c..2b9cd73 100644 --- a/scripts/.golangci.yml +++ b/scripts/.golangci.yml @@ -22,7 +22,6 @@ linters: disable: - lll - gochecknoglobals - - gomnd - wrapcheck - paralleltest - forbidigo @@ -40,12 +39,12 @@ linters: - execinquery - mnd - testifylint + - recvcheck issues: exclude-use-default: false exclude-rules: - linters: - - gomnd - mnd - goconst - noctx