diff --git a/.github/actions/setup-builder/action.yml b/.github/actions/setup-builder/action.yml new file mode 100644 index 000000000..0af9ecf93 --- /dev/null +++ b/.github/actions/setup-builder/action.yml @@ -0,0 +1,38 @@ +# 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' +runs: + using: "composite" + steps: + - name: Setup Rust toolchain + shell: bash + run: | + echo "Installing ${{ inputs.rust-version }}" + rustup toolchain install ${{ inputs.rust-version }} + rustup default ${{ inputs.rust-version }} + rustup component add rustfmt clippy + - name: Fixup git permissions + # https://github.com/actions/checkout/issues/766 + shell: bash + run: git config --global --add safe.directory "$GITHUB_WORKSPACE" \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index db1261297..f54604728 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -42,24 +42,16 @@ jobs: - name: Check License Header uses: apache/skywalking-eyes/header@v0.6.0 - - name: Install Rust ${{ env.rust_nightly }} - uses: dtolnay/rust-toolchain@stable + - name: Setup Rust toolchain + uses: ./.github/actions/setup-builder with: - toolchain: ${{ env.rust_nightly }} + rust-version: ${{ env.rust_nightly }} - name: Install cargo-sort - uses: baptiste0928/cargo-install@v3 - with: - crate: cargo-sort - version: '1.0.9' + run: make install-cargo-sort - name: Install taplo-cli - uses: baptiste0928/cargo-install@v3 - with: - crate: taplo-cli - version: '0.9.0' - - - uses: Swatinem/rust-cache@v2 + run: make install-taplo-cli - name: Cargo format run: make check-fmt @@ -85,12 +77,10 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Install Rust ${{ env.rust_min }} - uses: dtolnay/rust-toolchain@stable + - name: Setup Rust toolchain + uses: ./.github/actions/setup-builder with: - toolchain: ${{ env.rust_min }} - - - uses: Swatinem/rust-cache@v2 + rust-version: ${{ env.rust_min }} - name: Build run: make build @@ -100,12 +90,10 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Install Rust ${{ env.rust_min }} - uses: dtolnay/rust-toolchain@stable + - name: Setup Rust toolchain + uses: ./.github/actions/setup-builder with: - toolchain: ${{ env.rust_min }} - - - uses: Swatinem/rust-cache@v2 + rust-version: ${{ env.rust_min }} - name: Test run: cargo test --no-fail-fast --all-targets --all-features --workspace diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 7dc6910fe..7693a570a 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -47,13 +47,11 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Install Rust ${{ env.rust_min }} - uses: dtolnay/rust-toolchain@stable + - name: Setup Rust toolchain + uses: ./.github/actions/setup-builder with: - toolchain: ${{ env.rust_min }} + rust-version: ${{ env.rust_min }} - - uses: Swatinem/rust-cache@v2 - - name: Dryrun ${{ matrix.package }} working-directory: ${{ matrix.package }} run: cargo publish --all-features --dry-run