Skip to content

feat: Add GHA testing #5

feat: Add GHA testing

feat: Add GHA testing #5

Workflow file for this run

---
name: CI
on:
push:
branches: ["main"]
pull_request:
jobs:
yamllint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Run yamllint
uses: ibiqlik/action-yamllint@v3
with:
config_file: .yamllint.yml
file_or_dir: .
strict: true
markdownlint:
name: markdownlint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Run markdownlint-cli2
uses: DavidAnson/markdownlint-cli2-action@v23
with:
globs: "**/*.md"
golangci-lint:
name: golangci-lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-go@v6
with:
go-version-file: go.mod
# golangci-lint manages its own cache; disable setup-go's to avoid
# double-caching.
cache: false
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v9
with:
version: latest
args: --timeout 5m
tidy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Check go.mod is tidy
run: |
go mod tidy
if ! git diff --exit-code go.mod go.sum; then
echo "go.mod or go.sum is not tidy — run 'go mod tidy' and commit the result."
exit 1
fi
fmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-go@v6
with:
go-version-file: go.mod
cache: true
- name: Check formatting
run: |
unformatted=$(gofmt -l $(find . -name '*.go' -not -path './vendor/*'))
if [ -n "$unformatted" ]; then
echo "The following files are not gofmt-formatted:"
echo "$unformatted"
echo "Run 'gofmt -w .' to fix them."
exit 1
fi
vet:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-go@v6
with:
go-version-file: go.mod
cache: true
- name: Vet
run: go vet ./...
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-go@v6
with:
go-version-file: go.mod
cache: true
- name: Unit tests
run: go test -mod=vendor -race -count=1 -timeout 5m ./...
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-go@v6
with:
go-version-file: go.mod
cache: true
- name: Build
run: GO111MODULE=on CGO_ENABLED=0 GOARCH=amd64 GOOS=linux go build -mod=vendor -o bin/ ./