Skip to content

Commit 664b976

Browse files
authored
[ci] Permit skipping cargo-semver-checks step (#2084)
This is triggered when the most recent commit in a PR has a commit message which contains the string `SKIP_CARGO_SEMVER_CHECKS=1` on its own line. SKIP_CARGO_SEMVER_CHECKS=1 Closes #2083 gherrit-pr-id: Iffcecec3b7abfd48a67011d5979aa075b68da0ba
1 parent 6a5860b commit 664b976

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

.github/workflows/ci.yml

+21-1
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,25 @@ jobs:
482482
export RUSTDOCFLAGS="${{ matrix.toolchain == 'nightly' && '-Z unstable-options --document-hidden-items $METADATA_DOCS_RS_RUSTDOC_ARGS'|| '' }} $RUSTDOCFLAGS"
483483
./cargo.sh +${{ matrix.toolchain }} doc --document-private-items --package ${{ matrix.crate }} ${{ matrix.features }}
484484
485+
# If the commit message contains the line `SKIP_CARGO_SEMVER_CHECKS=1`, then
486+
# skip the cargo-semver-checks step.
487+
- name: Check whether to skip cargo-semver-checks
488+
run: |
489+
set -eo pipefail
490+
491+
if [ "${{ github.event_name }}" == "pull_request" ]; then
492+
# Invoked from a PR - get the PR body directly
493+
MESSAGE="${{ github.event.pull_request.body }}"
494+
else
495+
# Invoked from the merge queue - get the commit message
496+
MESSAGE="$(git log -1 --pretty=%B ${{ github.sha }})"
497+
fi
498+
499+
if echo "$MESSAGE" | grep '^\s*SKIP_CARGO_SEMVER_CHECKS=1\s*$' > /dev/null; then
500+
echo "Found 'SKIP_CARGO_SEMVER_CHECKS=1' in commit message; skipping cargo-semver-checks..." | tee -a $GITHUB_STEP_SUMMARY
501+
echo "ZC_SKIP_CARGO_SEMVER_CHECKS=1" >> $GITHUB_ENV
502+
fi
503+
485504
# Check semver compatibility with the most recently-published version on
486505
# crates.io. We do this in the matrix rather than in its own job so that it
487506
# gets run on different targets. Some of our API is target-specific (e.g.,
@@ -511,7 +530,8 @@ jobs:
511530
matrix.crate == 'zerocopy' &&
512531
matrix.features == '--features __internal_use_only_features_that_work_on_stable' &&
513532
matrix.toolchain == 'stable' &&
514-
matrix.target != 'wasm32-wasi'
533+
matrix.target != 'wasm32-wasi' &&
534+
env.ZC_SKIP_CARGO_SEMVER_CHECKS != '1'
515535
516536
# TODO(#453): Doing this as a matrix step is a hack that allows us to depend
517537
# on the fact that toolchains have already been installed. We currently only

0 commit comments

Comments
 (0)