-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add linting, formatting and other checks
This adds pre-commit hooks installable using the provided Makefile as well as a new check to validate the version in the Cargo file matches the git tag. This will be useful as a check before pushing releases.
- Loading branch information
1 parent
2e5c4c5
commit 91d70e6
Showing
8 changed files
with
103 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
README.md | ||
target/ | ||
scripts/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v3.1.0 | ||
hooks: | ||
- id: check-added-large-files | ||
- id: check-yaml | ||
- id: check-toml | ||
- id: trailing-whitespace | ||
- id: end-of-file-fixer | ||
- id: check-merge-conflict | ||
- repo: https://github.com/doublify/pre-commit-rust | ||
rev: 14b3e118cfc36fb87d8d9cbd1305a2238fd85868 | ||
hooks: | ||
- id: fmt | ||
- id: cargo-check | ||
- id: clippy | ||
- repo: https://github.com/IamTheFij/docker-pre-commit | ||
rev: v2.0.0 | ||
hooks: | ||
- id: docker-compose-check | ||
- id: hadolint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
DOCKER_TAG ?= bitwarden_rs_ldap_${USER} | ||
|
||
.PHONY: all | ||
all: test check release | ||
|
||
# Default make target will run tests | ||
.DEFAULT_GOAL = test | ||
|
||
# Build debug version | ||
target/debug/bitwarden_rs_ldap: src/ | ||
cargo build | ||
|
||
# Build release version | ||
target/release/bitwarden_rs_ldap: src/ | ||
cargo build --locked --release | ||
|
||
.PHONY: debug | ||
debug: target/debug/bitwarden_rs_ldap | ||
|
||
.PHONY: release | ||
release: target/release/bitwarden_rs_ldap | ||
|
||
# Run debug version | ||
.PHONY: run-debug | ||
run-debug: target/debug/bitwarden_rs_ldap | ||
target/debug/bitwarden_rs_ldap | ||
|
||
# Run all tests | ||
.PHONY: test | ||
test: | ||
cargo test | ||
|
||
# Installs pre-commit hooks | ||
.PHONY: install-hooks | ||
install-hooks: | ||
pre-commit install --install-hooks | ||
|
||
# Checks files for encryption | ||
.PHONY: check | ||
check: | ||
pre-commit run --all-files | ||
|
||
# Checks that version matches the current tag | ||
.PHONY: check-version | ||
check-version: | ||
./scripts/check-version.sh | ||
|
||
.PHONY: clean | ||
clean: | ||
rm -f ./target | ||
|
||
.PHONY: docker-build | ||
docker-build: | ||
docker build -f ./Dockerfile -t $(DOCKER_TAG) . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
--- | ||
version: '3' | ||
services: | ||
ldap_sync: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#! /bin/sh | ||
|
||
CARGO_VERSION=$(cargo pkgid --offline | sed 's/.*#//') | ||
GIT_VERSION=${GIT_VERSION:-$(git describe --tags --exact-match)} | ||
if ! [ "v$CARGO_VERSION" = "$GIT_VERSION" ]; then | ||
echo "ERROR: Cargo version (v$CARGO_VERSION) and git version ($GIT_VERSION) do not match" | ||
exit 1 | ||
fi |