Skip to content

Commit

Permalink
Add pre-commit hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
linw1995 committed Aug 2, 2024
1 parent 2220a91 commit 88699ec
Show file tree
Hide file tree
Showing 14 changed files with 47 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[build]
# copied from `cargo tarpaulin --print-rust-flags`
rustflags = "-Cdebuginfo=2 -Cstrip=none --cfg=tarpaulin -Cinstrument-coverage -Clink-dead-code"
incremental = false
incremental = false
6 changes: 3 additions & 3 deletions .gitea/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,15 @@ jobs:
./scripts/cli.sh setup
- name: Run lints
run: |
export CARGO_BUILD_TARGET=x86_64-unknown-linux-musl
export CARGO_BUILD_TARGET=x86_64-unknown-linux-musl
./scripts/cli.sh lint
- name: Run tests with coverage
run: |
export CARGO_BUILD_TARGET=x86_64-unknown-linux-musl
export CARGO_BUILD_TARGET=x86_64-unknown-linux-musl
./scripts/cli.sh coverage
# - name: Try to build release
# continue-on-error: true
# run: |
# export CARGO_BUILD_TARGET=x86_64-unknown-linux-musl
# export CARGO_BUILD_TARGET=x86_64-unknown-linux-musl
# cargo build --bin serve --release --verbose
# find . -name serve -type f
2 changes: 1 addition & 1 deletion .gitea/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
sccache --stop-server || sccache --start-server
- name: Build
run: |
export CARGO_BUILD_TARGET=x86_64-unknown-linux-musl
export CARGO_BUILD_TARGET=x86_64-unknown-linux-musl
cargo build --bin serve --release --verbose
cp ./target/x86_64-unknown-linux-musl/release/serve ./server
- name: Login to Docker Hub
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:

- name: Run tests with coverage
run: |
./scripts/cli.sh coverage
./scripts/cli.sh coverage
env:
CARGO_BUILD_TARGET: x86_64-unknown-linux-musl
SCCACHE_GHA_ENABLED: "true"
Expand Down
7 changes: 3 additions & 4 deletions .github/workflows/Release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
packages: write
attestations: write
id-token: write
#
#
steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand Down Expand Up @@ -76,12 +76,11 @@ jobs:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
# # This step generates an artifact attestation for the image, which is an unforgeable statement about where and how it was built. It increases supply chain security for people who consume the image. For more information, see "[AUTOTITLE](/actions/security-guides/using-artifact-attestations-to-establish-provenance-for-builds)."

# # This step generates an artifact attestation for the image, which is an unforgeable statement about where and how it was built. It increases supply chain security for people who consume the image. For more information, see "[AUTOTITLE](/actions/security-guides/using-artifact-attestations-to-establish-provenance-for-builds)."
# - name: Generate artifact attestation
# uses: actions/attest-build-provenance@v1
# with:
# subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
# subject-digest: ${{ steps.push.outputs.digest }}
# push-to-registry: true

2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ Cargo.lock
.env*
.vscode
tarpaulin-report.html
*.profraw
*.profraw
31 changes: 31 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: local
hooks:
- id: fmt
name: fmt
description: Format files with cargo fmt.
entry: cargo fmt
language: system
types: [rust]
args: ["--"]
- id: cargo-check
name: cargo check
description: Check the package for errors.
entry: cargo check
language: system
types: [rust]
pass_filenames: false
- id: clippy
name: clippy
description: Lint rust sources
entry: cargo clippy
language: system
args: ["--", "-D", "warnings"]
types: [rust]
pass_filenames: false
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
FROM alpine

RUN apk add --no-cache tzdata
RUN apk add --no-cache tzdata

COPY ./server /usr/local/bin/server

EXPOSE 8000

CMD ["server"]
CMD ["server"]
2 changes: 1 addition & 1 deletion migrations/2024-06-22-085015_delete_bookmarks/down.sql
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
ALTER TABLE bookmarks
ALTER TABLE bookmarks
DROP COLUMN deleted_at;
4 changes: 2 additions & 2 deletions migrations/2024-06-22-085015_delete_bookmarks/up.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
ALTER TABLE bookmarks
ADD COLUMN deleted_at TIMESTAMP(6)
WITH TIME ZONE;
ADD COLUMN deleted_at TIMESTAMP(6)
WITH TIME ZONE;
1 change: 0 additions & 1 deletion migrations/2024-07-01-143050_update_bookmark/down.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
ALTER TABLE bookmarks
DROP COLUMN updated_at;

1 change: 0 additions & 1 deletion migrations/2024-07-01-143050_update_bookmark/up.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
ALTER TABLE bookmarks
ADD COLUMN updated_at TIMESTAMP(6) WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP;

2 changes: 1 addition & 1 deletion migrations/2024-07-02-145638_tags/down.sql
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
DROP TABLE bookmarks_tags;
DROP TABLE tags;
DROP TABLE tags;
1 change: 0 additions & 1 deletion migrations/2024-07-02-145638_tags/up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,3 @@ CREATE TABLE bookmarks_tags(
tag_id integer REFERENCES tags(id) ON DELETE CASCADE,
PRIMARY KEY (bookmark_id, tag_id)
);

0 comments on commit 88699ec

Please sign in to comment.