Skip to content

Commit

Permalink
Add shell formatting to pre-commit (#60)
Browse files Browse the repository at this point in the history
Add shfmt to pre-commit to format our shell scripts, and run it on the
existing scripts.

This is an additional Go-based dependency.
  • Loading branch information
mdekstrand authored Jul 8, 2024
1 parent 121a1c9 commit 562ea57
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
13 changes: 12 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,26 @@ repos:
# Run the linter.
- id: ruff
args: [--fix]
name: auto-fix Python lint errors
# Run the formatter.
- id: ruff-format
name: format Python source
- repo: local
hooks:
- id: format-toml-files
name: toml-format
name: format toml files
entry: taplo
args: ["format"]
files: \.toml$
language: node
additional_dependencies:
- "@taplo/cli"
# shfmt support, adapted from https://github.com/mvdan/sh/issues/818
- id: format-shell-scripts
name: format shell scripts
language: golang
require_serial: true
additional_dependencies: [mvdan.cc/sh/v3/cmd/shfmt@v3.8.0]
entry: shfmt
args: ["-l", "-w", "-i", "4"]
types: [shell]
17 changes: 9 additions & 8 deletions deploy.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
#!/bin/bash

while getopts ":e:r:" flag
do
while getopts ":e:r:" flag; do
case "${flag}" in
e) env=${OPTARG};;
r) region=${OPTARG};;
*) echo "Invalid option. Only -e and -r are allowed" >&2
exit 1 ;;
e) env=${OPTARG} ;;
r) region=${OPTARG} ;;
*)
echo "Invalid option. Only -e and -r are allowed" >&2
exit 1
;;
esac
done
env=${env:-prod}
region=${region:-us-east-1}

echo "ENV: $env";
echo "Region: $region";
echo "ENV: $env"
echo "Region: $region"

# Download model artifacts
dvc pull
Expand Down

0 comments on commit 562ea57

Please sign in to comment.