Skip to content

Commit 77bd052

Browse files
committed
ci: add cargo check and cargo doc checks
Ensure that all PRs pass `cargo check` and `cargo doc` builds before they are gated into the full build matrix. In addition, we add GHA annotations to improve error messages.
1 parent 69ac26c commit 77bd052

File tree

1 file changed

+33
-17
lines changed

1 file changed

+33
-17
lines changed

.github/workflows/workflow.yml

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -29,30 +29,22 @@ jobs:
2929
if: github.event.pull_request.base.sha
3030
run: |
3131
git diff --check "${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}" || {
32-
echo >&2 "Your pull request introduces whitespace errors,";
33-
echo >&2 "which is not allowed. Please run:";
34-
echo >&2;
35-
echo >&2 " git rebase --whitespace=fix";
36-
echo >&2 " git push -f";
37-
echo >&2;
38-
echo >&2 "to correct and resubmit.";
32+
echo \
33+
'::error title={Failed git diff --check}::Your pull request introduces whitespace errors, which is not allowed. Please run:%0A%0A'\
34+
' git rebase --whitespace=fix%0A'\
35+
' git push -f%0A%0Ato correct and resubmit.'
3936
exit 1;
4037
}
4138
4239
- name: Checking for cargo-fmt errors (PRs only)
4340
if: github.event.pull_request.base.sha
4441
run: |
4542
cargo fmt --check || { \
46-
echo >&2 "Your pull request does not conform to cargo-fmt";
47-
echo >&2 "Rust format, which is not allowed. Please run:";
48-
echo >&2;
49-
echo >&2 " cargo fmt";
50-
echo >&2 " git commit -a --amend";
51-
echo >&2 " git push -f";
52-
echo >&2;
53-
echo >&2 "to correct and resubmit. If \`cargo fmt\` touches";
54-
echo >&2 "code which is not part of your MR, please let us";
55-
echo >&2 "know in the comments.";
43+
echo \
44+
'::error title={Failed cargo-fmt --check}::Your pull request does not conform to cargo-fmt, which is not allowed. Please run:%0A%0A' \
45+
' cargo fmt%0A' \
46+
' git commit -a --amend%0A' \
47+
' git push -f%0A%0Ato correct and resubmit. If the `cargo fmt` touches code which is not part of your original PR, please let us know in the comments.'
5648
exit 1;
5749
}
5850
@@ -88,6 +80,30 @@ jobs:
8880
mkdir -p vendor
8981
cargo vendor --versioned-dirs --locked >.cargo/config.toml
9082
83+
- name: Check Rust lints (PRs only)
84+
if: github.event.pull_request.base.sha
85+
run: |
86+
cargo check --frozen --locked --workspace || { \
87+
echo \
88+
'::error title={Failed cargo-check}::`cargo check` must pass without errors. Please correct Rust compiler lints. When you are finished, please run:%0A%0A' \
89+
' cargo fmt%0A' \
90+
' git commit -a --amend%0A' \
91+
' git push -f%0A%0Ato correct and resubmit. If this requires you to touch code which is not part of your original PR, please let us know in the comments.'
92+
exit 1;
93+
}
94+
95+
- name: Check documentation build (PRs only)
96+
if: github.event.pull_request.base.sha
97+
run: |
98+
cargo doc --frozen --locked --no-deps --workspace || { \
99+
echo \
100+
'::error title={Failed cargo-doc build}::Documentation failed to build. `cargo doc` must be able to generate crate documentation without errors. Please fix. When you are finished, please run:%0A%0A' \
101+
' cargo fmt%0A' \
102+
' git commit -a --amend%0A' \
103+
' git push -f%0A%0Ato correct and resubmit. If this requires you to touch code which is not part of your original PR, please let us know in the comments.'
104+
exit 1;
105+
}
106+
91107
# test sameold with all crate feature combinations,
92108
# in our Linux container
93109
test_sameold:

0 commit comments

Comments
 (0)