-
Notifications
You must be signed in to change notification settings - Fork 0
CI: add build + lint + test job #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+64
−0
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
a5f8a23
feature(ci): add basic workflow for linting Rust code
Nazarevsky 2c3947a
feature(ci): add Taskfile.yml which includes a persistent test runnin…
Nazarevsky e33687e
feature(ci): add testing step, change formatting and linting commands…
Nazarevsky 9b9a4b3
feature(ci): add step that sets up task, change job name
Nazarevsky File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,37 @@ | ||
| name: CI | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: [master] | ||
|
|
||
| jobs: | ||
| build-lint-test: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Install Rust toolchain | ||
| uses: dtolnay/rust-toolchain@stable | ||
| with: | ||
| components: rustfmt, clippy | ||
|
|
||
| - name: Install protoc | ||
| uses: arduino/setup-protoc@v3 | ||
|
|
||
| - name: Cache cargo | ||
| uses: Swatinem/rust-cache@v2 | ||
|
|
||
| - name: Install Task | ||
| uses: arduino/setup-task@v2 | ||
| with: | ||
| version: 3.x | ||
|
|
||
| - name: Check formatting | ||
| run: task fmt:check | ||
|
|
||
| - name: Run clippy | ||
| run: task lint | ||
|
|
||
| - name: Run tests | ||
| run: task test |
This file contains hidden or 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,27 @@ | ||
| version: "3" | ||
|
|
||
| tasks: | ||
| fmt: | ||
| desc: "Format Rust code" | ||
| cmds: [cargo fmt] | ||
|
|
||
| fmt:check: | ||
| desc: "Check Rust code formatting" | ||
| cmds: [ cargo fmt --check] | ||
|
|
||
| lint: | ||
| desc: "Lint Rust code" | ||
| cmds: [cargo clippy --all-targets --all-features -- -D warnings] | ||
|
|
||
| test: | ||
| desc: "Test Rust code" | ||
| cmds: | ||
| # We want to be sure every workspace member is always tested. | ||
| # However, some members need special parameters | ||
| # (e.g. event-plugin tests must run in a single thread), | ||
| # so a single 'cargo test' can't cover everything correctly. | ||
| # Therefore, task:test runs every workspace member EXCEPT the | ||
| # excluded ones (e.g. event-plugin), and the excluded members | ||
| # are run separately with their own command. | ||
| - cargo test --workspace --exclude event-plugin | ||
| - cargo test -p event-plugin -- --test-threads=1 | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should create separate tasks/makefiles for each project and define a naming convention for tasks across all plugins (like, each plugin should have task called test, build, etc)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might have that one and thats sounds pretty logical. However, I'd like to go with more error-prone way. To have a task/makefile for each project is fine for me, but:
cargo fmttask command for each project taskfile. Of course, we can create a single taskfile and just import what we need from it, however, we'd like to make plugins independent from each other;The approach that I introduced here helps us to mitigate cases stated above - the code is always tested no matter a new plugin was introduced or not; no additional steps are required (unless there're some special testing cases that we might introduce); no code duplicated; plugins are independent. What do you think about my intention?