[actions] rethink testing workflow

This commit is contained in:
Aleksandr Soloshenko 2025-09-11 11:14:06 +07:00 committed by Aleksandr
parent abbd9a2cd6
commit f24a9ee2d4
3 changed files with 118 additions and 75 deletions

View File

@ -7,28 +7,6 @@ permissions:
contents: read contents: read
jobs: jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
# step 1: checkout repository code
- name: Checkout code into workspace directory
uses: actions/checkout@v4
# step 2: set up go
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: stable
# step 3: install dependencies
- name: Install all Go dependencies
run: go mod download
# step 4: run test
- name: Run coverage
run: go test -race -coverprofile=coverage.out -covermode=atomic ./...
e2e: e2e:
name: E2E name: E2E
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -65,7 +43,6 @@ jobs:
contents: read contents: read
packages: write packages: write
needs: needs:
- test
- e2e - e2e
if: github.actor != 'dependabot[bot]' if: github.actor != 'dependabot[bot]'
uses: ./.github/workflows/docker-build.yml uses: ./.github/workflows/docker-build.yml

118
.github/workflows/go.yml vendored Normal file
View File

@ -0,0 +1,118 @@
name: Go
permissions:
contents: read
on:
workflow_dispatch:
push:
branches: [master]
paths:
- "**.go"
- "go.mod"
- "go.sum"
pull_request:
branches: [master]
paths:
- "**.go"
- "go.mod"
- "go.sum"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
golangci:
name: Lint
runs-on: ubuntu-latest
steps:
# step 1: checkout repository code
- name: Checkout code into workspace directory
uses: actions/checkout@v4
# step 2: set up go
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: stable
# step 3: run golangci-lint
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v8
with:
version: latest
args: --timeout=5m
test:
name: Test
runs-on: ubuntu-latest
steps:
# step 1: checkout repository code
- name: Checkout code into workspace directory
uses: actions/checkout@v4
# step 2: set up go
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: stable
# step 3: install dependencies
- name: Install all Go dependencies
run: go mod download
# step 4: run test
- name: Run coverage
run: go test -race -shuffle=on -covermode=atomic -coverpkg=./... -coverprofile=coverage.out ./...
# step 5: upload coverage
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
benchmark:
name: Benchmark
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
# step 1: checkout repository code
- name: Checkout code into workspace directory
uses: actions/checkout@v4
# step 2: set up go
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: stable
# step 3: install dependencies
- name: Install all Go dependencies
run: go mod download
# step 4: run benchmark
- name: Run benchmarks
run: go test -bench=. -benchmem ./... | tee benchmark.txt
# step 5: download previous benchmark result from cache (if exists)
- name: Download previous benchmark data
uses: actions/cache@v4
with:
path: ./cache
key: ${{ runner.os }}-benchmark
# step 6: upload benchmark
- name: Upload benchmark results
uses: benchmark-action/github-action-benchmark@v1
with:
# What benchmark tool the benchmark.txt came from
tool: "go"
# Where the output from the benchmark tool is stored
output-file-path: benchmark.txt
# Where the previous data file is stored
external-data-json-path: ./cache/benchmark-data.json
# Workflow will fail when an alert happens
fail-on-alert: true

View File

@ -1,52 +0,0 @@
name: golangci-lint
on:
pull_request:
permissions:
contents: read
# Optional: allow read access to pull request. Use with `only-new-issues` option.
# pull-requests: read
jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v5
with:
go-version: stable
cache: false
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
# Require: The version of golangci-lint to use.
# When `install-mode` is `binary` (default) the value can be v1.2 or v1.2.3 or `latest` to use the latest version.
# When `install-mode` is `goinstall` the value can be v1.2.3, `latest`, or the hash of a commit.
version: latest
# Optional: working directory, useful for monorepos
# working-directory: somedir
# Optional: golangci-lint command line arguments.
#
# Note: By default, the `.golangci.yml` file should be at the root of the repository.
# The location of the configuration file can be changed by using `--config=`
# args: --timeout=30m --config=/my/path/.golangci.yml --issues-exit-code=0
args: --timeout=5m
# Optional: show only new issues if it's a pull request. The default value is `false`.
# only-new-issues: true
# Optional: if set to true, then all caching functionality will be completely disabled,
# takes precedence over all other caching options.
# skip-cache: true
# Optional: if set to true, then the action won't cache or restore ~/go/pkg.
# skip-pkg-cache: true
# Optional: if set to true, then the action won't cache or restore ~/.cache/go-build.
# skip-build-cache: true
# Optional: The mode to install golangci-lint. It can be 'binary' or 'goinstall'.
# install-mode: "goinstall"