Skip to content

Commit

Permalink
Add pre-commit linting, test all PRs
Browse files Browse the repository at this point in the history
  • Loading branch information
hifi committed Dec 15, 2023
1 parent 25ac72a commit 91eca40
Show file tree
Hide file tree
Showing 12 changed files with 66 additions and 19 deletions.
1 change: 0 additions & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
[docs]: https://github.com/benbjohnson/litestream.io

38 changes: 33 additions & 5 deletions .github/workflows/commit.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,42 @@
on: push
on:
push:
pull_request:
types:
- opened
- synchronize
- reopened

env:
GO_VERSION: "1.21"

jobs:
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/[email protected]

build:
name: Build & Unit Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
- uses: actions/checkout@v4

- uses: actions/setup-go@v4
with:
go-version: '1.21'
go-version: ${{ env.GO_VERSION }}

- uses: actions/cache@v2
with:
path: ~/go/pkg/mod
Expand Down Expand Up @@ -36,7 +64,7 @@ jobs:
# steps:
# - uses: actions/checkout@v2
# - uses: actions/setup-go@v2
# with:
# with:
# go-version: '1.20'
# - uses: actions/cache@v2
# with:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release.docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
with:
username: benbjohnson
password: ${{ secrets.DOCKERHUB_TOKEN }}

- id: meta
uses: docker/metadata-action@v3
with:
Expand All @@ -39,7 +39,7 @@ jobs:
type=sha,format=long
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- uses: docker/build-push-action@v2
with:
context: .
Expand All @@ -48,4 +48,4 @@ jobs:
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
LITESTREAM_VERSION=${{ env.VERSION }}
LITESTREAM_VERSION=${{ env.VERSION }}
6 changes: 3 additions & 3 deletions .github/workflows/release.linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:

- name: Install cross-compilers
run: |
sudo apt-get update
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu gcc-arm-linux-gnueabihf gcc-arm-linux-gnueabi
- name: Install nfpm
Expand All @@ -55,10 +55,10 @@ jobs:
cp etc/litestream.yml etc/litestream.service dist
cat etc/nfpm.yml | LITESTREAM_VERSION=${{ steps.release.outputs.tag_name }} envsubst > dist/nfpm.yml
CGO_ENABLED=1 go build -ldflags "-s -w -extldflags "-static" -X 'main.Version=${{ steps.release.outputs.tag_name }}'" -tags osusergo,netgo,sqlite_omit_load_extension -o dist/litestream ./cmd/litestream
cd dist
tar -czvf litestream-${{ steps.release.outputs.tag_name }}-${{ env.GOOS }}-${{ env.GOARCH }}${{ env.GOARM }}.tar.gz litestream
../nfpm pkg --config nfpm.yml --packager deb --target litestream-${{ steps.release.outputs.tag_name }}-${{ env.GOOS }}-${{ env.GOARCH }}${{ env.GOARM }}.deb
../nfpm pkg --config nfpm.yml --packager deb --target litestream-${{ steps.release.outputs.tag_name }}-${{ env.GOOS }}-${{ env.GOARCH }}${{ env.GOARM }}.deb
- name: Upload release tarball
uses: actions/[email protected]
Expand Down
20 changes: 20 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -199,4 +199,4 @@
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
[docs]: https://github.com/benbjohnson/litestream.io

2 changes: 1 addition & 1 deletion cmd/litestream/generations.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ cover.
Usage:
litestream generations [arguments] DB_PATH
litestream generations [arguments] REPLICA_URL
Arguments:
Expand Down
2 changes: 2 additions & 0 deletions cmd/litestream/main_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ package main
import (
"context"
"io"
"log"
"log/slog"
"os"
"os/signal"

Expand Down
2 changes: 1 addition & 1 deletion cmd/litestream/replicate.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ func (c *ReplicateCommand) Close() (err error) {
// Usage prints the help screen to STDOUT.
func (c *ReplicateCommand) Usage() {
fmt.Printf(`
The replicate command starts a server to monitor & replicate databases.
The replicate command starts a server to monitor & replicate databases.
You can specify your database & replicas in a configuration file or you can
replicate a single database file by specifying its path and its replicas in the
command line arguments.
Expand Down
4 changes: 2 additions & 2 deletions etc/litestream.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
Description="Litestream $(var.Version) installer"
Compressed="yes"
/>

<Media Id="1" Cabinet="litestream.cab" EmbedCab="yes"/>

<MajorUpgrade
Schedule="afterInstallInitialize"
DowngradeErrorMessage="A later version of [ProductName] is already installed. Setup will now exit."
Expand Down
1 change: 0 additions & 1 deletion etc/litestream.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@
# replicas:
# - path: /path/to/replica # File-based replication
# - url: s3://my.bucket.com/db # S3-based replication

0 comments on commit 91eca40

Please sign in to comment.