From b867014c0b197d7aa5c944d8b2bb7f073148d0aa Mon Sep 17 00:00:00 2001 From: clearloop <26088946+clearloop@users.noreply.github.com> Date: Wed, 16 Aug 2023 14:06:17 +0400 Subject: [PATCH] ci(label): dispatch workflows with github API --- .github/workflows/build-macos.yml | 56 +++++++++++++++++++++++++++++++ .github/workflows/build.yml | 50 +-------------------------- .github/workflows/label.yml | 45 +++++++++++++------------ 3 files changed, 80 insertions(+), 71 deletions(-) create mode 100644 .github/workflows/build-macos.yml diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml new file mode 100644 index 00000000000..8ab63dd12da --- /dev/null +++ b/.github/workflows/build-macos.yml @@ -0,0 +1,56 @@ +name: Build MacOS + +on: + workflow_call: + workflow_dispatch: + +env: + CARGO_INCREMENTAL: 0 + CARGO_TERM_COLOR: always + RUST_BACKTRACE: short + TERM: xterm-256color + BINARYEN_VERSION: version_111 + +jobs: + x86: + runs-on: macos-latest + env: + RUSTUP_HOME: /tmp/rustup_home + steps: + - name: "ACTIONS: Checkout" + uses: actions/checkout@v3 + + - name: "ACTIONS: Setup caching" + uses: actions/cache@v3 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-cargo- + + - name: "Install: protobuf" + run: brew install protobuf + + - name: "Install: Rust toolchain" + uses: dsherret/rust-toolchain-file@v1 + + - name: "Install: cargo-nextest" + run: curl -LsSf https://get.nexte.st/latest/mac | tar zxf - -C ${CARGO_HOME:-~/.cargo}/bin + + - name: "Build: Node" + run: >- + cargo build + -p gear-cli --features=lazy-pages + + - name: "Test: Lazy pages" + run: >- + cargo nextest run + -p "pallet-*" + -p gear-lazy-pages + -p gear-runtime-interface + --features=lazy-pages diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5c7cdf47da3..56f15a20871 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -6,12 +6,6 @@ on: cache: type: string required: true - linux: - type: boolean - default: true - win: - type: boolean - default: true macos: type: boolean default: false @@ -26,7 +20,6 @@ env: jobs: linux: - if: ${{ inputs.linux }} runs-on: [kuberunner, github-runner-02] env: LLVM_PROFILE_FILE: "gear-%p-%m.profraw" @@ -184,7 +177,6 @@ jobs: - run: sccache --show-stats win-cross: - if: ${{ always() && inputs.win }} runs-on: [kuberunner, github-runner-03] env: XWIN_ARCH: x86_64 @@ -258,44 +250,4 @@ jobs: macos-x86: if: ${{ always() && inputs.macos }} needs: linux - runs-on: macos-latest - env: - RUSTUP_HOME: /tmp/rustup_home - steps: - - name: "ACTIONS: Checkout" - uses: actions/checkout@v3 - - - name: "ACTIONS: Setup caching" - uses: actions/cache@v3 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target/ - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - restore-keys: | - ${{ runner.os }}-cargo- - - - name: "Install: protobuf" - run: brew install protobuf - - - name: "Install: Rust toolchain" - uses: dsherret/rust-toolchain-file@v1 - - - name: "Install: cargo-nextest" - run: curl -LsSf https://get.nexte.st/latest/mac | tar zxf - -C ${CARGO_HOME:-~/.cargo}/bin - - - name: "Build: Node" - run: >- - cargo build - -p gear-cli --features=lazy-pages - - - name: "Test: Lazy pages" - run: >- - cargo nextest run - -p "pallet-*" - -p gear-lazy-pages - -p gear-runtime-interface - --features=lazy-pages + uses: ./.github/workflows/build-macos.yml diff --git a/.github/workflows/label.yml b/.github/workflows/label.yml index a87af649569..ede8b797193 100644 --- a/.github/workflows/label.yml +++ b/.github/workflows/label.yml @@ -10,21 +10,18 @@ concurrency: cancel-in-progress: true jobs: - status: + build: runs-on: ubuntu-latest - if: github.event.label.name == 'A0-pleasereview' || github.event.label.name == 'E2-forcemacos' - outputs: - build: ${{ steps.label-checks.outputs.build }} - linux: ${{ steps.label-checks.outputs.linux }} - win: ${{ steps.label-checks.outputs.win }} - macos: ${{ steps.label-checks.outputs.macos }} + # if: github.event.label.name == 'A0-pleasereview' || github.event.label.name == 'E2-forcemacos' steps: - uses: actions/github-script@v6 id: label-checks with: script: | const [owner, repo] = ["gear-tech", "gear"]; - const { ref, payload: { number: issue_number } } = context; + // const { ref, payload: { number: issue_number } } = context; + const ref = "cl/issue-2888"; + const issue_number = 3070; // List all labels of the current pull request. const { data: labelsArr } = await github.rest.issues.listLabelsOnIssue({ @@ -51,24 +48,28 @@ jobs: }); for (run of check_runs) { + console.log(run.name); if (run.name === "build / linux") { linux = false; - } else if (run.name === "build / macos-86") { + } else if (run.name === "build-macos / x86") { macos = false; } } - core.setOutput("build", linux || macos); - core.setOutput("linux", linux); - core.setOutput("win", linux); - core.setOutput("macos", macos) + if (linux) { + await github.rest.actions.createWorkflowDispatch({ + owner, + repo, + workflow_id: "build.yml", + ref + }); + } - build: - needs: status - uses: ./.github/workflows/build.yml - if: ${{ needs.status.outputs.build }} - with: - cache: true - linux: ${{ fromJSON(needs.status.outputs.linux) }} - win: ${{ fromJSON(needs.status.outputs.win) }} - macos: ${{ fromJSON(needs.status.outputs.macos) }} + if (macos) { + await github.rest.actions.createWorkflowDispatch({ + owner, + repo, + workflow_id: "build-macos.yml", + ref + }); + }