Skip to content

Commit

Permalink
ci(label): dispatch workflows with github API
Browse files Browse the repository at this point in the history
  • Loading branch information
clearloop committed Aug 16, 2023
1 parent ef60230 commit b867014
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 71 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/build-macos.yml
Original file line number Diff line number Diff line change
@@ -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
50 changes: 1 addition & 49 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -26,7 +20,6 @@ env:

jobs:
linux:
if: ${{ inputs.linux }}
runs-on: [kuberunner, github-runner-02]
env:
LLVM_PROFILE_FILE: "gear-%p-%m.profraw"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
45 changes: 23 additions & 22 deletions .github/workflows/label.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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
});
}

0 comments on commit b867014

Please sign in to comment.