-
Notifications
You must be signed in to change notification settings - Fork 214
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new GitHub Actions job to check that examples compile and are pro…
…perly formatted (#870) * Add workflow job to test examples on push or PR (`fmt` + `clippy`) * Fix clippy and formatting warnings and errors when running the new example validation script * Change caching key of the example validation job * Fix typo in `todo-actix` example * Fix missing execute permission on `validate-examples.sh` file * Modify job caching path to manually include `target`s from examples * Manually install stable and nightly Rust on `test (examples)` job This also installs the `clippy` and `rustfmt` components.
- Loading branch information
1 parent
7b74942
commit 8ab1e96
Showing
7 changed files
with
76 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
: "${CARGO:=cargo}" | ||
|
||
# Finds examples in the `./examples` directory. This query will also automatically | ||
# ignore directories that are not Rust projects (i.e. those that don't contain Cargo.toml). | ||
EXAMPLES=$(find ./examples/ -maxdepth 1 -mindepth 1 -type d -exec test -e "{}/Cargo.toml" ";" -print) | ||
|
||
|
||
for example in $EXAMPLES | ||
do | ||
echo "Checking example: $example..." | ||
|
||
pushd $example | ||
|
||
$CARGO fmt --check | ||
echo " -> example is properly formatted (passes cargo fmt)" | ||
$CARGO clippy --all-features --all-targets --workspace --quiet | ||
echo " -> example compiles (passes cargo clippy)" | ||
|
||
popd | ||
done | ||
|
||
echo "All examples are valid!" |