Skip to content

Improve scripts and tool configurations #1693

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

Merged
merged 32 commits into from
Oct 4, 2023
Merged
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
8c4df3c
Add pre-commit hook to run shellcheck
EliahKagan Sep 27, 2023
f3be76f
Force color when running shellcheck in pre-commit
EliahKagan Sep 27, 2023
7dd8add
Suppress SC2086 where word splitting is intended
EliahKagan Sep 27, 2023
21875b5
Don't split and glob the interpreter name
EliahKagan Sep 27, 2023
0920371
Extract suggest_venv out of the else block
EliahKagan Sep 27, 2023
e973f52
Use some handy bash-isms in version check script
EliahKagan Sep 27, 2023
be53823
Have init script treat master unambiguously as a branch
EliahKagan Sep 27, 2023
e604b46
Use 4-space indentation in all shell scripts
EliahKagan Sep 27, 2023
19dfbd8
Make the init script a portable POSIX shell script
EliahKagan Sep 27, 2023
7110bf8
Move extra tag-fetching step into init script
EliahKagan Sep 27, 2023
c7cdaf4
Reduce code duplication in version check script
EliahKagan Sep 27, 2023
f6dbba2
A couple more script tweaks for clarity
EliahKagan Sep 27, 2023
5060c9d
Explain what each step in the init script achieves
EliahKagan Sep 27, 2023
d5479b2
Use set -u in init script
EliahKagan Sep 28, 2023
52f9a68
Make the "all" Makefile target more robust
EliahKagan Sep 28, 2023
b88d07e
Use a single awk instead of two greps and a cut
EliahKagan Sep 28, 2023
d36818c
Add a black check to pre-commit
EliahKagan Sep 28, 2023
4ba5ad1
Fix typo in comment
EliahKagan Sep 28, 2023
5d8ddd9
Use two hooks for black: to check, and format
EliahKagan Sep 28, 2023
a872d9c
Pass --all-files explicitly so it is retained
EliahKagan Oct 3, 2023
9b9de11
Fix the formatting
EliahKagan Oct 3, 2023
5d15063
Add "make lint" to lint without auto-formatting
EliahKagan Sep 28, 2023
6de86a8
Update readme about most of the test/lint tools
EliahKagan Sep 28, 2023
f094909
Add BUILDDIR var to doc/Makefile; have tox use it
EliahKagan Sep 28, 2023
fc96980
Have init script check for GitHub Actions
EliahKagan Sep 28, 2023
b98f15e
Get tags for tests from original repo as fallback
EliahKagan Sep 29, 2023
7cca7d2
Don't print the exact same warning twice
EliahKagan Sep 29, 2023
e4e009d
Reword comment to fix ambiguity
EliahKagan Sep 29, 2023
e16e4c0
Format all YAML files in the same style
EliahKagan Sep 29, 2023
62c024e
Let tox run lint, mypy, and html envs without 3.9
EliahKagan Sep 29, 2023
9e245d0
Update readme: CI jobs not just for "main" branch
EliahKagan Oct 1, 2023
c2472e9
Note that the init script can be run from Git Bash
EliahKagan Oct 1, 2023
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
Prev Previous commit
Next Next commit
Suppress SC2086 where word splitting is intended
This suppresses ShellCheck SC2016, "Double quote to prevent
globbing and word splitting," on the command in the version check
script that expands $config_opts to build the "-c ..." arguments.

It also moves the code repsonsible for getting the latest tag,
which this is part of, into a function for that purpose, so it's
clear that building config_opts is specifically for that, and so
that the code is not made harder to read by adding the ShellCheck
suppression comment.

(The suppression applies only to the immediate next command.)
  • Loading branch information
EliahKagan committed Oct 3, 2023
commit 7dd8added2b1695b1740f0d1d7d7b2858a49a88c
10 changes: 8 additions & 2 deletions check-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ trap 'echo "$0: Check failed. Stopping." >&2' ERR
readonly version_path='VERSION'
readonly changes_path='doc/source/changes.rst'

function get_latest_tag() {
local config_opts
config_opts="$(printf ' -c versionsort.suffix=-%s' alpha beta pre rc RC)"
# shellcheck disable=SC2086 # Deliberately word-splitting the arguments.
git $config_opts tag -l '[0-9]*' --sort=-v:refname | head -n1
}

echo 'Checking current directory.'
test "$(cd -- "$(dirname -- "$0")" && pwd)" = "$(pwd)" # Ugly, but portable.

Expand All @@ -26,8 +33,7 @@ test -z "$(git status -s --ignore-submodules)"

version_version="$(cat "$version_path")"
changes_version="$(awk '/^[0-9]/ {print $0; exit}' "$changes_path")"
config_opts="$(printf ' -c versionsort.suffix=-%s' alpha beta pre rc RC)"
latest_tag="$(git $config_opts tag -l '[0-9]*' --sort=-v:refname | head -n1)"
latest_tag="$(get_latest_tag)"
head_sha="$(git rev-parse HEAD)"
latest_tag_sha="$(git rev-parse "${latest_tag}^{commit}")"

Expand Down