-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
53 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
name: Rust | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
|
||
jobs: | ||
test: | ||
name: Run Rust Tests | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
# Checkout the code | ||
- name: Checkout Code | ||
uses: actions/checkout@v4 | ||
|
||
# Set up Rust toolchain. | ||
# This will be overwritten anyway by a `rust-toolchain.toml` | ||
# file. | ||
- name: Setup Rust Toolchain | ||
uses: actions-rust-lang/setup-rust-toolchain@v1 | ||
with: | ||
toolchain: stable | ||
components: rustfmt | ||
|
||
# Run rustfmt and confirm no changes for each `blog/*/code` directory | ||
- name: Check Formatting | ||
run: | | ||
for dir in blog/*/code; do | ||
if [ -f "$dir/Cargo.toml" ]; then | ||
echo "Checking formatting in $dir" | ||
(cd "$dir" && cargo fmt --check) | ||
else | ||
echo "Skipping $dir as it does not contain a Cargo.toml file" | ||
fi | ||
done | ||
# Run tests for each `blog/*/code` directory | ||
- name: Build and Test | ||
run: | | ||
for dir in blog/*/code; do | ||
if [ -f "$dir/Cargo.toml" ]; then | ||
cd "$dir"; | ||
echo "Running build in $dir" | ||
cargo build --release | ||
echo "Running tests in $dir" | ||
cargo test --release | ||
else | ||
echo "Skipping $dir as it does not contain a Cargo.toml file" | ||
fi | ||
done |