From 0956b404124f33b2cfe64f8240ffc024e9b9ea1a Mon Sep 17 00:00:00 2001 From: James Wilson Date: Tue, 26 Sep 2023 17:54:03 +0100 Subject: [PATCH] try composite action to avoid dupe use-substrate code (#1177) * try composite action to avoid dupe use-substrate code * put use-substrate in a folder * required 'shell' prop * re-use use-substrate action across CI * remove unnecessary bit from action readme --- .../workflows/actions/use-substrate/README.md | 3 + .../actions/use-substrate/action.yml | 19 ++++ .github/workflows/nightly.yml | 15 +-- .github/workflows/rust.yml | 105 +++--------------- 4 files changed, 38 insertions(+), 104 deletions(-) create mode 100644 .github/workflows/actions/use-substrate/README.md create mode 100644 .github/workflows/actions/use-substrate/action.yml diff --git a/.github/workflows/actions/use-substrate/README.md b/.github/workflows/actions/use-substrate/README.md new file mode 100644 index 0000000000..71f0a55fbf --- /dev/null +++ b/.github/workflows/actions/use-substrate/README.md @@ -0,0 +1,3 @@ +# use-substrate + +This action downloads the substrate binary produced from the `build-substrate` workflow and puts it into the `$PATH`. \ No newline at end of file diff --git a/.github/workflows/actions/use-substrate/action.yml b/.github/workflows/actions/use-substrate/action.yml new file mode 100644 index 0000000000..b3bffcd314 --- /dev/null +++ b/.github/workflows/actions/use-substrate/action.yml @@ -0,0 +1,19 @@ +name: Use substrate binary +description: Downloads and configures the substrate binary built with build-substrate +runs: + using: composite + steps: + - name: Download substrate-node binary + id: download-artifact + uses: dawidd6/action-download-artifact@268677152d06ba59fcec7a7f0b5d961b6ccd7e1e # v2.28.0 + with: + workflow: build-substrate.yml + name: nightly-substrate-binary + + - name: Prepare substrate-node binary + shell: bash + run: | + chmod u+x ./substrate-node + ./substrate-node --version + mkdir -p ~/.local/bin + cp ./substrate-node ~/.local/bin diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 2e82af2664..c67cdd5003 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -17,19 +17,8 @@ jobs: - name: Checkout sources uses: actions/checkout@v4 - - name: Download substrate-node binary - id: download-artifact - uses: dawidd6/action-download-artifact@268677152d06ba59fcec7a7f0b5d961b6ccd7e1e # v2.28.0 - with: - workflow: build-substrate.yml - name: nightly-substrate-binary - - - name: Prepare substrate-node binary - run: | - chmod u+x ./substrate-node - ./substrate-node --version - mkdir -p ~/.local/bin - cp ./substrate-node ~/.local/bin + - name: Use substrate-node binary + uses: ./.github/workflows/actions/use-substrate - name: Install Rust stable toolchain uses: actions-rs/toolchain@v1 diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 6cf003e7e0..171152d9b8 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -29,19 +29,8 @@ jobs: - name: Checkout sources uses: actions/checkout@v4 - - name: Download substrate-node binary - id: download-artifact - uses: dawidd6/action-download-artifact@268677152d06ba59fcec7a7f0b5d961b6ccd7e1e # v2.28.0 - with: - workflow: build-substrate.yml - name: nightly-substrate-binary - - - name: Prepare substrate-node binary - run: | - chmod u+x ./substrate-node - ./substrate-node --version - mkdir -p ~/.local/bin - cp ./substrate-node ~/.local/bin + - name: Use substrate-node binary + uses: ./.github/workflows/actions/use-substrate - name: Install Rust stable toolchain uses: actions-rs/toolchain@v1 @@ -141,19 +130,8 @@ jobs: - name: Checkout sources uses: actions/checkout@v4 - - name: Download substrate-node binary - id: download-artifact - uses: dawidd6/action-download-artifact@268677152d06ba59fcec7a7f0b5d961b6ccd7e1e # v2.28.0 - with: - workflow: build-substrate.yml - name: nightly-substrate-binary - - - name: Prepare substrate-node binary - run: | - chmod u+x ./substrate-node - ./substrate-node --version - mkdir -p ~/.local/bin - cp ./substrate-node ~/.local/bin + - name: Use substrate-node binary + uses: ./.github/workflows/actions/use-substrate - name: Install Rust stable toolchain uses: actions-rs/toolchain@v1 @@ -181,19 +159,8 @@ jobs: - name: Checkout sources uses: actions/checkout@v4 - - name: Download substrate-node binary - id: download-artifact - uses: dawidd6/action-download-artifact@268677152d06ba59fcec7a7f0b5d961b6ccd7e1e # v2.28.0 - with: - workflow: build-substrate.yml - name: nightly-substrate-binary - - - name: Prepare substrate-node binary - run: | - chmod u+x ./substrate-node - ./substrate-node --version - mkdir -p ~/.local/bin - cp ./substrate-node ~/.local/bin + - name: Use substrate-node binary + uses: ./.github/workflows/actions/use-substrate - name: Install Rust stable toolchain uses: actions-rs/toolchain@v1 @@ -221,19 +188,8 @@ jobs: - name: Checkout sources uses: actions/checkout@v3 - - name: Download substrate-node binary - id: download-artifact - uses: dawidd6/action-download-artifact@268677152d06ba59fcec7a7f0b5d961b6ccd7e1e # v2.28.0 - with: - workflow: build-substrate.yml - name: nightly-substrate-binary - - - name: Prepare substrate-node binary - run: | - chmod u+x ./substrate-node - ./substrate-node --version - mkdir -p ~/.local/bin - cp ./substrate-node ~/.local/bin + - name: Use substrate-node binary + uses: ./.github/workflows/actions/use-substrate - name: Install Rust stable toolchain uses: actions-rs/toolchain@v1 @@ -262,19 +218,8 @@ jobs: - name: Checkout sources uses: actions/checkout@v4 - - name: Download substrate-node binary - id: download-artifact - uses: dawidd6/action-download-artifact@268677152d06ba59fcec7a7f0b5d961b6ccd7e1e # v2.28.0 - with: - workflow: build-substrate.yml - name: nightly-substrate-binary - - - name: Prepare substrate-node binary - run: | - chmod u+x ./substrate-node - ./substrate-node --version - mkdir -p ~/.local/bin - cp ./substrate-node ~/.local/bin + - name: Use substrate-node binary + uses: ./.github/workflows/actions/use-substrate - name: Install Rust stable toolchain uses: actions-rs/toolchain@v1 @@ -311,19 +256,8 @@ jobs: - name: Rust Cache uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43 # v2.7.0 - - name: Download substrate-node binary - id: download-artifact - uses: dawidd6/action-download-artifact@268677152d06ba59fcec7a7f0b5d961b6ccd7e1e # v2.28.0 - with: - workflow: build-substrate.yml - name: nightly-substrate-binary - - - name: Prepare substrate-node binary - run: | - chmod u+x ./substrate-node - ./substrate-node --version - mkdir -p ~/.local/bin - cp ./substrate-node ~/.local/bin + - name: Use substrate-node binary + uses: ./.github/workflows/actions/use-substrate - name: Run subxt WASM tests run: | @@ -358,19 +292,8 @@ jobs: - name: Checkout sources uses: actions/checkout@v4 - - name: Download substrate-node binary - id: download-artifact - uses: dawidd6/action-download-artifact@268677152d06ba59fcec7a7f0b5d961b6ccd7e1e # v2.28.0 - with: - workflow: build-substrate.yml - name: nightly-substrate-binary - - - name: Prepare substrate-node binary - run: | - chmod u+x ./substrate-node - ./substrate-node --version - mkdir -p ~/.local/bin - cp ./substrate-node ~/.local/bin + - name: Use substrate-node binary + uses: ./.github/workflows/actions/use-substrate - name: Install Rust stable toolchain uses: actions-rs/toolchain@v1