Showing the changes to script (1 of 2 files). Show all
Unified · Split
| @@ -0,0 +1,27 @@ | |||
| 1 | #!/usr/bin/env bash | ||
| 2 | |||
| 3 | # Squawk is a linter for database migrations. It helps identify dangerous patterns, and suggests alternatives. | ||
| 4 | # Squawk flagging an error does not mean that you need to take a different approach, but it does indicate you need to think about what you're doing. | ||
| 5 | # See also: https://squawkhq.com | ||
| 6 | |||
| 7 | set -e | ||
| 8 | |||
| 9 | SQUAWK_VERSION=0.26.0 | ||
| 10 | SQUAWK_BIN="./target/squawk-$SQUAWK_VERSION" | ||
| 11 | SQUAWK_ARGS="--assume-in-transaction" | ||
| 12 | |||
| 13 | |||
| 14 | if [ ! -f "$SQUAWK_BIN" ]; then | ||
| 15 | curl -L -o "$SQUAWK_BIN" "https://github.com/sbdchd/squawk/releases/download/v$SQUAWK_VERSION/squawk-darwin-x86_64" | ||
| 16 | chmod +x "$SQUAWK_BIN" | ||
| 17 | fi | ||
| 18 | |||
| 19 | if [ -n "$SQUAWK_GITHUB_TOKEN" ]; then | ||
| 20 | export SQUAWK_GITHUB_REPO_OWNER=$(echo $GITHUB_REPOSITORY | awk -F/ '{print $1}') | ||
| 21 | export SQUAWK_GITHUB_REPO_NAME=$(echo $GITHUB_REPOSITORY | awk -F/ '{print $2}') | ||
| 22 | export SQUAWK_GITHUB_PR_NUMBER=$(echo $GITHUB_REF | awk 'BEGIN { FS = "/" } ; { print $3 }') | ||
| 23 | |||
| 24 | $SQUAWK_BIN $SQUAWK_ARGS upload-to-github $(git diff --name-only origin/$GITHUB_BASE_REF...origin/$GITHUB_HEAD_REF 'crates/collab/migrations/*.sql') | ||
| 25 | else | ||
| 26 | $SQUAWK_BIN $SQUAWK_ARGS $(git ls-files --others crates/collab/migrations/*.sql) $(git diff --name-only main crates/collab/migrations/*.sql) | ||
| 27 | fi | ||