History

One of these days...

Conrad Irwin committed 2 years ago

Commit 87ccbf61 parent 51e4db72 files · +29 −7Browse files

Showing the changes to script (1 of 2 files). Show all

Unified · Split

script/squawk+27−0
@@ -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

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t