diff --git a/.github/workflows/code.yml b/.github/workflows/code.yml new file mode 100644 index 0000000..41eb13b --- /dev/null +++ b/.github/workflows/code.yml @@ -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 \ No newline at end of file diff --git a/Taskfile.yml b/Taskfile.yml new file mode 100644 index 0000000..3426ead --- /dev/null +++ b/Taskfile.yml @@ -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 \ No newline at end of file