Skip to content

Code Checks

Code Checks #24

Workflow file for this run

name: Code Checks
on:
push:
branches:
- '*'
pull_request:
branches:
- main
schedule:
- cron: '0 10 * * 1'
workflow_call:
inputs:
skipTests:
description: 'Skip tests, useful when there is a dedicated CI job for tests'
default: false
required: false
type: boolean
jobs:
test:
name: Go Test
timeout-minutes: 4
strategy:
fail-fast: true
matrix:
go: ['1.21.x']
os: ['ubuntu-20.04']
runs-on: ${{ matrix.os }}
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go }}
check-latest: true
- name: Test
if: ${{ !inputs.skipTests }}
run: go test -v -count=1 -race -shuffle=on -coverprofile=coverage.txt ./...
- name: Benchmark
if: ${{ !inputs.skipTests }}
run: go test -v -shuffle=on -run=- -bench=. -benchtime=1x ./...
check:
name: Go Code Checks
timeout-minutes: 2
strategy:
fail-fast: true
matrix:
go: ['1.21.x']
os: ['ubuntu-20.04']
runs-on: ${{ matrix.os }}
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go }}
check-latest: true
- name: Go Format
run: gofmt -s -w . && git diff --exit-code
- name: Go Vet
run: go vet ./...
- name: Go Tidy
run: go mod tidy && git diff --exit-code
- name: Go Mod
run: go mod download
- name: Go Mod Verify
run: go mod verify
- name: Go Generate
run: go generate ./... && git diff --exit-code
build:
name: Go Build
timeout-minutes: 2
strategy:
fail-fast: true
matrix:
go: ['1.21.x']
os: ['ubuntu-20.04']
runs-on: ${{ matrix.os }}
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go }}
check-latest: true
- name: Go Build
run: go build -o /dev/null ./...