From aa6011674fb2b21e360c020c1ce7d9fe62904925 Mon Sep 17 00:00:00 2001 From: Jacob Alexander Date: Wed, 11 Oct 2023 17:15:05 -0700 Subject: [PATCH] Setup GitHub Actions for Rust --- .github/workflows/audit.yml | 69 +++++++++++++++++++++++ .github/workflows/build.yml | 5 +- .github/workflows/rust_linux.yml | 88 ++++++++++++++++++++++++++++++ .github/workflows/rust_macos.yml | 17 ++++++ .github/workflows/rust_windows.yml | 17 ++++++ 5 files changed, 195 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/audit.yml create mode 100644 .github/workflows/rust_linux.yml create mode 100644 .github/workflows/rust_macos.yml create mode 100644 .github/workflows/rust_windows.yml diff --git a/.github/workflows/audit.yml b/.github/workflows/audit.yml new file mode 100644 index 00000000..f80f02f7 --- /dev/null +++ b/.github/workflows/audit.yml @@ -0,0 +1,69 @@ +name: "Audit Dependencies" +on: + push: + paths: + # Run if workflow changes + - '.github/workflows/audit.yml' + # Run on changed dependencies + - '**/Cargo.toml' + - '**/Cargo.lock' + # Run if the configuration file changes + - '**/audit.toml' + # Rerun periodicly to pick up new advisories + schedule: + - cron: '0 0 * * *' + # Run manually + workflow_dispatch: + +permissions: read-all + +jobs: + audit: + runs-on: ubuntu-latest + permissions: + issues: write + steps: + - uses: actions/checkout@v3 + with: + submodules: true + - uses: dtolnay/rust-toolchain@nightly + - uses: actions-rust-lang/audit@v1 + name: Audit Rust Dependencies + with: + ignore: RUSTSEC-2020-0071,RUSTSEC-2021-0139 + + deny: + runs-on: ubuntu-latest + permissions: + issues: write + steps: + - uses: actions/checkout@v3 + with: + submodules: true + - uses: dtolnay/rust-toolchain@nightly + - name: cargo-binstall + run: | + mkdir -p ~/.cargo/bin + wget https://github.com/cargo-bins/cargo-binstall/releases/latest/download/cargo-binstall-x86_64-unknown-linux-musl.tgz + tar xf cargo-binstall*.tgz -C ~/.cargo/bin + - run: cargo binstall --no-confirm cargo-deny + - name: Cargo Deny + run: cargo deny check licenses + + pants: + runs-on: ubuntu-latest + permissions: + issues: write + steps: + - uses: actions/checkout@v3 + with: + submodules: true + - uses: dtolnay/rust-toolchain@nightly + - name: cargo-binstall + run: | + mkdir -p ~/.cargo/bin + wget https://github.com/cargo-bins/cargo-binstall/releases/latest/download/cargo-binstall-x86_64-unknown-linux-musl.tgz + tar xf cargo-binstall*.tgz -C ~/.cargo/bin + - run: cargo binstall --no-confirm cargo-pants + - name: Cargo Pants + run: cargo pants diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 83bc7d23..6e66d0da 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,6 +4,9 @@ on: [push, pull_request] env: PIPENV_ACTIVE: 1 + deb_packages: >- + libreadline-dev + libwxgtk3.0-gtk3-dev jobs: linux: @@ -15,7 +18,7 @@ jobs: - name: Install dependencies run: | sudo apt-get update - sudo apt-get install libwxgtk3.0-dev libreadline-dev -y + sudo apt-get install -y ${{ env.deb_packages }} - name: Build run: | make -j diff --git a/.github/workflows/rust_linux.yml b/.github/workflows/rust_linux.yml new file mode 100644 index 00000000..008f0361 --- /dev/null +++ b/.github/workflows/rust_linux.yml @@ -0,0 +1,88 @@ +name: Rust Linux + +on: [push, pull_request] + +env: + deb_packages: >- + libreadline-dev + libwxgtk3.0-gtk3-dev + +jobs: + check: + name: Check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@nightly + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y ${{ env.deb_packages }} + - name: Cargo Check + run: cargo check --all + + build: + name: Build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@nightly + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y ${{ env.deb_packages }} + - name: Cargo Build + run: cargo build --all + - name: Cargo Install + run: cargo install --path bossac --bins --root dist + - uses: actions/upload-artifact@v1.0.0 + with: + name: linux_release_binaries + path: dist/bin + + fmt: + name: Rustfmt + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@nightly + with: + components: rustfmt + - name: Rustfmt Check + uses: actions-rust-lang/rustfmt@v1 + + clippy: + name: Clippy + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@nightly + with: + components: clippy + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y ${{ env.deb_packages }} + - name: Cargo Clippy + run: cargo clippy --all-targets -- -D warnings + + udeps: + name: cargo-udeps + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + submodules: true + - uses: dtolnay/rust-toolchain@nightly + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y ${{ env.deb_packages }} + - name: cargo-binstall + run: | + mkdir -p ~/.cargo/bin + wget https://github.com/cargo-bins/cargo-binstall/releases/latest/download/cargo-binstall-x86_64-unknown-linux-musl.tgz + tar xf cargo-binstall*.tgz -C ~/.cargo/bin + - run: cargo binstall --no-confirm cargo-udeps + - name: Cargo Udeps + run: cargo udeps --all-targets diff --git a/.github/workflows/rust_macos.yml b/.github/workflows/rust_macos.yml new file mode 100644 index 00000000..514805d1 --- /dev/null +++ b/.github/workflows/rust_macos.yml @@ -0,0 +1,17 @@ +name: Rust macOS + +on: [push, pull_request] + +jobs: + build: + name: Build + runs-on: macOS-latest + steps: + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@nightly + - name: Cargo Install + run: cargo install --path bossac --bins --root dist + - uses: actions/upload-artifact@v1.0.0 + with: + name: macos_release_binaries + path: dist/bin diff --git a/.github/workflows/rust_windows.yml b/.github/workflows/rust_windows.yml new file mode 100644 index 00000000..50a4aa23 --- /dev/null +++ b/.github/workflows/rust_windows.yml @@ -0,0 +1,17 @@ +name: Rust Windows + +on: [push, pull_request] + +jobs: + build: + name: Build + runs-on: windows-latest + steps: + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@nightly + - name: Cargo Install + run: cargo install --path bossac --bins --root dist + - uses: actions/upload-artifact@v1.0.0 + with: + name: win_release_binaries + path: dist/bin