Add pre-commit linting, test all PRs (#541)
This commit is contained in:
1
.github/CONTRIBUTING.md
vendored
1
.github/CONTRIBUTING.md
vendored
@@ -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
|
||||||
|
|
||||||
|
|||||||
40
.github/workflows/commit.yml
vendored
40
.github/workflows/commit.yml
vendored
@@ -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
|
||||||
@@ -36,7 +66,7 @@ jobs:
|
|||||||
# steps:
|
# steps:
|
||||||
# - uses: actions/checkout@v2
|
# - uses: actions/checkout@v2
|
||||||
# - uses: actions/setup-go@v2
|
# - uses: actions/setup-go@v2
|
||||||
# with:
|
# with:
|
||||||
# go-version: '1.20'
|
# go-version: '1.20'
|
||||||
# - uses: actions/cache@v2
|
# - uses: actions/cache@v2
|
||||||
# with:
|
# with:
|
||||||
|
|||||||
20
.github/workflows/release.docker.yml
vendored
20
.github/workflows/release.docker.yml
vendored
@@ -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:
|
||||||
@@ -27,7 +27,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
username: benbjohnson
|
username: benbjohnson
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
|
||||||
- id: meta
|
- id: meta
|
||||||
uses: docker/metadata-action@v3
|
uses: docker/metadata-action@v3
|
||||||
with:
|
with:
|
||||||
@@ -39,7 +39,7 @@ jobs:
|
|||||||
type=sha,format=long
|
type=sha,format=long
|
||||||
type=semver,pattern={{version}}
|
type=semver,pattern={{version}}
|
||||||
type=semver,pattern={{major}}.{{minor}}
|
type=semver,pattern={{major}}.{{minor}}
|
||||||
|
|
||||||
- uses: docker/build-push-action@v2
|
- uses: docker/build-push-action@v2
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
@@ -48,4 +48,4 @@ jobs:
|
|||||||
tags: ${{ steps.meta.outputs.tags }}
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
build-args: |
|
build-args: |
|
||||||
LITESTREAM_VERSION=${{ env.VERSION }}
|
LITESTREAM_VERSION=${{ env.VERSION }}
|
||||||
|
|||||||
6
.github/workflows/release.linux.yml
vendored
6
.github/workflows/release.linux.yml
vendored
@@ -40,7 +40,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Install cross-compilers
|
- name: Install cross-compilers
|
||||||
run: |
|
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
|
sudo apt-get install -y gcc-aarch64-linux-gnu gcc-arm-linux-gnueabihf gcc-arm-linux-gnueabi
|
||||||
|
|
||||||
- name: Install nfpm
|
- name: Install nfpm
|
||||||
@@ -55,10 +55,10 @@ jobs:
|
|||||||
cp etc/litestream.yml etc/litestream.service dist
|
cp etc/litestream.yml etc/litestream.service dist
|
||||||
cat etc/nfpm.yml | LITESTREAM_VERSION=${{ steps.release.outputs.tag_name }} envsubst > dist/nfpm.yml
|
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
|
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
|
cd dist
|
||||||
tar -czvf litestream-${{ steps.release.outputs.tag_name }}-${{ env.GOOS }}-${{ env.GOARCH }}${{ env.GOARM }}.tar.gz litestream
|
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
|
- name: Upload release tarball
|
||||||
uses: actions/upload-release-asset@v1.0.2
|
uses: actions/upload-release-asset@v1.0.2
|
||||||
|
|||||||
20
.pre-commit-config.yaml
Normal file
20
.pre-commit-config.yaml
Normal 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
|
||||||
2
LICENSE
2
LICENSE
@@ -199,4 +199,4 @@
|
|||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
|
|||||||
@@ -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
|
||||||
|
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ cover.
|
|||||||
Usage:
|
Usage:
|
||||||
|
|
||||||
litestream generations [arguments] DB_PATH
|
litestream generations [arguments] DB_PATH
|
||||||
|
|
||||||
litestream generations [arguments] REPLICA_URL
|
litestream generations [arguments] REPLICA_URL
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ package main
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"io"
|
"io"
|
||||||
|
"log"
|
||||||
|
"log/slog"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
|
|
||||||
|
|||||||
@@ -181,7 +181,7 @@ func (c *ReplicateCommand) Close() (err error) {
|
|||||||
// Usage prints the help screen to STDOUT.
|
// Usage prints the help screen to STDOUT.
|
||||||
func (c *ReplicateCommand) Usage() {
|
func (c *ReplicateCommand) Usage() {
|
||||||
fmt.Printf(`
|
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
|
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
|
replicate a single database file by specifying its path and its replicas in the
|
||||||
command line arguments.
|
command line arguments.
|
||||||
|
|||||||
@@ -26,9 +26,9 @@
|
|||||||
Description="Litestream $(var.Version) installer"
|
Description="Litestream $(var.Version) installer"
|
||||||
Compressed="yes"
|
Compressed="yes"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Media Id="1" Cabinet="litestream.cab" EmbedCab="yes"/>
|
<Media Id="1" Cabinet="litestream.cab" EmbedCab="yes"/>
|
||||||
|
|
||||||
<MajorUpgrade
|
<MajorUpgrade
|
||||||
Schedule="afterInstallInitialize"
|
Schedule="afterInstallInitialize"
|
||||||
DowngradeErrorMessage="A later version of [ProductName] is already installed. Setup will now exit."
|
DowngradeErrorMessage="A later version of [ProductName] is already installed. Setup will now exit."
|
||||||
|
|||||||
@@ -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
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user