DEV Community

Cover image for GitHub action for multi-project Rust repository
Petr Janik
Petr Janik

Posted on

GitHub action for multi-project Rust repository

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

    branches: [ master ]
    branches: [ master ]



    runs-on: ubuntu-latest

    - uses: actions/checkout@v2
    - name: Build, test, clippy all
      run: sh -x ./scripts/
Enter fullscreen mode Exit fullscreen mode

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:

  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"

find . -name 'Cargo.toml' | sort -u | build_test_clippy
Enter fullscreen mode Exit fullscreen mode

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

Link to Code

Top comments (0)