Skip to content

Commit

Permalink
chore(ci): enable rust conditional check (yetone#790)
Browse files Browse the repository at this point in the history
  • Loading branch information
aarnphm authored Nov 4, 2024
1 parent 58e0165 commit 3c4ef49
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 56 deletions.
49 changes: 5 additions & 44 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: CI
name: Lua CI

on:
push:
Expand All @@ -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
Expand All @@ -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
24 changes: 12 additions & 12 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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 }}
Expand Down Expand Up @@ -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 }}
Expand Down Expand Up @@ -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 }}
Expand All @@ -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 }}
Expand All @@ -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:
Expand Down
55 changes: 55 additions & 0 deletions .github/workflows/rust.yaml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 3c4ef49

Please sign in to comment.