pdme/do.sh
Deepak Mallubhotla 96a3a8fac4
All checks were successful
gitea-physics/pdme/pipeline/pr-master This commit looks good
nix: nixifies do.sh
2022-06-12 11:24:27 -05:00

61 lines
1.2 KiB
Bash

#!/usr/bin/env bash
# Do - The Simplest Build Tool on Earth.
# Documentation and examples see https://github.com/8gears/do
set -Eeuo pipefail # -e "Automatic exit from bash shell script on error" -u "Treat unset variables and parameters as errors"
checknix() {
if [[ "${DO_NIX_CUSTOM:=0}" -eq 1 ]]; then
echo "In an interactive nix env."
else
echo "Using poetry as runner, no nix detected."
fi
}
build() {
echo "I am ${FUNCNAME[0]}ing"
poetry build
}
fmt() {
if [[ "${DO_NIX_CUSTOM:=0}" -eq 1 ]]; then
black .
else
poetry run black .
fi
find . -type f -name "*.py" -exec sed -i -e 's/ /\t/g' {} \;
}
test() {
echo "I am ${FUNCNAME[0]}ing"
if [[ "${DO_NIX_CUSTOM:=0}" -eq 1 ]]; then
flake8 pdme tests
mypy pdme
pytest
else
poetry run flake8 pdme tests
poetry run mypy pdme
poetry run pytest
fi
}
htmlcov() {
if [[ "${DO_NIX_CUSTOM:=0}" -eq 1 ]]; then
pytest --cov-report=html
else
poetry run pytest --cov-report=html
fi
}
release() {
./scripts/release.sh
}
all() {
build && fmt && test
}
"$@" # <- execute the task
[ "$#" -gt 0 ] || printf "Usage:\n\t./do.sh %s\n" "($(compgen -A function | grep '^[^_]' | paste -sd '|' -))"