Skip to content
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

chore: made Rust CI workflow #27

Merged
merged 5 commits into from
Oct 1, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 87 additions & 0 deletions .github/workflows/rust_ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# This CI (Continuous Integration) file will automatically check your Rust code for errors.
# It runs using GitHub Actions: https://docs.github.com/en/actions
# It will check the code compiles, run tests, run lints, and check for security issues.
# CI will help you standardise your code style and to detect issues with your code easily and early.
# It makes it easier to integrate different branches once they're finished.
# adapted from https://github.com/actions-rs/meta/blob/master/recipes/quickstart.md and https://gist.github.com/LukeMathWalker/5ae1107432ce283310c3e601fac915f3

name: Rust CI

on:
push:
# branches:
# - main
release:
types: [published]
pull_request:

env:
CARGO_TERM_COLOR: always

jobs:
check:
name: Check code compiles
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Run cargo check
run: cargo check

test:
name: Run tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two things with this:

  • LogicRs requires the nightly toolchain (idk if that's available with this toolchain provider)
  • I'd prefer if we used the official rust solution and not depend on third-party tools. I'm not that into CI, so if there's a good reason against that, please lmk

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, thanks for your feedback.

To your first point, yeah, I'll change it over to the nightly toolchain if that's what your code needs.

To your second, there isn't an official Rust GitHub action, but dtolnay/rust-toolchain is now what most people use. I think the checkout action has been updated though, so I'll update it and also recheck everything else is up-to-date too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK @Spydr06,

I just finished moving all the actions over to the nightly toolchain, updating the checkout action used, and moving everything over to the de-facto standard actions used for jobs. Please let me know if you have any further thoughts. Thanks! :)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To your second, rust-lang/rustup#3409. I think the checkout action has been updated though, so I'll update it and also recheck everything else is up-to-date too.

Ah ok, did not know that. Then it's fine ofc

- name: Run tests
run: cargo test

fmt:
name: Lint with rmstfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- name: Enforce formatting
run: cargo fmt --check

clippy:
name: Lint with clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- uses: Swatinem/rust-cache@v2
- name: Linting
run: cargo clippy -- -D warnings

cargo_deny:
name: cargo deny
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: taiki-e/install-action@cargo-deny
- name: Scan for vulnerabilities
run: cargo deny check advisories

cargo-audit:
name: cargo audit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Install cargo audit
run: cargo install cargo-audit
- name: Run "cargo audit" to check for vulnerabilities
run: cargo audit --color=always --deny=warnings