-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* some stuff * update todo text * Update main.rs * Update format.sh * clippy fixes * clippy suggestion * clippy suggestion * more clippy fixes * clippy suggestions * clippy fixes * remove code which causes compiler error * more fixes * also run cargo test * Update check.sh * make it a proper check script * update comment * add workflow * update script to error and stop early * add rustfmt * try to break ci * fix ci * undo some clippy fixes * undo more str * use clone again * undo * add missing todo * missing todo * add newline * bring it back * Update check.sh
- Loading branch information
1 parent
b053dad
commit 4fa11a8
Showing
111 changed files
with
426 additions
and
317 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,28 @@ | ||
name: Check Tutorial | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
cargo: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Rust | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: nightly | ||
override: true | ||
components: rustfmt, clippy | ||
|
||
- name: Run format, lint, and test script | ||
run: ./check.sh | ||
shell: bash |
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,2 @@ | ||
book | ||
**/target/ |
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,77 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
# Default to 'check' mode if no argument is provided | ||
MODE=${1:-check} | ||
|
||
# Check if the mode is valid | ||
if [[ "$MODE" != "check" && "$MODE" != "fix" ]]; then | ||
echo "Invalid mode: $MODE. Use 'check' or 'fix'." | ||
exit 1 | ||
fi | ||
|
||
# Check if the 'steps' directory exists | ||
if [ ! -d "steps" ]; then | ||
echo "Directory 'steps' does not exist." | ||
exit 1 | ||
fi | ||
|
||
# Iterate through each subdirectory in the 'steps' directory | ||
for dir in steps/*/; do | ||
# Extract the directory name | ||
dir_name=$(basename "$dir") | ||
|
||
# Check if the directory contains a Cargo.toml file | ||
if [ ! -f "$dir/Cargo.toml" ]; then | ||
echo "Skipping directory (no Cargo.toml found): $dir" | ||
continue | ||
fi | ||
|
||
if [ -d "$dir" ]; then | ||
echo "Entering directory: $dir" | ||
cd "$dir" | ||
|
||
# Run cargo fmt and cargo clippy based on the mode | ||
if [ "$MODE" == "check" ]; then | ||
|
||
echo "Checking cargo fmt" | ||
cargo +nightly fmt -- --check | ||
|
||
echo "Checking cargo clippy" | ||
if [[ "$dir_name" =~ ^([1-9]|1[0-9]|2[0-6])$ ]]; then | ||
# We specifically allow `clippy::ptr-arg` in the first 26 steps, because | ||
# it helps minimize the transition to generic types. | ||
RUSTFLAGS="-A unused -A clippy::ptr-arg" cargo +nightly clippy -- -D warnings | ||
else | ||
RUSTFLAGS="-A unused" cargo +nightly clippy -- -D warnings | ||
fi | ||
|
||
echo "Checking cargo test" | ||
RUSTFLAGS="-A unused -D warnings" cargo test | ||
|
||
elif [ "$MODE" == "fix" ]; then | ||
|
||
echo "Running cargo fmt" | ||
RUSTFLAGS="-A unused" cargo +nightly fmt | ||
|
||
echo "Running cargo clippy" | ||
if [[ "$dir_name" =~ ^([1-9]|1[0-9]|2[0-6])$ ]]; then | ||
# We specifically allow `clippy::ptr-arg` in the first 26 steps, because | ||
# it helps minimize the transition to generic types. | ||
RUSTFLAGS="-A unused -A clippy::ptr-arg" cargo +nightly clippy --fix --allow-dirty | ||
else | ||
RUSTFLAGS="-A unused" cargo +nightly clippy --fix --allow-dirty | ||
fi | ||
|
||
echo "Running cargo test" | ||
RUSTFLAGS="-A unused -D warnings" cargo test | ||
|
||
fi | ||
|
||
# Return to the previous directory | ||
cd - > /dev/null | ||
fi | ||
done | ||
|
||
echo "All operations completed." |
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
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
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
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
Oops, something went wrong.