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 24207d0
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 56 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/actions/checkout/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Checkout repo and patch dependencies

inputs:
caller-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

runs:
using: "composite"
steps:
- uses: actions/checkout@v4
if: inputs.caller-package == ''
- uses: actions/checkout@v4
if: inputs.caller-package != ''
with:
repository: ${{ inputs.main-repo }}
ref: ${{ github.sha }}
- name: Patch for the commit to be tested
if: inputs.caller-package != ''
run: |
cargo install dependencies-patch
dependencies-patch -c . \
-n ${{ inputs.caller-package }} \
-t git --git-repo ${{ github.repository }} \
--commit ${{ github.sha }}
34 changes: 6 additions & 28 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,10 @@ jobs:
env:
RUSTUP_TOOLCHAIN: ${{ matrix.rust-toolchain }}
steps:
- uses: actions/checkout@v4
if: inputs.package == ''
- uses: actions/checkout@v4
if: inputs.package != ''
- uses: ./actions/checkout
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 }}
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ matrix.rust-toolchain }}
Expand Down Expand Up @@ -77,21 +66,10 @@ jobs:
env:
RUSTUP_TOOLCHAIN: ${{ matrix.rust-toolchain }}
steps:
- uses: actions/checkout@v4
if: inputs.package == ''
- uses: actions/checkout@v4
if: inputs.package != ''
- uses: ./actions/checkout
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 }}
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ matrix.rust-toolchain }}
Expand Down
34 changes: 6 additions & 28 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,10 @@ jobs:
unit-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
if: inputs.package == ''
- uses: actions/checkout@v4
if: inputs.package != ''
- uses: ./actions/checkout
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 }}
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ env.rust-toolchain }}
Expand All @@ -55,21 +44,10 @@ jobs:
os: [ubuntu-latest]
arch: [x86_64, riscv64, aarch64]
steps:
- uses: actions/checkout@v4
if: inputs.package == ''
- uses: actions/checkout@v4
if: inputs.package != ''
- uses: ./actions/checkout
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 }}
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ env.rust-toolchain }}
Expand Down

0 comments on commit 24207d0

Please sign in to comment.