Skip to content
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

use denv v1.1.0's quiet no-overwrite init flags #1492

Open
wants to merge 5 commits into
base: trunk
Choose a base branch
from
Open
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
50 changes: 36 additions & 14 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -102,19 +102,30 @@ debug config_py *ARGS:
# initialize a containerized development environment
init:
#!/usr/bin/env sh
# while setting the denv_workspace is helpful for other
# commands that can assume the denv is already initialized,
# we need to unset this environment variable to make sure
# the test is done appropriately.
# just makes sure this recipe runs from the directory of
# the justfile so we know we are in the correct location.
unset denv_workspace
if denv check --workspace --quiet; then
echo "\033[32mWorkspace already initialized.\033[0m"
denv config print
set -eu
denv_major=$(denv version | sed 's/denv v//' | cut -f 1 -d.)
denv_minor=$(denv version | sed 's/denv v//' | cut -f 2 -d.)
if [ "${denv_major}" -lt "1" ] || [ "${denv_minor}" -lt "1" ]; then
# denv v1.0.X or earlier, manually check for workspace
# which may print a confusing error from denv when no workspace is found
unset denv_workspace
# while setting the denv_workspace is helpful for other
# commands that can assume the denv is already initialized,
# we need to unset this environment variable to make sure
# the test is done appropriately.
# just makes sure this recipe runs from the directory of
# the justfile so we know we are in the correct location.
if denv check --workspace --quiet; then
echo "\033[32mWorkspace already initialized.\033[0m"
else
denv init --clean-env --name ldmx ldmx/dev:latest "${LDMX_BASE}"
fi
else
denv init --clean-env --name ldmx ldmx/dev:latest ${LDMX_BASE}
# denv v1.1.0 and later has updated denv init to allow us
# to avoid overwriting quietly
denv init --clean-env --no-over --no-mkdir --name ldmx ldmx/dev:latest "${LDMX_BASE}"
fi
denv config print

# check that the necessary programs for running ldmx-sw are present
check:
Expand Down Expand Up @@ -161,10 +172,21 @@ format-just:
# check the scripts for common errors and bugs
shellcheck:
#!/usr/bin/env sh
set -exu
set -x
format_list=$(mktemp)
git ls-tree -r HEAD | awk '{ if ($1 == 100755 || $4 ~ /\.sh/) print $4 }' > ${format_list}
shellcheck --severity style --shell sh $(cat ${format_list})
git ls-tree -r HEAD | awk '{ if ($1 == 100755 || $4 ~ /\.sh/) print $4 }' \
> "${format_list}"
xargs --arg-file="${format_list}" \
shellcheck --severity style --shell sh
rm "${format_list}"

# check a script recipe also using shellcheck
shellcheck-recipe RECIPE:
#!/usr/bin/env sh
source=$(mktemp)
just -n {{ RECIPE }} 2> "${source}"
shellcheck --severity style --shell sh "${source}"
rm "${source}"

# below are the mimics of ldmx <cmd>
# we could think about removing them if folks are happy with committing to the
Expand Down
Loading