Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP][ci] Add worfklow stopper #4551

Open
wants to merge 30 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
99eba9e
[WIP][ci] Add worfklow stopper
alvicsam May 23, 2024
cca9f69
add id
alvicsam May 23, 2024
1d109bb
try owner
alvicsam May 23, 2024
5f2ddb8
add repository
alvicsam May 23, 2024
b423d39
try another owner
alvicsam May 23, 2024
a0607d8
change runner
alvicsam May 23, 2024
b4288fd
restart pipeline
alvicsam May 23, 2024
799a644
restart pipeline
alvicsam May 23, 2024
30854ab
restart pipeline
alvicsam May 23, 2024
2d23739
restart pipeline
alvicsam May 24, 2024
40ec4a3
restart pipeline
alvicsam May 24, 2024
16e7161
test workflow stopper with system error
alvicsam Jun 21, 2024
de0a48b
test workflow stopper with system error
alvicsam Jun 21, 2024
1812b0b
Merge branch 'master' into as-test-workflow-stopper
alvicsam Jun 21, 2024
6176263
upd wfl
alvicsam Aug 14, 2024
619b4d0
Merge branch 'master' into as-test-workflow-stopper
alvicsam Aug 14, 2024
0303017
try stopper with action
alvicsam Aug 14, 2024
ad46185
rm label condition
alvicsam Aug 14, 2024
1ede702
fix path
alvicsam Aug 14, 2024
db72f3a
fix path
alvicsam Aug 14, 2024
2a36dae
try ubuntu latest
alvicsam Aug 14, 2024
f9412f3
try input
alvicsam Aug 14, 2024
a9a805d
disable inputs
alvicsam Aug 14, 2024
049ac85
Merge branch 'master' into as-test-workflow-stopper
alvicsam Nov 11, 2024
71df0c8
check secrets
alvicsam Nov 11, 2024
c64b293
fix action vars
alvicsam Nov 11, 2024
7118659
add step to more jobs
alvicsam Nov 11, 2024
ef81c5d
test several jobs
alvicsam Nov 11, 2024
56954ea
rm dup
alvicsam Nov 11, 2024
832d4de
add stopper to more jobs
alvicsam Nov 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .github/actions/workflow-stopper/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: "stop all workflows"
description: "Action stops all workflows in a PR to save compute resources."
inputs:
app-id:
description: "App id"
required: true
app-key:
description: "App token"
required: true
runs:
using: "composite"
steps:
- name: Worfklow stopper - Generate token
uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ inputs.app-id }}
private-key: ${{ inputs.app-key }}
owner: "paritytech"
repositories: "workflow-stopper"
- name: Workflow stopper - Stop all workflows
uses: octokit/[email protected]
with:
route: POST /repos/paritytech/workflow-stopper/actions/workflows/stopper.yml/dispatches
ref: main
inputs: '${{ format(''{{ "github_sha": "{0}", "github_repository": "{1}", "github_ref_name": "{2}", "github_workflow_id": "{3}", "github_job_name": "{4}" }}'', github.event.pull_request.head.sha, github.repository, github.ref_name, github.run_id, github.job) }}'
env:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
15 changes: 14 additions & 1 deletion .github/workflows/build-misc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ permissions:
contents: read

jobs:

preflight:
uses: ./.github/workflows/reusable-preflight.yml

Expand All @@ -38,11 +37,18 @@ jobs:
- name: Build
env:
SUBSTRATE_RUNTIME_TARGET: riscv
id: required
run: |
forklift cargo check -p minimal-template-runtime
forklift cargo check -p westend-runtime
forklift cargo check -p rococo-runtime
forklift cargo check -p polkadot-test-runtime
- name: Stop all workflows if failed
if: ${{ failure() && steps.required.conclusion == 'failure' }}
uses: ./.github/actions/workflow-stopper
with:
app-id: ${{ secrets.WORKFLOW_STOPPER_RUNNER_APP_ID }}
app-key: ${{ secrets.WORKFLOW_STOPPER_RUNNER_APP_KEY }}

