Skip to content

Commit

Permalink
Update scripts and contributing guide (#681)
Browse files Browse the repository at this point in the history
* Add script requirements to Contributing guide

* Add bash version checks

* Explicitly mention sed
  • Loading branch information
jw013 authored Mar 3, 2024
1 parent 491bf13 commit 781abd0
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 0 deletions.
19 changes: 19 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
- [Design goals](#design-goals)
- [Running `cargo test` for the first time](#running-cargo-test-for-the-first-time)
- [Adding a new lint](#adding-a-new-lint)
- [Development Environment](#development-environment)

## Making your first contribution

Expand All @@ -19,6 +20,8 @@ and relies on similar information.
For example, if implementing a lint that uses information about attributes,
find other lints that check attribute information and use them as guides as you write your lint.

Make sure to check the ["Development Environment"](#development-environment) section, especially if you are using Mac or Windows.

The ["Adding a new lint"](#adding-a-new-lint) section of this document has a walkthrough for
defining and testing new lints.

Expand Down Expand Up @@ -243,3 +246,19 @@ So if you added code to a test crate and it caused other lints to report new fin

If the answer to all is yes, then everything is fine! Just edit those other lints'
expected output files to include the new items, and you can get back on track.

## Development Environment

While cargo-semver-checks is cross platform, the development task automation scripts in the scripts
directory are not. In particular, they require

- GNU command line tools (coreutils, grep, sed, etc.)
- a relatively modern `bash` (at least version 4.0)
- `curl`
- [`jq`](https://jqlang.github.io/jq/)

Linux users likely have all of these already installed or available via their package manager.
Windows users can get a bash + GNU command line environment via WSL or git bash.
Mac users can install GNU tools via homebrew. The scripts will not work
correctly using the default bash and BSD command line utilities that come with
Mac OS.
6 changes: 6 additions & 0 deletions scripts/get_current_version.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
#!/usr/bin/env bash

# check for bash using maximum compatibility sh syntax
if [ -z "$BASH_VERSION" ]; then
>&2 printf 'This script must be run using the bash shell.\n'
exit 1
fi

# Script requirements:
# - curl
# - jq
Expand Down
6 changes: 6 additions & 0 deletions scripts/is_version_already_uploaded.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
#!/usr/bin/env bash

# check for bash using maximum compatibility sh syntax
if [ -z "$BASH_VERSION" ]; then
>&2 printf 'This script must be run using the bash shell.\n'
exit 1
fi

# Script requirements:
# - curl
# - jq
Expand Down
6 changes: 6 additions & 0 deletions scripts/make_new_lint.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
#!/usr/bin/env bash

# check for bash using maximum compatibility sh syntax
if [ -z "$BASH_VERSION" ]; then
>&2 printf 'This script must be run using the bash shell.\n'
exit 1
fi

# Fail on first error, on undefined variables, and on failures in pipelines.
set -euo pipefail

Expand Down
6 changes: 6 additions & 0 deletions scripts/make_new_test_crate.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
#!/usr/bin/env bash

# check for bash using maximum compatibility sh syntax
if [ -z "$BASH_VERSION" ]; then
>&2 printf 'This script must be run using the bash shell.\n'
exit 1
fi

# Fail on first error, on undefined variables, and on failures in pipelines.
set -euo pipefail

Expand Down
12 changes: 12 additions & 0 deletions scripts/regenerate_test_rustdocs.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
#!/usr/bin/env bash

# check for bash using maximum compatibility sh syntax
if [ -z "$BASH_VERSION" ]; then
>&2 printf 'This script must be run using the bash shell.\n'
exit 1
fi

# have bash, check version
if (( BASH_VERSINFO[0] < 4 )); then
>&2 printf 'This script requires bash version 4.0 or greater.\n'
exit 1
fi

# Fail on first error, on undefined variables, and on failures in pipelines.
set -euo pipefail

Expand Down

0 comments on commit 781abd0

Please sign in to comment.