mirror of
https://github.com/makayabou/asg-server.git
synced 2026-05-02 17:43:36 +02:00
119 lines
2.9 KiB
YAML
119 lines
2.9 KiB
YAML
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
|