build-subkey:
timeout-minutes: 20
Expand All @@ -62,9 +68,16 @@ jobs:
- name: Build
env:
SKIP_WASM_BUILD: 1
id: required
run: |
cd ./substrate/bin/utils/subkey
forklift cargo build --locked --release
- name: Stop all workflows if failed
if: ${{ failure() && steps.required.conclusion == 'failure' }}
uses: ./.github/actions/workflow-stopper
with:
app-id: ${{ secrets.WORKFLOW_STOPPER_RUNNER_APP_ID }}
app-key: ${{ secrets.WORKFLOW_STOPPER_RUNNER_APP_KEY }}

confirm-required-build-misc-jobs-passed:
runs-on: ubuntu-latest
Expand Down
15 changes: 15 additions & 0 deletions .github/workflows/check-frame-omni-bencher.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,16 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- name: script
id: required
run: |
forklift cargo build --locked --quiet --release -p asset-hub-westend-runtime --features runtime-benchmarks
forklift cargo run --locked --release -p frame-omni-bencher --quiet -- v1 benchmark pallet --runtime target/release/wbuild/asset-hub-westend-runtime/asset_hub_westend_runtime.compact.compressed.wasm --all --steps 2 --repeat 1 --quiet
- name: Stop all workflows if failed
if: ${{ failure() && steps.required.conclusion == 'failure' }}
uses: ./.github/actions/workflow-stopper
with:
app-id: ${{ secrets.WORKFLOW_STOPPER_RUNNER_APP_ID }}
app-key: ${{ secrets.WORKFLOW_STOPPER_RUNNER_APP_KEY }}

runtime-matrix:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -80,6 +87,7 @@ jobs:
uses: actions/checkout@v4

- name: script
id: required
run: |
RUNTIME_BLOB_NAME=$(echo $PACKAGE_NAME | sed 's/-/_/g').compact.compressed.wasm
RUNTIME_BLOB_PATH=./target/release/wbuild/$PACKAGE_NAME/$RUNTIME_BLOB_NAME
Expand All @@ -90,6 +98,13 @@ jobs:
cmd="./target/release/frame-omni-bencher v1 benchmark pallet --runtime $RUNTIME_BLOB_PATH --all --steps 2 --repeat 1 $FLAGS"
echo "Running command: $cmd"
eval "$cmd"
- name: Stop all workflows if failed
if: ${{ failure() && steps.required.conclusion == 'failure' }}
uses: ./.github/actions/workflow-stopper
with:
app-id: ${{ secrets.WORKFLOW_STOPPER_RUNNER_APP_ID }}
app-key: ${{ secrets.WORKFLOW_STOPPER_RUNNER_APP_KEY }}

confirm-frame-omni-benchers-passed:
runs-on: ubuntu-latest
name: All benchmarks passed
Expand Down
13 changes: 11 additions & 2 deletions .github/workflows/check-runtime-migration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,20 +101,29 @@ jobs:
./try-runtime create-snapshot --uri ${{ matrix.uri }} snapshot.raw

- name: Build Runtime
id: required1
run: |
echo "---------- Building ${{ matrix.package }} runtime ----------"
time forklift cargo build --release --locked -p ${{ matrix.package }} --features try-runtime -q
forklift cargo build --release --locked -p ${{ matrix.package }} --features try-runtime -q

- name: Run Check
id: required2
run: |
echo "Running ${{ matrix.network }} runtime migration check"
export RUST_LOG=remote-ext=debug,runtime=debug

echo "---------- Executing on-runtime-upgrade for ${{ matrix.network }} ----------"
time ./try-runtime ${{ matrix.command_extra_args }} \
./try-runtime ${{ matrix.command_extra_args }} \
--runtime ./target/release/wbuild/${{ matrix.package }}/${{ matrix.wasm }} \
on-runtime-upgrade --disable-spec-version-check --checks=all ${{ matrix.subcommand_extra_args }} snap -p snapshot.raw
sleep 5
- name: Stop all workflows if failed
if: ${{ failure() && (steps.required1.conclusion == 'failure' || steps.required2.conclusion == 'failure') }}
uses: ./.github/actions/workflow-stopper
with:
app-id: ${{ secrets.WORKFLOW_STOPPER_RUNNER_APP_ID }}
app-key: ${{ secrets.WORKFLOW_STOPPER_RUNNER_APP_KEY }}

