From ab2b4ef5adc8651d96d46cdc64f61263080ca3f3 Mon Sep 17 00:00:00 2001 From: Tom <28008958+taeh98@users.noreply.github.com> Date: Sun, 1 Oct 2023 15:41:14 +0100 Subject: [PATCH 1/5] chore: made Rust CI workflow --- .github/workflows/rust_ci.yml | 85 +++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 .github/workflows/rust_ci.yml diff --git a/.github/workflows/rust_ci.yml b/.github/workflows/rust_ci.yml new file mode 100644 index 0000000..348f5da --- /dev/null +++ b/.github/workflows/rust_ci.yml @@ -0,0 +1,85 @@ +# This CI (Continuous Integration) file will automatically check your Rust code for errors. +# It will check the code compiles, run tests, run lints, and check for security issues. +# You should use CI to detect issues with your code easily and early. It will save lots of time and effort. +# 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 + - 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 From 1d83d3809940cc7bd072aa42e9093be66b47d2b2 Mon Sep 17 00:00:00 2001 From: Tom <28008958+taeh98@users.noreply.github.com> Date: Sun, 1 Oct 2023 15:47:22 +0100 Subject: [PATCH 2/5] added explanatory comments to rust_ci.yml --- .github/workflows/rust_ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/rust_ci.yml b/.github/workflows/rust_ci.yml index 348f5da..64c5cc2 100644 --- a/.github/workflows/rust_ci.yml +++ b/.github/workflows/rust_ci.yml @@ -1,6 +1,8 @@ # 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. -# You should use CI to detect issues with your code easily and early. It will save lots of time and effort. +# 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 From 219ed4295f2362d1ecebda24bc2dd44fed9ccd67 Mon Sep 17 00:00:00 2001 From: t <28008958+taeh98@users.noreply.github.com> Date: Sun, 1 Oct 2023 17:09:17 +0100 Subject: [PATCH 3/5] updated checkout action --- .github/workflows/rust_ci.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/rust_ci.yml b/.github/workflows/rust_ci.yml index 64c5cc2..5f5cc2f 100644 --- a/.github/workflows/rust_ci.yml +++ b/.github/workflows/rust_ci.yml @@ -23,7 +23,7 @@ jobs: name: Check code compiles runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable - uses: Swatinem/rust-cache@v2 - name: Run cargo check @@ -33,7 +33,7 @@ jobs: name: Run tests runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable - uses: Swatinem/rust-cache@v2 - name: Run tests @@ -43,7 +43,7 @@ jobs: name: Lint with rmstfmt runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable with: components: rustfmt @@ -54,7 +54,7 @@ jobs: name: Lint with clippy runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable with: components: clippy @@ -66,7 +66,7 @@ jobs: name: cargo deny runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: taiki-e/install-action@cargo-deny - name: Scan for vulnerabilities run: cargo deny check advisories @@ -75,7 +75,7 @@ jobs: name: cargo audit runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: actions-rs/toolchain@v1 with: profile: minimal From c90e4f064bfdc279bac1d9b3281b79e089d1fe15 Mon Sep 17 00:00:00 2001 From: t <28008958+taeh98@users.noreply.github.com> Date: Sun, 1 Oct 2023 17:15:18 +0100 Subject: [PATCH 4/5] used official cargo deny action --- .github/workflows/rust_ci.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/rust_ci.yml b/.github/workflows/rust_ci.yml index 5f5cc2f..5385d11 100644 --- a/.github/workflows/rust_ci.yml +++ b/.github/workflows/rust_ci.yml @@ -62,14 +62,12 @@ jobs: - name: Linting run: cargo clippy -- -D warnings - cargo_deny: + cargo-deny: name: cargo deny runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: taiki-e/install-action@cargo-deny - - name: Scan for vulnerabilities - run: cargo deny check advisories + - uses: EmbarkStudios/cargo-deny-action@v1 cargo-audit: name: cargo audit From 3cabf094c71f926e4fd0cd6a7e38b6134bf4d063 Mon Sep 17 00:00:00 2001 From: t <28008958+taeh98@users.noreply.github.com> Date: Sun, 1 Oct 2023 17:21:46 +0100 Subject: [PATCH 5/5] use nightly toolchain --- .github/workflows/rust_ci.yml | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/.github/workflows/rust_ci.yml b/.github/workflows/rust_ci.yml index 5385d11..4a73409 100644 --- a/.github/workflows/rust_ci.yml +++ b/.github/workflows/rust_ci.yml @@ -24,7 +24,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable + - uses: dtolnay/rust-toolchain@nightly - uses: Swatinem/rust-cache@v2 - name: Run cargo check run: cargo check @@ -34,7 +34,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable + - uses: dtolnay/rust-toolchain@nightly - uses: Swatinem/rust-cache@v2 - name: Run tests run: cargo test @@ -44,9 +44,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable + - uses: dtolnay/rust-toolchain@nightly with: components: rustfmt + - uses: Swatinem/rust-cache@v2 - name: Enforce formatting run: cargo fmt --check @@ -55,7 +56,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable + - uses: dtolnay/rust-toolchain@nightly with: components: clippy - uses: Swatinem/rust-cache@v2 @@ -74,11 +75,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true + - uses: dtolnay/rust-toolchain@nightly + - uses: Swatinem/rust-cache@v2 - name: Install cargo audit run: cargo install cargo-audit - name: Run "cargo audit" to check for vulnerabilities