Skip to content

Openverse is a search engine for openly-licensed media. This monorepo includes all application code.

Fix just argument splitting on pass-through recipes with complex args (#4961)

sarayourfriend081d17490453
diff --git a/.vale/justfile b/.vale/justfile
index 5fbd468cd..d8d9331c5 100644
--- a/.vale/justfile
+++ b/.vale/justfile
@@ -14,7 +14,7 @@ IGNORE_FILES_PATTERN := ".pnpm|changelogs|projects/proposals|node_modules|.?venv
# of the current working directory. If a custom separator is specified, newlines are
# replaced with this separator before outputting the file list.
_files separator="\n":
- #! /usr/bin/env sh
+ #! /usr/bin/env bash
files=$(
find "$PWD/.." -type f \( -name "*.md" -o -name "*.mdx" \) \
| grep -vE "{{ IGNORE_FILES_PATTERN }}"
diff --git a/api/justfile b/api/justfile
index 9bddb7b6e..d724387bb 100644
--- a/api/justfile
+++ b/api/justfile
@@ -45,12 +45,14 @@ install *args:
######
# Bring up services specific to the API profile
+[positional-arguments]
up *flags:
- env COMPOSE_PROFILES="api" just ../up {{ flags }}
+ env COMPOSE_PROFILES="api" just ../up "$@"
# Bring up services specific to the API profile, in addition to the API server
+[positional-arguments]
up-extra *flags:
- env COMPOSE_PROFILES="api,api_extra" just ../up {{ flags }}
+ env COMPOSE_PROFILES="api,api_extra" just ../up "$@"
# Wait for all profile services to be up
wait-up: up
@@ -103,12 +105,14 @@ pgcli db_user_pass="deploy" db_name="openledger": up
#########################
# Run Django administrative commands locally
-dj-local +args="":
- pdm run python manage.py {{ args }}
+[positional-arguments]
+dj-local *args:
+ pdm run python manage.py "$@"
# Run Django administrative commands inside the Docker container
-dj +args="": wait-up
- env DC_USER="{{ env_var_or_default("DC_USER", "opener") }}" just ../exec web python manage.py {{ args }}
+[positional-arguments]
+dj *args: wait-up
+ env DC_USER="{{ env_var_or_default("DC_USER", "opener") }}" just ../exec web python manage.py "$@"
# Get IPython shell inside the Docker container
ipython:
@@ -152,12 +156,14 @@ generate-docs doc="media-props" fail_on_diff="true":
#########
# Run API tests inside the Docker container
+[positional-arguments]
test *args: wait-up
- env DC_USER="opener" just ../exec web pytest {{ args }}
+ env DC_USER="opener" just ../exec web pytest "$@"
# Run API tests locally
+[positional-arguments]
test-local *args:
- pdm run pytest {{ args }}
+ pdm run pytest "$@"
# Run smoke test for the API docs
doc-test: wait-up
diff --git a/automations/js/justfile b/automations/js/justfile
index e23171a23..4a8235f60 100644
--- a/automations/js/justfile
+++ b/automations/js/justfile
@@ -10,8 +10,10 @@ NO_COLOR := "\\033[0m"
just --list --unsorted
# Run a script
+[positional-arguments]
run script *args:
- pnpm --filter automations exec node src/{{ script }} {{ args }}
+ #! /usr/bin/env bash
+ pnpm --filter automations exec node src/{{ script }} "${@:2}"
#################
# Weekly report #
@@ -25,21 +27,14 @@ report:
# Render #
##########
+_render slug name:
+ just run render-jinja.js \
+ templates/release-drafter.yml.jinja \
+ .github/release-drafter-{{ slug }}.yml \
+ '{"app": "{{ name }}"}'
+
render-release-drafter:
- #! /usr/bin/env sh
- render_release_drafter() {
- slug=$1
- name=$2
- just run render-jinja.js \
- templates/release-drafter.yml.jinja \
- .github/release-drafter-$slug.yml \
- "'{ \"app\": \"$name\" }'"
- }
- render_release_drafter api API
- render_release_drafter ingestion_server "Ingestion Server"
- render_release_drafter frontend Frontend
- render_release_drafter catalog Catalog
-
-# Render all templates (shortcut for easy iteration)
-render-templates:
- just render-release-drafter
+ just _render api API
+ just _render ingestion_server "Ingestion Server"
+ just _render frontend Frontend
+ just _render catalog Catalog
diff --git a/automations/python/justfile b/automations/python/justfile
index 29dbc3ffa..c6c4020db 100644
--- a/automations/python/justfile
+++ b/automations/python/justfile
@@ -11,9 +11,11 @@ NO_COLOR := "\\033[0m"
# Install dependencies
+[positional-arguments]
install *args:
- pdm install {{ args }}
+ pdm install "$@"
# Run a script
+[positional-arguments]
run script *args:
- pdm run {{ script }} {{ args }}
+ pdm run "$@"
diff --git a/catalog/justfile b/catalog/justfile
index cb6bffcab..135a8f5e6 100644
--- a/catalog/justfile
+++ b/catalog/justfile
@@ -56,12 +56,14 @@ install *args: check-py-version
######
# Bring up services specific to the catalog profile
+[positional-arguments]
up *flags:
- env COMPOSE_PROFILES="catalog" just ../up {{ flags }}
+ env COMPOSE_PROFILES="catalog" just ../up "$@"
# Bring up services specific to the catalog profile, except Airflow
+[positional-arguments]
up-deps *flags:
- env COMPOSE_PROFILES="catalog_dependencies" just ../up {{ flags }}
+ env COMPOSE_PROFILES="catalog_dependencies" just ../up "$@"
# Load sample data into upstream DB
init: up
@@ -82,11 +84,12 @@ shell:
env DC_USER="airflow" just ../exec {{ SERVICE }} /bin/bash
# Launch an IPython shell in a new container under `SERVICE`
+[positional-arguments]
ipython *args: up-deps
env DC_USER="airflow" just ../run \
--workdir /opt/airflow/catalog/dags \
{{ SERVICE }} \
- bash -c \'ipython {{ args }}\'
+ bash -c "ipython ${@:2}"
# Launch a `pgcli` shell in the PostgreSQL container
pgcli db_user_pass="deploy" db_name="openledger": up
@@ -97,13 +100,14 @@ pgcli db_user_pass="deploy" db_name="openledger": up
#########
# Run a command in a test container under `SERVICE`
-_mount-test command: up-deps
+[positional-arguments]
+_mount-test *command: up-deps
env DC_USER="airflow" just ../run \
-e AIRFLOW_VAR_INGESTION_LIMIT=1000000 \
-w /opt/airflow/catalog \
- --volume \'{{ justfile_directory() }}/../docker\':/opt/airflow/docker/ \
+ --volume {{ justfile_directory() }}/../docker:/opt/airflow/docker/ \
{{ SERVICE }} \
- {{ command }}
+ "$@"
# Launch a Bash shell in a test container under `SERVICE`
# Run pytest with `--pdb` to workaround xdist breaking pdb.set_trace()
@@ -111,8 +115,9 @@ test-session:
just _mount-test bash
# Run pytest in a test container under `SERVICE`
+[positional-arguments]
test *args:
- just _mount-test "bash -c \'pytest {{ args }}\'"
+ just _mount-test bash -c "pytest $@"
#############
# Utilities #
@@ -120,7 +125,7 @@ test *args:
# Generate the documentation (either "dag" or "media-props")
generate-docs doc="dag" fail_on_diff="false":
- #!/bin/bash
+ #! /usr/bin/env bash
set -e
if [ "{{ doc }}" == "dag" ]; then
SCRIPT_PATH="catalog/utilities/dag_doc_gen/dag_doc_generation.py"
@@ -136,18 +141,20 @@ generate-docs doc="dag" fail_on_diff="false":
echo "Invalid documentation type specified, use \`dag\` or \`media-props\`. Exiting."
exit 1
fi
+
GENERATED_ABS_PATH="/opt/airflow/catalog/${GENERATED_REL_PATH}"
just ../run \
--volume {{ justfile_directory() }}/../docker:/opt/airflow/docker/ \
-e PYTHONPATH=/opt/airflow/catalog:/opt/airflow/catalog/dags \
{{ SERVICE }} \
- "bash -c 'python $SCRIPT_PATH && chmod 666 $GENERATED_ABS_PATH'"
+ bash -c "python $SCRIPT_PATH && chmod 666 $GENERATED_ABS_PATH"
+
TEMP="documentation/meta/temp"
- mv ../catalog/$GENERATED_REL_PATH ../$TEMP.md
+ mv ../catalog/"$GENERATED_REL_PATH" ../"$TEMP".md
echo "Moved the generated file to ../$TEMP.md"
echo -n "Running linting..."
# Linting step afterwards is necessary since the generated output differs greatly from what prettier expects
- just ../lint prettier $TEMP.md &>/dev/null || true
+ just ../lint prettier "$TEMP".md &>/dev/null || true
echo "Linting done!"
echo -n "Replacing linted md <hr> '---' with '----' required by sphinx..."
diff --git a/docker/cache/justfile b/docker/cache/justfile
index eb0bcb846..51f8a933f 100644
--- a/docker/cache/justfile
+++ b/docker/cache/justfile
@@ -14,8 +14,9 @@ NO_COLOR := "\\033[0m"
#######
# Open the Redis CLI as an interactive REPL
+[positional-arguments]
cli *args:
- just ../../exec cache redis-cli {{ args }}
+ just ../../exec cache redis-cli "$@"
# Delete all data cached in Redis
flushall:
diff --git a/documentation/justfile b/documentation/justfile
index 7203d690f..4a997abcb 100644
--- a/documentation/justfile
+++ b/documentation/justfile
@@ -72,8 +72,9 @@ live port="50230": clean
pdm run sphinx-autobuild -b html . _serve/ --port {{ port }}
# Compile the documentation into a static site
+[positional-arguments]
build *args: clean
- pdm run sphinx-build {{ args }} -b html . _build/
+ pdm run sphinx-build "$@" -b html . _build/
# Serve the compiled docs using a simple HTTP server
serve port="50231":
diff --git a/frontend/bin/playwright.sh b/frontend/bin/playwright.sh
index cdfa8a6b6..00554c3f8 100755
--- a/frontend/bin/playwright.sh
+++ b/frontend/bin/playwright.sh
@@ -1,4 +1,4 @@
-#! /usr/bin/env sh
+#! /usr/bin/env bash
set -e
version() {
diff --git a/frontend/justfile b/frontend/justfile
index eeb402bb2..77479adf6 100644
--- a/frontend/justfile
+++ b/frontend/justfile
@@ -55,8 +55,9 @@ run-img tag="openverse-frontend:local":
######
# Bring up services specific to the frontend profile
+[positional-arguments]
up *flags:
- env COMPOSE_PROFILES="frontend" just ../up {{ flags }}
+ env COMPOSE_PROFILES="frontend" just ../up "$@"
# Wait for all profile services to be up
wait-up: up
@@ -67,8 +68,9 @@ init: wait-up
cd .. && ./setup_plausible.sh
# Run a package.json script via pnpm
+[positional-arguments]
run *args:
- pnpm run {{ args }}
+ pnpm run "$@"
# Generate the specified kind of documentation
generate-docs doc="media-props" fail_on_diff="true":
diff --git a/indexer_worker/justfile b/indexer_worker/justfile
index 4669b9e04..47cdd69d7 100644
--- a/indexer_worker/justfile
+++ b/indexer_worker/justfile
@@ -33,8 +33,9 @@ install *args="--dev":
######
# Bring up services specific to the indexer worker profile
+[positional-arguments]
up *flags:
- env COMPOSE_PROFILES="catalog_indexer_worker" just ../up {{ flags }}
+ env COMPOSE_PROFILES="catalog_indexer_worker" just ../up "$@"
wait-up: up
just wait
@@ -77,9 +78,12 @@ curl-post data host="localhost:50281":
# Tests #
#########
+# Run indexer worker tests in the container
+[positional-arguments]
test *args: wait-up
- just ../exec catalog_indexer_worker pytest {{ args }}
+ just ../exec catalog_indexer_worker pytest "$@"
# Run indexer-worker tests locally
+[positional-arguments]
test-local *args:
- pdm run pytest {{ args }}
+ pdm run pytest "$@"
diff --git a/justfile b/justfile
index 851b31f39..037ef385a 100644
--- a/justfile
+++ b/justfile
@@ -4,9 +4,6 @@ set dotenv-load := false
# @ - Quiet recipes (https://github.com/casey/just#quiet-recipes)
# _ - Private recipes (https://github.com/casey/just#private-recipes)
-IS_PROD := env_var_or_default("PROD", env_var_or_default("IS_PROD", ""))
-# `PROD_ENV` can be "ingestion_server" or "catalog"
-PROD_ENV := env_var_or_default("PROD_ENV", "")
IS_CI := env_var_or_default("CI", "")
DC_USER := env_var_or_default("DC_USER", "opener")
@@ -171,14 +168,7 @@ lint-codeowners checks="stable":
# Docker #
##########
-DOCKER_FILE := "-f " + (
- if IS_PROD == "true" {
- if PROD_ENV == "ingestion_server" { "ingestion_server/docker-compose.yml" }
- else if PROD_ENV == "catalog" { "catalog/docker-compose.yml" }
- else { "docker-compose.yml" }
- }
- else { "docker-compose.yml" }
-)
+DOCKER_FILE := "-f docker-compose.yml"
EXEC_DEFAULTS := if IS_CI == "" { "" } else { "-T" }
export CATALOG_PY_VERSION := `just catalog/py-version`
@@ -207,13 +197,15 @@ versions:
EOF
# Run `docker compose` configured with the correct files and environment
+[positional-arguments]
dc *args:
@{{ if IS_CI != "" { "just env" } else { "true" } }}
- env COMPOSE_PROFILES="{{ env_var_or_default("COMPOSE_PROFILES", "api,ingestion_server,frontend,catalog") }}" docker compose {{ DOCKER_FILE }} {{ args }}
+ env COMPOSE_PROFILES="{{ env_var_or_default("COMPOSE_PROFILES", "api,ingestion_server,frontend,catalog") }}" docker compose {{ DOCKER_FILE }} "$@"
# Build all (or specified) services
+[positional-arguments]
build *args:
- just dc build {{ args }}
+ just dc build "$@"
# List all services and their URLs and ports
@ps:
@@ -223,11 +215,12 @@ build *args:
# Also see `up` recipe in sub-justfiles
# Bring all Docker services up, in all profiles
+[positional-arguments]
up *flags: env && ps
#!/usr/bin/env bash
set -eo pipefail
while true; do
- if just dc up {{ if IS_CI != "" { "--quiet-pull" } else { "" } }} -d {{ flags }} ; then
+ if just dc up {{ if IS_CI != "" { "--quiet-pull" } else { "" } }} -d "$@" ; then
break
fi
((c++)) && ((c==3)) && break
@@ -249,8 +242,9 @@ init:
just frontend/init
# Take all Docker services down, in all profiles
+[positional-arguments]
down *flags:
- just dc down {{ flags }}
+ just dc down "$@"
# Take all services down then call the specified app's up recipe. ex.: `just dup catalog` is useful for restarting the catalog with new environment variables
dup app:
@@ -259,7 +253,7 @@ dup app:
# Recreate all volumes and containers from scratch
recreate:
just down -v
- just up "--force-recreate --build"
+ just up --force-recreate --build
just init
# Bust pnpm cache and reinstall Node.js dependencies
@@ -277,12 +271,14 @@ attach service:
docker attach $(just dc ps | awk '{print $1}' | grep {{ service }})
# Execute statement in service containers using Docker Compose
+[positional-arguments]
exec +args:
- just dc exec -u {{ env_var_or_default("DC_USER", "root") }} {{ EXEC_DEFAULTS }} {{ args }}
+ just dc exec -u {{ env_var_or_default("DC_USER", "root") }} {{ EXEC_DEFAULTS }} "$@"
# Execute statement in a new service container using Docker Compose
+[positional-arguments]
run +args:
- just dc run --rm -u {{ env_var_or_default("DC_USER", "root") }} {{ EXEC_DEFAULTS }} "{{ args }}"
+ just dc run --rm -u {{ env_var_or_default("DC_USER", "root") }} {{ EXEC_DEFAULTS }} "$@"
# Execute pgcli against one of the database instances
_pgcli container db_user_pass db_name db_host db_port="5432":
@@ -352,20 +348,31 @@ f:
just frontend/run dev
# alias for `pnpm --filter {package} run {script}`
-p package script +args="":
- pnpm --filter {{ package }} run {{ script }} {{ args }}
+[positional-arguments]
+p package script *args:
+ pnpm --filter {{ package }} run {{ script }} "${@:3}"
# Run eslint with --fix and default file selection enabled; used to enable easy file overriding whilst retaining the defaults when running --all-files
-eslint *files="frontend automations/js packages/js .pnpmfile.cjs .eslintrc.js prettier.config.js tsconfig.base.json":
+[positional-arguments]
+eslint *args:
+ #! /usr/bin/env bash
just p '@openverse/eslint-plugin' build
+ if [[ "$@" ]]; then
+ files=("$@")
+ else
+ # default files
+ files=(frontend automations/js packages/js .pnpmfile.cjs .eslintrc.js prettier.config.js tsconfig.base.json)
+ fi
+
pnpm exec eslint \
--ext .js,.ts,.vue,.json,.json5 \
--ignore-path .gitignore \
--ignore-path .eslintignore \
--max-warnings=0 \
--fix \
- {{ files }}
+ "${files[@]}"
# Alias for `just packages/js/k6/run` or `just p k6 run`
+[positional-arguments]
@k6 *args:
- just packages/js/k6/run {{ args }}
+ just packages/js/k6/run "$@"
diff --git a/packages/js/k6/justfile b/packages/js/k6/justfile
index 64c59654a..dc6c2e609 100644
--- a/packages/js/k6/justfile
+++ b/packages/js/k6/justfile
@@ -1,4 +1,5 @@
# Build and run K6 script by namespace and scenario
-run namespace scenario +extra_args="":
+[positional-arguments]
+run namespace scenario *extra_args:
pnpm run build --input src/{{ namespace }}/{{ scenario }}.test.ts
- k6 run {{ extra_args }} ./dist/{{ namespace }}/{{ scenario }}.test.js
+ k6 run "${@:3}" ./dist/{{ namespace }}/{{ scenario }}.test.js
diff --git a/packages/python/openverse-attribution/justfile b/packages/python/openverse-attribution/justfile
index 56cb7e75a..250ef73c0 100644
--- a/packages/python/openverse-attribution/justfile
+++ b/packages/python/openverse-attribution/justfile
@@ -14,5 +14,6 @@ NO_COLOR := "\\033[0m"
###########
# Install dependencies
+[positional-arguments]
install *args:
- pdm install {{ args }}
+ pdm install "$@"