Skip to content

Commit

Permalink
[CI] Abstarct an independent action to checkout and patch
Browse files Browse the repository at this point in the history
  • Loading branch information
Azure-stars committed Oct 19, 2024
1 parent 3ae4e1e commit 4fb2b63
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 48 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/actions/checkout/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Checkout repo and patch dependencies

inputs:
package:
description: 'The package that triggers the external test'
required: true
type: string
main-repo:
description: 'The main repository that runs the test'
required: true
type: string
main-ref:
description: 'The branch of the main repository'
required: false
default: 'main'
type: string

runs:
using: "composite"
steps:
- uses: actions/checkout@v4
with:
repository: ${{ inputs.main-repo }}
ref: ${{ inputs.main-ref }}
- name: Patch for the commit to be tested
run: |
cargo install dependencies-patch
dependencies-patch -c . \
-n ${{ inputs.package }} \
-t git --git-repo ${{ github.repository }} \
--commit ${{ github.sha }}
32 changes: 8 additions & 24 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,12 @@ jobs:
RUSTUP_TOOLCHAIN: ${{ matrix.rust-toolchain }}
steps:
- uses: actions/checkout@v4
if: inputs.package == ''
- uses: actions/checkout@v4
- uses: ./.github/workflows/actions/checkout
if: inputs.package != ''
with:
repository: ${{ env.prj-repo }}
ref: ${{ inputs.ref }}
- name: Patch for the commit to be tested
if: inputs.package != ''
run: |
cargo install dependencies-patch
dependencies-patch -c . \
-n ${{ inputs.package }} \
-t git --git-repo ${{ github.repository }} \
--commit ${{ github.sha }}
caller-package: ${{ inputs.package }}
main-repo: ${{ env.prj-repo }}
main-ref: ${{ inputs.ref }}
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ matrix.rust-toolchain }}
Expand Down Expand Up @@ -78,20 +70,12 @@ jobs:
RUSTUP_TOOLCHAIN: ${{ matrix.rust-toolchain }}
steps:
- uses: actions/checkout@v4
if: inputs.package == ''
- uses: actions/checkout@v4
- uses: ./.github/workflows/actions/checkout
if: inputs.package != ''
with:
repository: ${{ env.prj-repo }}
ref: ${{ inputs.ref }}
- name: Patch for the commit to be tested
if: inputs.package != ''
run: |
cargo install dependencies-patch
dependencies-patch -c . \
-n ${{ inputs.package }} \
-t git --git-repo ${{ github.repository }} \
--commit ${{ github.sha }}
caller-package: ${{ inputs.package }}
main-repo: ${{ env.prj-repo }}
main-ref: ${{ inputs.ref }}
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ matrix.rust-toolchain }}
Expand Down
32 changes: 8 additions & 24 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
if: inputs.package == ''
- uses: actions/checkout@v4
- uses: ./.github/workflows/actions/checkout
if: inputs.package != ''
with:
repository: ${{ env.prj-repo }}
ref: ${{ inputs.ref }}
- name: Patch for the commit to be tested
if: inputs.package != ''
run: |
cargo install dependencies-patch
dependencies-patch -c . \
-n ${{ inputs.package }} \
-t git --git-repo ${{ github.repository }} \
--commit ${{ github.sha }}
caller-package: ${{ inputs.package }}
main-repo: ${{ env.prj-repo }}
main-ref: ${{ inputs.ref }}
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ env.rust-toolchain }}
Expand All @@ -56,20 +48,12 @@ jobs:
arch: [x86_64, riscv64, aarch64]
steps:
- uses: actions/checkout@v4
if: inputs.package == ''
- uses: actions/checkout@v4
- uses: ./.github/workflows/actions/checkout
if: inputs.package != ''
with:
repository: ${{ env.prj-repo }}
ref: ${{ inputs.ref }}
- name: Patch for the commit to be tested
if: inputs.package != ''
run: |
cargo install dependencies-patch
dependencies-patch -c . \
-n ${{ inputs.package }} \
-t git --git-repo ${{ github.repository }} \
--commit ${{ github.sha }}
caller-package: ${{ inputs.package }}
main-repo: ${{ env.prj-repo }}
main-ref: ${{ inputs.ref }}
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ env.rust-toolchain }}
Expand Down

0 comments on commit 4fb2b63

Please sign in to comment.