Skip to content

Commit

Permalink
CI
Browse files Browse the repository at this point in the history
  • Loading branch information
benbjohnson committed Mar 15, 2024
1 parent e90a41e commit 3dfb6b2
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 0 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Checks

on:
workflow_dispatch:
pull_request:
push:
branches: [master]

permissions:
contents: read
pull-requests: read

concurrency:
group: ${{ github.workflow }}-$${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
precommit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: "go.mod"
check-latest: true
- uses: pre-commit/action@v3.0.1
with:
extra_args: --all-files --hook-stage=manual

lint:
strategy:
fail-fast: false
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: "go.mod"
- uses: golangci/golangci-lint-action@v4
with:
version: v1.54
working-directory: .
skip-pkg-cache: true
19 changes: 19 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Test

on:
workflow_dispatch:
pull_request:
push:
branches: [master]

jobs:
test:
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-go@v5
with:
go-version-file: "go.mod"
- name: Run Tests
run: go test -v ./...
24 changes: 24 additions & 0 deletions .pre-commit-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files

- repo: https://github.com/tekwizely/pre-commit-golang
rev: v1.0.0-rc.1
hooks:
- id: go-mod-tidy

# NOTE: This pre-commit hook is ignored when running on Github Workflow
# because goalngci-lint github action is much more useful than the pre-commit action.
# The trick is to run github action only for "manual" hook stage
- repo: https://github.com/golangci/golangci-lint
rev: v1.54.2
hooks:
- id: golangci-lint
stages: [commit]

0 comments on commit 3dfb6b2

Please sign in to comment.