Skip to content

Commit

Permalink
Merge branch 'master' into mh-improve-format-script
Browse files Browse the repository at this point in the history
  • Loading branch information
mhucka authored Mar 4, 2025
2 parents 026c8dc + b16ef30 commit 4a93e2c
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 16 deletions.
4 changes: 2 additions & 2 deletions check/mypy
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
################################################################################

# Get the working directory to the repo root.
cd "$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "$(git rev-parse --show-toplevel)"
cd "$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" || exit 1
cd "$(git rev-parse --show-toplevel)" || exit 1

echo -e -n "\033[31m"
mypy --config-file=dev_tools/conf/mypy.ini "$@" .
Expand Down
6 changes: 3 additions & 3 deletions check/pylint
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
################################################################################

# Get the working directory to the repo root.
cd "$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "$(git rev-parse --show-toplevel)"
cd "$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" || exit 1
cd "$(git rev-parse --show-toplevel)" || exit 1

pylint --rcfile=dev_tools/conf/.pylintrc $@ src dev_tools
pylint --rcfile=dev_tools/conf/.pylintrc "$@" src dev_tools
11 changes: 6 additions & 5 deletions check/pytest
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Runs pytest on the repository.
#
# Usage:
# check/pytest [--actually-quiet] [--flags for pytest] [file-paths-relative-to-repo-root]
# check/pytest [--actually-quiet] [--flags for pytest] [paths-relative-to-root]
#
# The --actually-quiet argument filters out any progress output from pytest.
#
Expand All @@ -14,8 +14,8 @@
################################################################################

# Get the working directory to the repo root.
cd "$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "$(git rev-parse --show-toplevel)"
cd "$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" || exit 1
cd "$(git rev-parse --show-toplevel)" || exit 1

rootdir=$(pwd)

Expand All @@ -30,10 +30,11 @@ for arg in "$@"; do
done

if [ -z "${ACTUALLY_QUIET}" ]; then
pytest -c dev_tools/conf/pytest.ini --rootdir=$rootdir "${PYTEST_ARGS[@]}"
pytest -c dev_tools/conf/pytest.ini --rootdir="$rootdir" "${PYTEST_ARGS[@]}"
else
# Filter out lines like "...F....x... [ 42%]", with coloring.
pytest -c dev_tools/conf/pytest.ini --rootdir=$rootdir -q --color=yes "${PYTEST_ARGS[@]}" |
pytest -c dev_tools/conf/pytest.ini \
--rootdir="$rootdir" -q --color=yes "${PYTEST_ARGS[@]}" |
grep -Pv '^(.\[0m)?[\.FEsx]+(.\[36m)?\s+\[\s*\d+%\](.\[0m)?$'
exit "${PIPESTATUS[0]}"
fi
6 changes: 4 additions & 2 deletions check/pytest-and-incremental-coverage
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ cd "$( dirname "${BASH_SOURCE[0]}" )" || exit 1
cd "$(git rev-parse --show-toplevel)" || exit 1

# Figure out which revision to compare against.
if [ ! -z "$1" ] && [[ $1 != -* ]]; then
if [ "$(git cat-file -t $1 2> /dev/null)" != "commit" ]; then
if [[ -n "$1" && $1 != -* ]]; then
if [[ "$(git cat-file -t "$1" 2> /dev/null)" != "commit" ]]; then
echo -e "\033[31mNo revision '$1'.\033[0m" >&2
exit 1
fi
Expand All @@ -43,7 +43,9 @@ else
echo -e "\033[31mNo default revision found to compare against. Argument #1 must be what to diff against (e.g. 'origin/master' or 'HEAD~1').\033[0m" >&2
exit 1
fi
# shellcheck disable=SC2086
base="$(git merge-base ${rev} HEAD)"
# shellcheck disable=SC2086
if [ "$(git rev-parse ${rev})" == "${base}" ]; then
echo -e "Comparing against revision '${rev}'." >&2
else
Expand Down
3 changes: 2 additions & 1 deletion dev_tools/packaging/produce-package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,15 @@ function confirm() {
if [ -n "$(git status --short)" ]; then
echo -e "${RED}WARNING: There are uncommitted git changes."
echo -e "They won't be included in the package.${RESET}"
# shellcheck disable=SC2310
if ! confirm "${YELLOW}Proceed anyway?${RESET}"; then
echo "Stopping."
exit 1
fi
fi

tmp_git_dir=$(mktemp -d "/tmp/produce-package-git.XXXXXXXXXXXXXXXX")
trap "{ rm -rf $tmp_git_dir; }" EXIT
trap '{ rm -rf "$tmp_git_dir"; }' EXIT

cd "$tmp_git_dir"
git init --quiet
Expand Down
4 changes: 2 additions & 2 deletions dev_tools/packaging/publish-dev-package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ if [[ "${EXPECTED_VERSION}" != *dev* ]]; then
echo -e "\e[31mExpected version must include 'dev'.\e[0m"
exit 1
fi
ACTUAL_VERSION_LINE=$(cat "src/${PROJECT_NAME}/_version.py" | tail -n 1)
ACTUAL_VERSION_LINE=$(tail -n 1 "src/${PROJECT_NAME}/_version.py")
if [ "${ACTUAL_VERSION_LINE}" != '__version__ = "'"${EXPECTED_VERSION}"'"' ]; then
echo -e "\e[31mExpected version (${EXPECTED_VERSION}) didn't match the one in ${PROJECT_NAME}/_version.py (${ACTUAL_VERSION_LINE}).\e[0m"
exit 1
Expand Down Expand Up @@ -103,7 +103,7 @@ cd "$(git rev-parse --show-toplevel)"

# Temporary workspace.
tmp_package_dir=$(mktemp -d "/tmp/publish-dev-package_package.XXXXXXXXXXXXXXXX")
trap "{ rm -rf ${tmp_package_dir}; }" EXIT
trap '{ rm -rf "${tmp_package_dir}"; }' EXIT

# Produce packages.
dev_tools/packaging/produce-package.sh "${tmp_package_dir}" "${UPLOAD_VERSION}"
Expand Down
2 changes: 1 addition & 1 deletion dev_tools/packaging/verify-published-package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ REPO_ROOT="$(git rev-parse --show-toplevel)"
# Temporary workspace.
tmp_dir=$(mktemp -d "/tmp/verify-published-package.XXXXXXXXXXXXXXXX")
cd "${tmp_dir}"
trap "{ rm -rf ${tmp_dir}; }" EXIT
trap '{ rm -rf "$tmp_dir"; }' EXIT

# Prepare.
PYTHON_VERSION=python3
Expand Down

0 comments on commit 4a93e2c

Please sign in to comment.