Skip to content
This repository has been archived by the owner on Aug 4, 2023. It is now read-only.

Add ShellCheck to pre-commit config #718

Merged
merged 8 commits into from
Sep 20, 2022
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
4 changes: 4 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,7 @@ repos:
- id: black
args:
- --safe
- repo: https://github.com/koalaman/shellcheck-precommit
rev: v0.8.0
hooks:
- id: shellcheck
8 changes: 3 additions & 5 deletions dag-sync.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,14 @@ SLACK_URL=$1
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
cd "$SCRIPT_DIR"

# Get current commit hash
current=$(git rev-parse HEAD)
# Update origin
git fetch origin
# Get new commit hash *one commit ahead* of this one
new=$(git rev-list --reverse --topo-order HEAD..origin/main | head -1)
# If there is no new commit hash to move to, nothing has changed, quit early
[ -z $new ] && exit
[ -z "$new" ] && exit
# Move ahead to this new commit
git reset --hard $new
git reset --hard "$new"
# Pull out the subject from the new commit
subject=$(git log -1 --format='%s')

Expand All @@ -32,7 +30,7 @@ if [ -z "$SLACK_URL" ]
then
echo "Slack hook was not supplied! Updates will not be posted"
else
curl $SLACK_URL \
curl "$SLACK_URL" \
-X POST \
-H 'Content-Type: application/json' \
-d '{"text":"Deployed: '"$subject"'","username":"DAG Sync","icon_emoji":":recycle:","blocks":[{"type":"section","text":{"type":"mrkdwn","text":"Deployed: <https://github.com/WordPress/openverse-catalog/commit/'"$new"'|'"$subject"'>"}}]}'
Expand Down
10 changes: 5 additions & 5 deletions docker/airflow/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,20 @@ header "MODIFYING ENVIRONMENT"
# subprocess manipulation via <(...) syntax to allow the `export` calls
# to propagate to the outer shell.
# See: https://unix.stackexchange.com/a/402752
while read var_string; do
while read -r var_string; do
# get the variable name
var_name=`expr "$var_string" : '^\([A-Z_]*\)'`
var_name=$(expr "$var_string" : '^\([A-Z_]*\)')
echo "Variable Name: $var_name"
# get the old value
old_value=`expr "$var_string" : '^[A-Z_]*=\(http.*\)$'`
old_value=$(expr "$var_string" : '^[A-Z_]*=\(http.*\)$')
echo " Old Value: $old_value"
# call python to url encode the http clause
url_encoded=`python -c "from urllib.parse import quote_plus; import sys; print(quote_plus(sys.argv[1]))" $old_value`
url_encoded=$(python -c "from urllib.parse import quote_plus; import sys; print(quote_plus(sys.argv[1]))" "$old_value")
# prepend https://
new_value='https://'$url_encoded
echo " New Value: $new_value"
# set the environment variable
export $var_name=$new_value
export "$var_name"="$new_value"
# only include airflow connections with http somewhere in the string
done < <(env | grep "^AIRFLOW_CONN[A-Z_]\+=http.*$")

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash

T=$(mktemp)
jq '.' $1 > $T
mv $T $1
jq '.' "$1" > "$T"
mv "$T" "$1"