diff options
| author | Owen Jacobson <owen@grimoire.ca> | 2020-06-17 23:45:48 -0400 |
|---|---|---|
| committer | Owen Jacobson <owen@grimoire.ca> | 2020-06-17 23:58:31 -0400 |
| commit | e344f6c6245fe1121976b407a989af86c7453dad (patch) | |
| tree | 49f0290591c0c48d69607656db3a6f1f10323e7a | |
| parent | 3ccaa5f22c66874b274506fe784939806fb0f2db (diff) | |
Extracted checks into a tools directory.
Having the checks duplicated between .git-hooks and .travis.yml was a
recipe for them to diverge eventually. This is somewhat tidier, and
creates a clear convention for any future tools-like scripts.
I didn't do the same to install steps, as they're a lot more sensitive to the
specific environment - Travis requires different things from Github, which
requires different things from CircleCI, which requires different things from a
local environment.
| -rwxr-xr-x | .git-hooks/pre-commit | 7 | ||||
| -rw-r--r-- | .travis.yml | 7 | ||||
| -rw-r--r-- | tools/README.md | 26 | ||||
| -rwxr-xr-x | tools/check-dependencies | 7 | ||||
| -rwxr-xr-x | tools/check-lints | 8 | ||||
| -rwxr-xr-x | tools/check-tests | 8 | ||||
| -rwxr-xr-x | tools/checks | 11 |
7 files changed, 62 insertions, 12 deletions
diff --git a/.git-hooks/pre-commit b/.git-hooks/pre-commit index 7fd95fb..186a6e1 100755 --- a/.git-hooks/pre-commit +++ b/.git-hooks/pre-commit @@ -1,8 +1,3 @@ #!/bin/bash -e -# dup of the list in .travis.yml -cargo build --locked -cargo test -cargo fmt -- --check -cargo clippy -- --deny warnings -cargo udeps --locked --all-targets +exec tools/checks diff --git a/.travis.yml b/.travis.yml index 1b8bcad..db31059 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,10 +11,5 @@ install: - cargo install cargo-udeps - cargo build -# dup of the list in .git-hooks/pre-commit script: - - cargo build --locked - - cargo test - - cargo fmt -- --check - - cargo clippy -- --deny warnings - - cargo udeps --locked --all-targets + - tools/checks diff --git a/tools/README.md b/tools/README.md new file mode 100644 index 0000000..8c1b7e0 --- /dev/null +++ b/tools/README.md @@ -0,0 +1,26 @@ +# Local Tools + +The scripts in this directory assume they will be run from the root of the +project, as `tools/NAME`. They contain brief, branch-free, composable scripts +intended to be run to achieve frequent goals. They act as a shared shell +history, of a sorts, and as a place to put command-line-ish code that needs to +be shared by multiple components. + +Each script begins with a brief comment demonstrating the intended invocation +and the effects. + +## Authoring + +Tools _should_ begin with a shebang or shell `set` expression that enables +exiting on failure and that enables command echoing, followed by a documentation +comment: + +```bash +#!/bin/bash -ex + +# tools/my-example-tool +# +# Runs all example tasks. + +: … +``` diff --git a/tools/check-dependencies b/tools/check-dependencies new file mode 100755 index 0000000..36641e3 --- /dev/null +++ b/tools/check-dependencies @@ -0,0 +1,7 @@ +#!/bin/bash -ex + +# check-dependencies +# +# Checks that the dependencies in this project are all in use. + +cargo udeps --locked --all-targets diff --git a/tools/check-lints b/tools/check-lints new file mode 100755 index 0000000..1314896 --- /dev/null +++ b/tools/check-lints @@ -0,0 +1,8 @@ +#!/bin/bash -ex + +# tools/check-lints +# +# Checks that the code in this project passes style checks. + +cargo fmt -- --check +cargo clippy -- --deny warnings diff --git a/tools/check-tests b/tools/check-tests new file mode 100755 index 0000000..ef2a7bc --- /dev/null +++ b/tools/check-tests @@ -0,0 +1,8 @@ +#!/bin/bash -ex + +# tools/check-tests +# +# Checks that the code in this project passes incorrectness checks. + +cargo build --locked --all-targets +cargo test diff --git a/tools/checks b/tools/checks new file mode 100755 index 0000000..26a20ae --- /dev/null +++ b/tools/checks @@ -0,0 +1,11 @@ +#!/bin/bash -ex + +# tools/checks +# +# Runs all code checks. If you're automating testing, call this rather than +# invoking a test command directly; if you're adding a test command, add it here +# or to one of the tools called from this script. + +tools/check-tests +tools/check-lints +tools/check-dependencies |
