Skip to content

Commit

Permalink
Use action builder since apache doesn't allow external actions
Browse files Browse the repository at this point in the history
  • Loading branch information
liurenjie1024 committed Jul 7, 2024
1 parent dc430da commit 4862144
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 28 deletions.
38 changes: 38 additions & 0 deletions .github/actions/setup-builder/action.yml
Original file line number Diff line number Diff line change
@@ -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"
34 changes: 11 additions & 23 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
8 changes: 3 additions & 5 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4862144

Please sign in to comment.