Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env bash
#
# Pre-commit hook to run lightweight checks and auto-format the code. It's designed
# to be blazingly fast, so it checks only changed files. Run the following command
# to install this hook for yourself. It's a symlink, to make sure it stays always
# up-to-date.
#
# ```bash
# ln -s ../../.githooks/pre-commit .git/hooks/pre-commit
# ```

set -euxo pipefail

function command_exists() {
bin_name=$(basename "$1")

if command -v "$1" &> /dev/null; then
printf "\e[0;32m[INFO] Using %s...\e[0m\n" "$bin_name"
return 0
fi

printf "\e[0;33m[WARN] %s CLI was not found. Ignoring it...\e[0m\n" "$bin_name" >&2
return 1
}

files=$(git diff --cached --name-only --diff-filter=ACMR | sed 's| |\\ |g')

if [[ -z "$files" ]]; then
echo "No files changed. Exiting the pre-commit hook..."
exit 0
fi

if command_exists typos; then
echo "$files" | xargs typos
fi

if command_exists ./node_modules/.bin/prettier; then
echo "$files" | xargs ./node_modules/.bin/prettier --ignore-unknown --write
fi

# Add the modified/prettified files to staging
echo "$files" | xargs git add

exit 0
11 changes: 11 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,14 @@ jobs:

- run: terraform validate
working-directory: ${{ matrix.project }}

prettier:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "22"
cache: "npm"
- run: npm ci --ignore-scripts
- run: npx prettier --check .
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ This repository contains necessary IaC code to deploy the resources of elastio s

Elastio terraform modules are published to the public Cloudsmith registry. In order to use them from that registry add this to your [`.terraformrc`](https://developer.hashicorp.com/terraform/cli/config/config-file), which should reside in your home directory (if you are on Linux):


```hcl
credentials "terraform.cloudsmith.io" {
token = "elastio/public/"
Expand Down
27 changes: 27 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"scripts": {
"fmt": "prettier --write ."
},
"devDependencies": {
"prettier": "^3.5.3"
}
}