-
Notifications
You must be signed in to change notification settings - Fork 202
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix just argument splitting on pass-through recipes with complex args #4961
Changes from 2 commits
51981b8
97aeed8
accf415
e834229
3a9fd32
f97a5e6
9904123
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#! /usr/bin/env sh | ||
#! /usr/bin/env bash | ||
set -e | ||
|
||
version() { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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") | ||
|
||
|
@@ -137,8 +134,9 @@ precommit: | |
fi | ||
|
||
# Run pre-commit to lint and reformat files | ||
[positional-arguments] | ||
lint hook="" *files="": precommit | ||
python3 pre-commit.pyz run {{ hook }} {{ if files == "" { "--all-files" } else { "--files" } }} {{ files }} | ||
python3 pre-commit.pyz run {{ hook }} {{ if files == "" { "--all-files" } else { "--files {{ files }}" } }} | ||
|
||
# Run codeowners validator locally. Only enable experimental hooks if there are no uncommitted changes. | ||
lint-codeowners checks="stable": | ||
|
@@ -171,14 +169,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 +198,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 +216,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 +243,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: | ||
|
@@ -277,12 +272,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 +349,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: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A handful of scripts used |
||
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 "$@" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These variables were used long ago when we used to deploy the ingestion server and catalog using
just
. We don't do that any more, and they just add noise/complexity to this file now, so are good to remove.