# name of this job must be unique across all workflows
# otherwise GitHub will mark all these jobs as required
confirm-required-checks-passed:
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/checks-quick.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ concurrency:
permissions: {}

jobs:

preflight:
uses: ./.github/workflows/reusable-preflight.yml

Expand All @@ -28,7 +27,14 @@ jobs:
steps:
- uses: actions/checkout@6d193bf28034eafb982f37bd894289fe649468fc # v4.1.7
- name: Cargo fmt
id: required
run: cargo +nightly fmt --all -- --check
- name: Stop all workflows if failed
if: ${{ failure() && steps.required.conclusion == 'failure' }}
uses: ./.github/actions/workflow-stopper
with:
app-id: ${{ secrets.WORKFLOW_STOPPER_RUNNER_APP_ID }}
app-key: ${{ secrets.WORKFLOW_STOPPER_RUNNER_APP_KEY }}
check-dependency-rules:
runs-on: ubuntu-latest
timeout-minutes: 20
Expand Down
23 changes: 23 additions & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,17 @@ jobs:
steps:
- uses: actions/checkout@6d193bf28034eafb982f37bd894289fe649468fc # v4.1.7
- name: script
id: required
run: |
cargo clippy --all-targets --locked --workspace --quiet
cargo clippy --all-targets --all-features --locked --workspace --quiet
- name: Stop all workflows if failed
if: ${{ failure() && steps.required.conclusion == 'failure' }}
uses: ./.github/actions/workflow-stopper
with:
app-id: ${{ secrets.WORKFLOW_STOPPER_RUNNER_APP_ID }}
app-key: ${{ secrets.WORKFLOW_STOPPER_RUNNER_APP_KEY }}

check-try-runtime:
runs-on: ${{ needs.preflight.outputs.RUNNER }}
needs: [preflight]
Expand All @@ -44,6 +52,7 @@ jobs:
steps:
- uses: actions/checkout@6d193bf28034eafb982f37bd894289fe649468fc # v4.1.7
- name: script
id: required
run: |
forklift cargo check --locked --all --features try-runtime --quiet
# this is taken from cumulus
Expand All @@ -52,6 +61,13 @@ jobs:
# add after https://github.com/paritytech/substrate/pull/14502 is merged
# experimental code may rely on try-runtime and vice-versa
forklift cargo check --locked --all --features try-runtime,experimental --quiet
- name: Stop all workflows if failed
if: ${{ failure() && steps.required.conclusion == 'failure' }}
uses: ./.github/actions/workflow-stopper
with:
app-id: ${{ secrets.WORKFLOW_STOPPER_RUNNER_APP_ID }}
app-key: ${{ secrets.WORKFLOW_STOPPER_RUNNER_APP_KEY }}

# check-core-crypto-features works fast without forklift
check-core-crypto-features:
runs-on: ${{ needs.preflight.outputs.RUNNER }}
Expand All @@ -63,6 +79,7 @@ jobs:
steps:
- uses: actions/checkout@6d193bf28034eafb982f37bd894289fe649468fc # v4.1.7
- name: script
id: required
run: |
cd substrate/primitives/core
./check-features-variants.sh
Expand All @@ -73,6 +90,12 @@ jobs:
cd substrate/primitives/keyring
./check-features-variants.sh
cd -
- name: Stop all workflows if failed
if: ${{ failure() && steps.required.conclusion == 'failure' }}
uses: ./.github/actions/workflow-stopper
with:
app-id: ${{ secrets.WORKFLOW_STOPPER_RUNNER_APP_ID }}
app-key: ${{ secrets.WORKFLOW_STOPPER_RUNNER_APP_KEY }}
# name of this job must be unique across all workflows
# otherwise GitHub will mark all these jobs as required
confirm-required-checks-passed:
Expand Down
14 changes: 14 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,15 @@ jobs:
steps:
- uses: actions/checkout@v4
- run: forklift cargo test --doc --workspace
id: required
env:
RUSTFLAGS: "-Cdebug-assertions=y -Dwarnings"
- name: Stop all workflows if failed
if: ${{ failure() && steps.required.conclusion == 'failure' }}
uses: ./.github/actions/workflow-stopper
with:
app-id: ${{ secrets.WORKFLOW_STOPPER_RUNNER_APP_ID }}
app-key: ${{ secrets.WORKFLOW_STOPPER_RUNNER_APP_KEY }}

