My Workflow
I recently started learning Rust. If you are interested in following my journey, see the Rust series here on DEV.
For this, I created a repository containing multiple subfolders.
I would like to be able to build and test each of the projects for each pull request or when a new code is pushed to the master.
I started off the suggested rust.yml action.
name: Rust
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
env:
CARGO_TERM_COLOR: always
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build, test, clippy all
run: sh -x ./scripts/ci.sh
My build job includes one step, called Build, test, clippy all and it executes a bash script in the repository.
The script looks as follows:
build_test_clippy(){
while read path; do
printf "Project: %s\n" "$path"
cargo build --verbose --manifest-path "$path"
cargo test --verbose --manifest-path "$path"
cargo clippy --verbose --manifest-path "$path"
done
}
find . -name 'Cargo.toml' | sort -u | build_test_clippy
First, the find command finds all directories containing the
Cargo.toml file. This is like package.json if you are familiar with JavaScript.
In the directories it finds, it executes cargo build which builds the project, cargo test which runs the tests and cargo clippy which is a linter for Rust.
Submission Category:
Wacky Wildcards
Top comments (0)