Skip to content

Commit

Permalink
fixed linter warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
jwnmulder committed Dec 1, 2024
1 parent d60c25c commit 3d924c8
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 165 deletions.
67 changes: 13 additions & 54 deletions .envrc
Original file line number Diff line number Diff line change
@@ -1,69 +1,28 @@
set -euo pipefail
#!/usr/bin/env bash

strict_env

direnv_version 2.21

VIRTUAL_ENV=$PWD/.venv
VIRTUAL_ENV="$PWD/.venv"

# Setting strict-mode doesn't work for really old direnv versions. This however does
if [ ! $? -eq 0 ]; then
echo "Way to old direnv version (missing direnv_version), please upgrade first"
exit 1
if ! command -v uv > /dev/null 2>&1; then
echo "uv required, please install manually or run: curl -LsSf https://astral.sh/uv/install.sh | sh"
exit 1
fi

bold="$(tput bold)"
red="$(tput setaf 1)"
green="$(tput setaf 2)"
yellow="$(tput setaf 3)"
reset="$(tput sgr0)"

info() {
echo -e "${bold}${*}${reset}"
}

warn() {
echo -e "${yellow}${*}${reset}" >&2
log_level="warning"
}

die() {
echo -e "${red}${bold}FATAL: ${*}${reset}" >&2
error_message=("${@}")
log_level="error"
return 1
}

install_approved=false
continue_or_die() {
if ! cmp -s "$PWD/requirements.txt" ".venv/requirements.txt"; then

if [ "$install_approved" != "true" ]; then
warn "${bold}need${reset} to run install/update scripts (it can take a few minutes)"
echo -e "\n[10 sec] Continue (Y/n)?"
read -t 10 -r resp || true
case "$resp" in
n | N) die "Aborted!" ;;
*)
echo "Okay, let's do this."
install_approved=true
;;
esac
fi
}

if ! cmp -s "$PWD/requirements.txt" ".venv/requirements.xt"; then
continue_or_die

scripts/ensure-venv.sh "${VIRTUAL_ENV}"

cp "$PWD/requirements.txt" ".venv/requirements.xt"
uv venv
uv pip install --upgrade -r "$PWD/requirements.txt"
cp "$PWD/requirements.txt" ".venv/requirements.txt"
fi

export VIRTUAL_ENV
PATH_add "${VIRTUAL_ENV}/bin"

if ! cmp -s "$PWD/galaxy.yml" ".venv/galaxy.yml"; then

continue_or_die

collections_dir=$(readlink -f "$(pwd)/../../")
collections_dir_name=$(basename "$collections_dir")
if [ "${collections_dir_name}" != "ansible_collections" ]; then
Expand All @@ -72,9 +31,9 @@ if ! cmp -s "$PWD/galaxy.yml" ".venv/galaxy.yml"; then
fi

# Set ANSIBLE_COLLECTIONS_PATHS to avoid some warnings
export ANSIBLE_COLLECTIONS_PATHS="$collections_dir"
export ANSIBLE_COLLECTIONS_PATH="$collections_dir"

ansible-galaxy collection install --upgrade ansible.netcommon -p "$collections_dir"
uv run ansible-galaxy collection install --upgrade ansible.netcommon -p "$collections_dir"

cp "$PWD/galaxy.yml" ".venv/galaxy.yml"
fi
80 changes: 0 additions & 80 deletions rm_builder/.envrc

This file was deleted.

30 changes: 0 additions & 30 deletions scripts/ensure-venv.sh

This file was deleted.

2 changes: 1 addition & 1 deletion scripts/run-all-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ if [ "${collections_dir_name}" != "ansible_collections" ]; then
fi

# Set ANSIBLE_COLLECTIONS_PATHS to avoid some warnings
export ANSIBLE_COLLECTIONS_PATHS="$collections_dir"
export ANSIBLE_COLLECTIONS_PATH="$collections_dir"

echo "Running ansible-galaxy collection install"
ansible-galaxy collection install --upgrade ansible.netcommon -p "$collections_dir"
Expand Down

0 comments on commit 3d924c8

Please sign in to comment.