Skip to content

[projects] introduce module #20

[projects] introduce module

[projects] introduce module #20

Workflow file for this run

name: Go
permissions:
contents: read
on:
workflow_dispatch:
push:
branches: [master]
paths:
- "**.go"
- "go.mod"
- "go.sum"
- ".golangci.yml"
pull_request:
branches: [master]
paths:
- "**.go"
- "go.mod"
- "go.sum"
- ".golangci.yml"
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@v6
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@v6
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 -count=1 -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
if: false
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@v6
with:
go-version: stable
# step 3: install dependencies
- name: Install all Go dependencies
run: go mod download
# step 4: restore previous benchmark history (if exists)
- name: Restore benchmark history
id: benchmark-cache
uses: actions/cache/restore@v4
with:
path: ./cache
key: ${{ runner.os }}-benchmark-${{ github.ref_name }}
restore-keys: |
${{ runner.os }}-benchmark-
# step 5: run benchmark
- name: Run benchmarks
run: go test -run=^$ -bench=. -benchmem ./... | tee benchmark.txt
# 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
# step 7: persist updated benchmark history
- name: Save benchmark history
if: always()
uses: actions/cache/save@v4
with:
path: ./cache
key: ${{ runner.os }}-benchmark-${{ github.ref_name }}-${{ github.run_id }}
e2e-test:
name: E2E Test
runs-on: ubuntu-latest
if: false
needs: test
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@v6
with:
go-version: stable
# step 3: install main project dependencies
- name: Install main Go dependencies
run: go mod download
# step 4: install e2e test dependencies
- name: Install E2E test dependencies
run: cd tests/e2e && go mod download
# step 5: run e2e tests with verbose output
- name: Run E2E tests
run: cd tests/e2e && go test -v ./...