From 3dfb6b2e6d503fcc18fbdd88e84028ae92a57c5d Mon Sep 17 00:00:00 2001 From: Ben Johnson Date: Fri, 15 Mar 2024 13:16:10 -0600 Subject: [PATCH] CI --- .github/workflows/checks.yml | 44 ++++++++++++++++++++++++++++++++++++ .github/workflows/test.yml | 19 ++++++++++++++++ .pre-commit-config.yml | 24 ++++++++++++++++++++ 3 files changed, 87 insertions(+) create mode 100644 .github/workflows/checks.yml create mode 100644 .github/workflows/test.yml create mode 100644 .pre-commit-config.yml diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml new file mode 100644 index 0000000..8f8e858 --- /dev/null +++ b/.github/workflows/checks.yml @@ -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 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..0eae54b --- /dev/null +++ b/.github/workflows/test.yml @@ -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 ./... diff --git a/.pre-commit-config.yml b/.pre-commit-config.yml new file mode 100644 index 0000000..c66aa20 --- /dev/null +++ b/.pre-commit-config.yml @@ -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]