From 3c4ef490a861427817c57e1204c4e41f3fd5fe73 Mon Sep 17 00:00:00 2001 From: Aaron Pham Date: Sun, 3 Nov 2024 19:31:20 -0500 Subject: [PATCH] chore(ci): enable rust conditional check (#790) --- .github/workflows/ci.yaml | 49 ++++-------------------------- .github/workflows/release.yaml | 24 +++++++-------- .github/workflows/rust.yaml | 55 ++++++++++++++++++++++++++++++++++ 3 files changed, 72 insertions(+), 56 deletions(-) create mode 100644 .github/workflows/rust.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index e2da7af..9a9147c 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,4 +1,4 @@ -name: CI +name: Lua CI on: push: @@ -13,8 +13,8 @@ jobs: name: Check Lua style runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - uses: JohnnyMorganz/stylua-action@v4 + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # ratchet:actions/checkout@v4 + - uses: JohnnyMorganz/stylua-action@b6661824b86c9c33121bed87a778b660ba90cf77 # ratchet:JohnnyMorganz/stylua-action@v4 with: token: ${{ secrets.GITHUB_TOKEN }} version: latest @@ -24,47 +24,8 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # ratchet:actions/checkout@v4 - name: Luacheck linter - uses: lunarmodules/luacheck@v1 + uses: lunarmodules/luacheck@cc089e3f65acdd1ef8716cc73a3eca24a6b845e4 # ratchet:lunarmodules/luacheck@v1 with: args: ./lua/ - rust-tests: - name: Run Rust tests - runs-on: ubuntu-latest - if: github.event_name == 'push' || contains(github.event.pull_request.files.*.path, 'crates/') || contains(github.event.pull_request.files.*.path, '.cargo/') - steps: - - uses: actions/checkout@v4 - - uses: Swatinem/rust-cache@v2 - - uses: dtolnay/rust-toolchain@master - with: - toolchain: stable - components: clippy, rustfmt - - name: Run rust tests - run: cargo test --features luajit - rust: - name: Check Rust style - runs-on: ubuntu-latest - if: github.event_name == 'push' || contains(github.event.pull_request.files.*.path, 'crates/') || contains(github.event.pull_request.files.*.path, '.cargo/') - steps: - - uses: actions/checkout@v4 - - uses: Swatinem/rust-cache@v2 - - uses: dtolnay/rust-toolchain@master - with: - toolchain: stable - components: clippy, rustfmt - - name: Run rustfmt - run: make ruststylecheck - rustlint: - name: Lint Rust - runs-on: ubuntu-latest - if: github.event_name == 'push' || contains(github.event.pull_request.files.*.path, 'crates/') || contains(github.event.pull_request.files.*.path, '.cargo/') - steps: - - uses: actions/checkout@v4 - - uses: Swatinem/rust-cache@v2 - - uses: dtolnay/rust-toolchain@master - with: - toolchain: "1.80.1" - components: clippy, rustfmt - - name: Run rustfmt - run: make rustlint diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 8d4f41f..ab82637 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -2,11 +2,11 @@ name: Release on: push: - tags: [ v\d+\.\d+\.\d+ ] + tags: [v\d+\.\d+\.\d+] permissions: - contents: write - packages: write + contents: write + packages: write env: CARGO_TERM_COLOR: always @@ -22,11 +22,11 @@ jobs: release_body: "${{ steps.tag.outputs.message }}" steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # ratchet:actions/checkout@v4 - name: Get version id: get_version - uses: battila7/get-version-action@v2 + uses: battila7/get-version-action@d97fbc34ceb64d1f5d95f4dfd6dce33521ccccf5 # ratchet:battila7/get-version-action@v2 - name: Get tag message id: tag @@ -38,7 +38,7 @@ jobs: - name: Create Release id: create-release - uses: ncipollo/release-action@v1 + uses: ncipollo/release-action@2c591bcc8ecdcd2db72b97d6147f871fcd833ba5 # ratchet:ncipollo/release-action@v1 with: draft: true name: ${{ steps.get_version.outputs.version }} @@ -82,11 +82,11 @@ jobs: runs-on: ${{ matrix.config.os }} steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # ratchet:actions/checkout@v4 - - uses: Swatinem/rust-cache@v2 + - uses: Swatinem/rust-cache@82a92a6e8fbeee089604da2575dc567ae9ddeaab # ratchet:Swatinem/rust-cache@v2 if: ${{ matrix.config.container == null }} - - uses: dtolnay/rust-toolchain@master + - uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # ratchet:dtolnay/rust-toolchain@master if: ${{ matrix.config.container == null }} with: targets: ${{ matrix.config.rust_target }} @@ -141,7 +141,7 @@ jobs: Compress-Archive -Path $dllFiles -DestinationPath "avante_lib-${{ matrix.config.os_name }}-${{ matrix.config.arch }}-${{ matrix.feature }}.zip" - name: Upload Release Asset - uses: shogo82148/actions-upload-release-asset@v1 + uses: shogo82148/actions-upload-release-asset@8482bd769644976d847e96fb4b9354228885e7b4 # ratchet:shogo82148/actions-upload-release-asset@v1 if: ${{ matrix.config.os_name != 'windows' }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -150,7 +150,7 @@ jobs: upload_url: ${{ needs.create-release.outputs.release_upload_url }} asset_path: ./results/avante_lib-${{ matrix.config.os_name }}-${{ matrix.config.arch }}-${{ matrix.feature }}.tar.gz - name: Upload Release Asset (Windows) - uses: shogo82148/actions-upload-release-asset@v1 + uses: shogo82148/actions-upload-release-asset@8482bd769644976d847e96fb4b9354228885e7b4 # ratchet:shogo82148/actions-upload-release-asset@v1 if: ${{ matrix.config.os_name == 'windows' }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -168,7 +168,7 @@ jobs: steps: - name: publish release id: publish-release - uses: actions/github-script@v6 + uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # ratchet:actions/github-script@v6 env: release_id: ${{ needs.create-release.outputs.release_id }} with: diff --git a/.github/workflows/rust.yaml b/.github/workflows/rust.yaml new file mode 100644 index 0000000..28b04c7 --- /dev/null +++ b/.github/workflows/rust.yaml @@ -0,0 +1,55 @@ +name: Rust CI + +on: + push: + branches: + - main + paths: + - "crates/*" + - "Cargo.lock" + - "Cargo.toml" + pull_request: + branches: + - main + paths: + - "crates/*" + - "Cargo.lock" + - "Cargo.toml" + +jobs: + tests: + name: Run Rust tests + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # ratchet:actions/checkout@v4 + - uses: Swatinem/rust-cache@82a92a6e8fbeee089604da2575dc567ae9ddeaab # ratchet:Swatinem/rust-cache@v2 + - uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # ratchet:dtolnay/rust-toolchain@master + with: + toolchain: stable + components: clippy, rustfmt + - name: Run rust tests + run: cargo test --features luajit + style: + name: Check Rust style + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # ratchet:actions/checkout@v4 + - uses: Swatinem/rust-cache@82a92a6e8fbeee089604da2575dc567ae9ddeaab # ratchet:Swatinem/rust-cache@v2 + - uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # ratchet:dtolnay/rust-toolchain@master + with: + toolchain: stable + components: clippy, rustfmt + - name: Run rustfmt + run: make ruststylecheck + lint: + name: Lint Rust + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # ratchet:actions/checkout@v4 + - uses: Swatinem/rust-cache@82a92a6e8fbeee089604da2575dc567ae9ddeaab # ratchet:Swatinem/rust-cache@v2 + - uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # ratchet:dtolnay/rust-toolchain@master + with: + toolchain: "1.80.1" + components: clippy, rustfmt + - name: Run rustfmt + run: make rustlint