Skip to content

Commit

Permalink
[CI] Detect errors in piped commands (#289)
Browse files Browse the repository at this point in the history
To bolster reliability, incorporate the -o pipefail option, which
designates a command pipeline's overall return status as failed if any
individual command within it fails. Following this, integrating the -e
option can empower the script with the ability to promptly halt
execution.

Fixes #225
  • Loading branch information
zoo868e committed Aug 27, 2023
1 parent 0d6da06 commit 1ede214
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ jobs:
# actually compatible with.
- name: Set toolchain version
run: |
set -e
set -eo pipefail
function pkg-meta {
cargo metadata --format-version 1 | jq -r ".packages[] | select(.name == \"zerocopy\").$1"
Expand All @@ -111,7 +111,7 @@ jobs:
- name: Configure environment variables
run: |
set -e
set -eo pipefail
if [[ '${{ matrix.toolchain }}' == 'nightly' ]]; then
RUSTFLAGS="$RUSTFLAGS $ZC_NIGHTLY_RUSTFLAGS"
MIRIFLAGS="$MIRIFLAGS $ZC_NIGHTLY_MIRIFLAGS"
Expand Down Expand Up @@ -214,7 +214,7 @@ jobs:
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
- name: Check Rust formatting
run: |
set -e
set -eo pipefail
cargo fmt --check -p zerocopy
cargo fmt --check -p zerocopy-derive
shopt -s globstar
Expand All @@ -231,7 +231,7 @@ jobs:
uses: Swatinem/rust-cache@e207df5d269b42b69c8bc5101da26f7d31feddb4 # v2.6.2
- name: Check README.md
run: |
set -e
set -eo pipefail
cargo install cargo-readme --version 3.2.0
diff <(./generate-readme.sh) README.md
exit $?
Expand All @@ -245,7 +245,7 @@ jobs:
# files are the same.
- name: Check MSRVs match
run: |
set -e
set -eo pipefail
# Usage: msrv <crate-name>
function msrv {
Expand Down Expand Up @@ -274,7 +274,7 @@ jobs:
# `INTERNAL.md` for an explanation of why we do this.
- name: Check crate versions match
run: |
set -e
set -eo pipefail
# Usage: version <crate-name>
function version {
Expand Down
2 changes: 1 addition & 1 deletion generate-readme.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

set -e
set -eo pipefail

COPYRIGHT_HEADER=$(mktemp)
BODY=$(mktemp)
Expand Down

0 comments on commit 1ede214

Please sign in to comment.