Use the local GitHub Action to replace setup-rust-action (#1371)

This commit is contained in:
hulk 2024-08-13 18:59:19 +08:00 committed by GitHub
parent 1e209d8741
commit ca5262c13f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 64 additions and 25 deletions

View file

@ -0,0 +1,42 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
name: Prepare Rust Builder
description: 'Prepare Rust Build Environment'
inputs:
rust-version:
description: 'version of rust to install (e.g. stable)'
required: true
default: 'stable'
targets:
description: 'The toolchain targets to add, comma-separated'
default: ''
runs:
using: "composite"
steps:
- name: Setup Rust Toolchain
shell: bash
run: |
echo "Installing ${{ inputs.rust-version }}"
if [ -n "${{ inputs.targets}}" ]; then
rustup toolchain install ${{ inputs.rust-version }} -t ${{ inputs.targets }}
else
rustup toolchain install ${{ inputs.rust-version }}
fi
rustup default ${{ inputs.rust-version }}
rustup component add rustfmt clippy

View file

@ -7,32 +7,29 @@ jobs:
codestyle: codestyle:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Set up Rust - uses: actions/checkout@v4
uses: hecrj/setup-rust-action@v2 - name: Setup Rust Toolchain
uses: ./.github/actions/setup-builder
with: with:
components: rustfmt
# Note that `nightly` is required for `license_template_path`, as # Note that `nightly` is required for `license_template_path`, as
# it's an unstable feature. # it's an unstable feature.
rust-version: nightly rust-version: nightly
- uses: actions/checkout@v4
- run: cargo +nightly fmt -- --check --config-path <(echo 'license_template_path = "HEADER"') - run: cargo +nightly fmt -- --check --config-path <(echo 'license_template_path = "HEADER"')
lint: lint:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Set up Rust
uses: hecrj/setup-rust-action@v2
with:
components: clippy
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Setup Rust Toolchain
uses: ./.github/actions/setup-builder
- run: cargo clippy --all-targets --all-features -- -D warnings - run: cargo clippy --all-targets --all-features -- -D warnings
compile: compile:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Set up Rust
uses: hecrj/setup-rust-action@v2
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Setup Rust Toolchain
uses: ./.github/actions/setup-builder
- run: cargo check --all-targets --all-features - run: cargo check --all-targets --all-features
docs: docs:
@ -40,19 +37,19 @@ jobs:
env: env:
RUSTDOCFLAGS: "-Dwarnings" RUSTDOCFLAGS: "-Dwarnings"
steps: steps:
- name: Set up Rust
uses: hecrj/setup-rust-action@v2
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Setup Rust Toolchain
uses: ./.github/actions/setup-builder
- run: cargo doc --document-private-items --no-deps --workspace --all-features - run: cargo doc --document-private-items --no-deps --workspace --all-features
compile-no-std: compile-no-std:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Set up Rust - uses: actions/checkout@v4
uses: hecrj/setup-rust-action@v2 - name: Setup Rust Toolchain
uses: ./.github/actions/setup-builder
with: with:
targets: 'thumbv6m-none-eabi' targets: 'thumbv6m-none-eabi'
- uses: actions/checkout@v4
- run: cargo check --no-default-features --target thumbv6m-none-eabi - run: cargo check --no-default-features --target thumbv6m-none-eabi
test: test:
@ -61,8 +58,10 @@ jobs:
rust: [stable, beta, nightly] rust: [stable, beta, nightly]
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Setup Rust - name: Checkout
uses: hecrj/setup-rust-action@v2 uses: actions/checkout@v4
- name: Setup Rust Toolchain
uses: ./.github/actions/setup-builder
with: with:
rust-version: ${{ matrix.rust }} rust-version: ${{ matrix.rust }}
- name: Install Tarpaulin - name: Install Tarpaulin
@ -71,16 +70,16 @@ jobs:
crate: cargo-tarpaulin crate: cargo-tarpaulin
version: 0.14.2 version: 0.14.2
use-tool-cache: true use-tool-cache: true
- name: Checkout
uses: actions/checkout@v4
- name: Test - name: Test
run: cargo test --all-features run: cargo test --all-features
test-coverage: test-coverage:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Setup Rust - name: Checkout
uses: hecrj/setup-rust-action@v2 uses: actions/checkout@v4
- name: Setup Rust Toolchain
uses: ./.github/actions/setup-builder
with: with:
rust-version: stable rust-version: stable
- name: Install Tarpaulin - name: Install Tarpaulin
@ -89,8 +88,6 @@ jobs:
crate: cargo-tarpaulin crate: cargo-tarpaulin
version: 0.14.2 version: 0.14.2
use-tool-cache: true use-tool-cache: true
- name: Checkout
uses: actions/checkout@v4
- name: Coverage - name: Coverage
run: cargo tarpaulin -o Lcov --output-dir ./coverage run: cargo tarpaulin -o Lcov --output-dir ./coverage
- name: Coveralls - name: Coveralls
@ -103,9 +100,9 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: [test] needs: [test]
steps: steps:
- name: Set up Rust
uses: hecrj/setup-rust-action@v2
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Setup Rust Toolchain
uses: ./.github/actions/setup-builder
- name: Publish - name: Publish
shell: bash shell: bash
run: | run: |