Add pre-commit linting, test all PRs (#541)

This commit is contained in:
Toni Spets
2023-12-15 21:49:29 +02:00
committed by GitHub
parent 25ac72ae6c
commit 1a96ad4389
12 changed files with 75 additions and 26 deletions

View File

@@ -15,4 +15,3 @@ If you find mistakes in the documentation, please submit a fix to the
[new-issue]: https://github.com/benbjohnson/litestream/issues/new [new-issue]: https://github.com/benbjohnson/litestream/issues/new
[docs]: https://github.com/benbjohnson/litestream.io [docs]: https://github.com/benbjohnson/litestream.io

View File

@@ -1,14 +1,44 @@
on: push on:
push:
pull_request:
types:
- opened
- synchronize
- reopened
env:
GO_VERSION: "1.21"
name: Commit
jobs: jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
cache: true
- run: |
go install golang.org/x/tools/cmd/goimports@latest
go install honnef.co/go/tools/cmd/staticcheck@latest
export PATH="$HOME/go/bin:$PATH"
- uses: pre-commit/action@v3.0.0
build: build:
name: Build & Unit Test name: Build & Unit Test
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v4
- uses: actions/setup-go@v2
- uses: actions/setup-go@v4
with: with:
go-version: '1.21' go-version: ${{ env.GO_VERSION }}
- uses: actions/cache@v2 - uses: actions/cache@v2
with: with:
path: ~/go/pkg/mod path: ~/go/pkg/mod

View File

@@ -2,13 +2,13 @@ on:
release: release:
types: types:
- published - published
pull_request: # pull_request:
types: # types:
- opened # - opened
- synchronize # - synchronize
- reopened # - reopened
branches-ignore: # branches-ignore:
- "dependabot/**" # - "dependabot/**"
name: Release (Docker) name: Release (Docker)
jobs: jobs:

20
.pre-commit-config.yaml Normal file
View File

@@ -0,0 +1,20 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
hooks:
- id: trailing-whitespace
exclude_types: [markdown]
- 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-beta.5
hooks:
- id: go-imports-repo
args:
- "-local"
- "github.com/benbjohnson/litestrem"
- "-w"
- id: go-vet-repo-mod
# - id: go-staticcheck-repo-mod

View File

@@ -58,4 +58,3 @@ If you find mistakes in the documentation, please submit a fix to the
[new-issue]: https://github.com/benbjohnson/litestream/issues/new [new-issue]: https://github.com/benbjohnson/litestream/issues/new
[docs]: https://github.com/benbjohnson/litestream.io [docs]: https://github.com/benbjohnson/litestream.io

View File

@@ -5,6 +5,8 @@ package main
import ( import (
"context" "context"
"io" "io"
"log"
"log/slog"
"os" "os"
"os/signal" "os/signal"

View File

@@ -7,4 +7,3 @@
# replicas: # replicas:
# - path: /path/to/replica # File-based replication # - path: /path/to/replica # File-based replication
# - url: s3://my.bucket.com/db # S3-based replication # - url: s3://my.bucket.com/db # S3-based replication