build-rustdoc:
runs-on: ${{ needs.preflight.outputs.RUNNER }}
Expand All @@ -38,6 +45,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- run: forklift cargo doc --all-features --workspace --no-deps
id: required
env:
SKIP_WASM_BUILD: 1
RUSTDOCFLAGS: "-Dwarnings --default-theme=ayu --html-in-header ./docs/sdk/assets/header.html --extend-css ./docs/sdk/assets/theme.css --html-after-content ./docs/sdk/assets/after-content.html"
Expand All @@ -60,6 +68,12 @@ jobs:
path: ./crate-docs/
retention-days: 1
if-no-files-found: error
- name: Stop all workflows if failed
if: ${{ failure() && steps.required.conclusion == 'failure' }}
uses: ./.github/actions/workflow-stopper
with:
app-id: ${{ secrets.WORKFLOW_STOPPER_RUNNER_APP_ID }}
app-key: ${{ secrets.WORKFLOW_STOPPER_RUNNER_APP_KEY }}

build-implementers-guide:
runs-on: ubuntu-latest
Expand Down
28 changes: 28 additions & 0 deletions .github/workflows/tests-linux-stable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,14 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- name: script
id: required
run: WASM_BUILD_NO_COLOR=1 forklift cargo test -p staging-node-cli --release --locked -- --ignored
- name: Stop all workflows if failed
if: ${{ failure() && steps.required.conclusion == 'failure' }}
uses: ./.github/actions/workflow-stopper
with:
app-id: ${{ secrets.WORKFLOW_STOPPER_RUNNER_APP_ID }}
app-key: ${{ secrets.WORKFLOW_STOPPER_RUNNER_APP_KEY }}

# https://github.com/paritytech/ci_cd/issues/864
test-linux-stable-runtime-benchmarks:
Expand All @@ -53,7 +60,14 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- name: script
id: required
run: forklift cargo nextest run --workspace --features runtime-benchmarks benchmark --locked --cargo-profile testnet --cargo-quiet
- name: Stop all workflows if failed
if: ${{ failure() && steps.required.conclusion == 'failure' }}
uses: ./.github/actions/workflow-stopper
with:
app-id: ${{ secrets.WORKFLOW_STOPPER_RUNNER_APP_ID }}
app-key: ${{ secrets.WORKFLOW_STOPPER_RUNNER_APP_KEY }}

test-linux-stable:
needs: [preflight]
Expand Down Expand Up @@ -82,6 +96,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- name: script
id: required
run: |
# Fixes "detected dubious ownership" error in the ci
git config --global --add safe.directory '*'
Expand All @@ -97,6 +112,12 @@ jobs:
- name: runtime-api tests
if: ${{ matrix.partition == '1/3' }}
run: forklift cargo nextest run -p sp-api-test --features enable-staging-api --cargo-quiet
- name: Stop all workflows if failed
if: ${{ failure() && steps.required.conclusion == 'failure' }}
uses: ./.github/actions/workflow-stopper
with:
app-id: ${{ secrets.WORKFLOW_STOPPER_RUNNER_APP_ID }}
app-key: ${{ secrets.WORKFLOW_STOPPER_RUNNER_APP_KEY }}

# some tests do not run with `try-runtime` feature enabled
# https://github.com/paritytech/polkadot-sdk/pull/4251#discussion_r1624282143
Expand All @@ -123,6 +144,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- name: script
id: required
run: |
forklift cargo nextest run --workspace \
--locked \
Expand All @@ -132,6 +154,12 @@ jobs:
--features experimental,ci-only-tests \
--filter-expr " !test(/all_security_features_work/) - test(/nonexistent_cache_dir/)" \
--partition count:${{ matrix.partition }} \
- name: Stop all workflows if failed
if: ${{ failure() && steps.required.conclusion == 'failure' }}
uses: ./.github/actions/workflow-stopper
with:
app-id: ${{ secrets.WORKFLOW_STOPPER_RUNNER_APP_ID }}
app-key: ${{ secrets.WORKFLOW_STOPPER_RUNNER_APP_KEY }}

confirm-required-jobs-passed:
runs-on: ubuntu-latest
Expand Down
Loading