-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Edward Fitz Abucay <ffimnsr@gmail.com>
- Loading branch information
Showing
7 changed files
with
213 additions
and
44 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 |
---|---|---|
|
@@ -10,3 +10,6 @@ insert_final_newline = true | |
|
||
[*.yaml] | ||
indent_size = 2 | ||
|
||
[*.toml] | ||
indent_size = 2 |
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,12 @@ | ||
#!/usr/bin/env bash | ||
|
||
COMMIT_SUBJECT=$(head -2 $1 | tail -1) | ||
echo "Commit message: $COMMIT_SUBJECT" | ||
|
||
# Check if the commit message starts with an emoji status | ||
if [[ ! $COMMIT_SUBJECT =~ ^(🍕|✨|🐛|🚑|👷|📦|💚|📝|💄|🧹|⚡|🧪|❌|🚀|🚧|🔖|🌐) ]]; then | ||
echo >&2 "Commit message must start with one emoji status." | ||
exit 1 | ||
fi | ||
|
||
exit 0 |
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,9 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Run checks before committing | ||
echo "Checking if the code is compilable" | ||
cargo check --all-targets --all-features | ||
if [ $? -ne 0 ]; then | ||
echo >&2 "Please fix the errors before committing." | ||
exit 1 | ||
fi |
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,56 @@ | ||
#!/usr/bin/env bash | ||
|
||
remote="$1" | ||
url="$2" | ||
|
||
zero=$(git hash-object --stdin </dev/null | tr '[0-9a-f]' '0') | ||
|
||
check_lint () { | ||
# Run lint check | ||
cargo fmt --all --check | ||
if [ $? -ne 0 ]; then | ||
echo >&2 "Please run 'cargo fmt' and commit the formatting changes." | ||
exit 1 | ||
fi | ||
} | ||
|
||
check_code_warnings () { | ||
# Run clippy to check for warnings | ||
cargo clippy --all-features --all-targets --tests --benches -- -Dclippy::all | ||
if [ $? -ne 0 ]; then | ||
echo >&2 "Please run 'cargo clippy' and fix the warnings." | ||
exit 1 | ||
fi | ||
} | ||
|
||
while read local_ref local_oid remote_ref remote_oid | ||
do | ||
if test "$local_oid" = "$zero"; then | ||
# Handle delete | ||
: | ||
else | ||
if test "$remote_oid" = "$zero"; then | ||
# No existing commits yet on the new branch (no remote yet). | ||
# Examine all local commits. | ||
range="$local_oid" | ||
else | ||
# Examine new commits from local that is missing from remote branch. | ||
# Update to existing branch. | ||
range="$remote_oid..$local_oid" | ||
fi | ||
|
||
# Check for WIP commit | ||
commit=$(git rev-list -n 1 --grep '^--wip--' "$range") | ||
if test -n "$commit" | ||
then | ||
echo >&2 "Found WIP commit in $local_ref, not pushing." | ||
exit 1 | ||
fi | ||
|
||
check_lint | ||
|
||
check_code_warnings | ||
fi | ||
done | ||
|
||
exit 0 |
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,133 @@ | ||
[tasks.install-git-hooks] | ||
command = "git" | ||
args = ["config", "--local", "core.hooksPath", ".githooks/"] | ||
|
||
[tasks.clip] | ||
command = "cargo" | ||
args = ["clippy", "--all-features", "--all-targets", "--tests", "--benches", "--", "-Dclippy::all"] | ||
|
||
[tasks.run-postgres] | ||
script = ''' | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
packager=docker | ||
if ! command -v docker &>/dev/null; then | ||
packager=podman | ||
fi | ||
$packager run -it --rm --name pgsql -p 5432:5432 \ | ||
-e POSTGRES_PASSWORD=postgres \ | ||
-e POSTGRES_DB=startup \ | ||
-d postgres:16-alpine | ||
''' | ||
|
||
[tasks.run-mysql] | ||
script = ''' | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
packager=docker | ||
if ! command -v docker &>/dev/null; then | ||
packager=podman | ||
fi | ||
$packager run -it --rm --name mysql -p 3306:3306 \ | ||
-e MYSQL_ROOT_PASSWORD=mysql \ | ||
-e MYSQL_DATABASE=startup \ | ||
-d mysql:9-oracle | ||
''' | ||
|
||
[tasks.run-mariadb] | ||
script = ''' | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
packager=docker | ||
if ! command -v docker &>/dev/null; then | ||
packager=podman | ||
fi | ||
$packager run -it --rm --name mariadb -p 3306:3306 \ | ||
-e MARIADB_ROOT_PASSWORD=mariadb \ | ||
-e MARIADB_DATABASE=startup \ | ||
-d mariadb:10 | ||
''' | ||
|
||
[tasks.run-mssql] | ||
script = ''' | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
packager=docker | ||
if ! command -v docker &>/dev/null; then | ||
packager=podman | ||
fi | ||
$packager run -it --rm --name mssql -p 1433:1433 \ | ||
-e ACCEPT_EULA=Y \ | ||
-e MSSQL_SA_PASSWORD='Strong(!)Password123' \ | ||
-e MSSQL_PID=Developer \ | ||
-e MSSQL_DB=startup \ | ||
-d mcr.microsoft.com/mssql/server:2022-latest | ||
''' | ||
|
||
[tasks.create-package] | ||
script = ''' | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
packager=docker | ||
if ! command -v docker &>/dev/null; then | ||
packager=podman | ||
fi | ||
latest_version=${CARGO_MAKE_PROJECT_VERSION} | ||
name=${CARGO_MAKE_PROJECT_NAME} | ||
$packager build \ | ||
--label org.opencontainers.image.created=$(date +%Y-%m-%dT%H:%M:%S%z) \ | ||
--label org.opencontainers.image.authors=gh:@ffimnsr \ | ||
--label org.opencontainers.image.description="$name $latest_version" \ | ||
--label org.opencontainers.image.revision=$(git rev-parse HEAD) \ | ||
--label org.opencontainers.image.source=$(git remote get-url origin) \ | ||
--label org.opencontainers.image.title=$name \ | ||
--label org.opencontainers.image.url=https://github.com/ffimnsr/midas-rs \ | ||
--label org.opencontainers.image.version=$latest_version\ | ||
-f Containerfile \ | ||
-t ghcr.io/ffimnsr/$name-rs:$latest_version \ | ||
-t ghcr.io/ffimnsr/$name-rs:latest . | ||
''' | ||
|
||
[tasks.create-package-distroless] | ||
script = ''' | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
packager=docker | ||
if ! command -v docker &>/dev/null; then | ||
packager=podman | ||
fi | ||
latest_version=${CARGO_MAKE_PROJECT_VERSION} | ||
name=${CARGO_MAKE_PROJECT_NAME} | ||
$packager build \ | ||
--sbom=true \ | ||
--provenance=true \ | ||
--label org.opencontainers.image.created=$(date +%Y-%m-%dT%H:%M:%S%z) \ | ||
--label org.opencontainers.image.authors=gh:@ffimnsr \ | ||
--label org.opencontainers.image.description="$name $latest_version" \ | ||
--label org.opencontainers.image.revision=$(git rev-parse HEAD) \ | ||
--label org.opencontainers.image.source=$(git remote get-url origin) \ | ||
--label org.opencontainers.image.title=$name \ | ||
--label org.opencontainers.image.url=https://github.com/ffimnsr/playground \ | ||
--label org.opencontainers.image.version=$latest_version\ | ||
-f Containerfile.distroless \ | ||
-t ghcr.io/ffimnsr/$name-rs:$latest_version \ | ||
-t ghcr.io/ffimnsr/$name-rs:latest . | ||
''' |
This file was deleted.
Oops, something went wrong.