From 89cd8b45efbeb0bebe35da895c30d143dfb84ee7 Mon Sep 17 00:00:00 2001 From: Alex Todorov Date: Mon, 29 Jul 2024 17:53:15 +0300 Subject: [PATCH] Remove self-hosted runner as soon as we're done with it instead of removing everything at the end after waiting for all jobs in the matrix to complete. --- .github/provision-github-runner.sh | 2 +- .github/remove-linode-vm.sh | 1 + .github/workflows/ci.yml | 55 ++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+), 1 deletion(-) diff --git a/.github/provision-github-runner.sh b/.github/provision-github-runner.sh index fc962b43c..544562261 100755 --- a/.github/provision-github-runner.sh +++ b/.github/provision-github-runner.sh @@ -8,7 +8,7 @@ curl -L https://github.com/actions/runner/releases/download/v2.317.0/actions-run tar xzf ./runner.tar.gz sudo ./bin/installdependencies.sh # for 3rd party dependencies and building the code -sudo apt install -y build-essential clang curl gcc jq libssl-dev pkg-config protobuf-compiler unzip +sudo apt install -y build-essential clang curl gcc jq libssl-dev pipx pkg-config protobuf-compiler unzip OWNER_REPO_SLUG="gluwa/creditcoin3" REPOSITORY_URL="https://github.com/$OWNER_REPO_SLUG" diff --git a/.github/remove-linode-vm.sh b/.github/remove-linode-vm.sh index 7be695886..45c2afd68 100755 --- a/.github/remove-linode-vm.sh +++ b/.github/remove-linode-vm.sh @@ -5,6 +5,7 @@ set -x # Install linode-cli python3 --version pipx install linode-cli +export PATH="$PATH:~/.local/bin" linode-cli --version VM_ID=$(linode-cli linodes list --json --label "$LC_RUNNER_VM_NAME" | jq -r '.[0].id') diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d4b7f61f8..892e4e70b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -255,6 +255,15 @@ jobs: command: clippy args: --all-targets --all-features -- -D warnings -A clippy::too_many_arguments -A clippy::type_complexity + # keep this always as the last step + - name: Remove self-hosted + if: always() + run: | + .github/remove-linode-vm.sh + env: + LINODE_CLI_TOKEN: ${{ secrets.LINODE_CLI_TOKEN }} + LC_RUNNER_VM_NAME: ${{ runner.name }} + check: runs-on: [self-hosted, "workflow-${{ github.run_id }}", "proxy-check"] @@ -290,6 +299,15 @@ jobs: run: | SKIP_WASM_BUILD=1 cargo check --features=runtime-benchmarks --release + # keep this always as the last step + - name: Remove self-hosted + if: always() + run: | + .github/remove-linode-vm.sh + env: + LINODE_CLI_TOKEN: ${{ secrets.LINODE_CLI_TOKEN }} + LC_RUNNER_VM_NAME: ${{ runner.name }} + unit-test-creditcoin: runs-on: [ @@ -325,6 +343,15 @@ jobs: command: test args: --features=runtime-benchmarks -- --test-threads 1 + # keep this always as the last step + - name: Remove self-hosted + if: always() + run: | + .github/remove-linode-vm.sh + env: + LINODE_CLI_TOKEN: ${{ secrets.LINODE_CLI_TOKEN }} + LC_RUNNER_VM_NAME: ${{ runner.name }} + build-creditcoin-node: strategy: fail-fast: false @@ -390,6 +417,15 @@ jobs: name: creditcoin_node_runtime.compact.compressed.wasm-${{ matrix.target }} path: target/release/wbuild/creditcoin3-runtime/creditcoin_next_runtime.compact.compressed.wasm + # keep this always as the last step + - name: Remove self-hosted + if: always() + run: | + .github/remove-linode-vm.sh + env: + LINODE_CLI_TOKEN: ${{ secrets.LINODE_CLI_TOKEN }} + LC_RUNNER_VM_NAME: ${{ runner.name }} + build-creditcoin-node-for-testing: needs: - build-creditcoin-node @@ -457,6 +493,15 @@ jobs: name: creditcoin_node_runtime.compact.compressed.wasm-for-${{ matrix.target }} path: target/release/wbuild/creditcoin3-runtime/creditcoin_next_runtime.compact.compressed.wasm + # keep this always as the last step + - name: Remove self-hosted + if: always() + run: | + .github/remove-linode-vm.sh + env: + LINODE_CLI_TOKEN: ${{ secrets.LINODE_CLI_TOKEN }} + LC_RUNNER_VM_NAME: ${{ runner.name }} + integration-test-smart-contract: needs: - build-creditcoin-node-for-testing @@ -699,6 +744,7 @@ jobs: echo "runner_vm_name=${{ env.RUNNER_VM_NAME }}-$HASH_VALUE" >> "$GITHUB_OUTPUT" - name: Remove VM + continue-on-error: true run: | .github/remove-linode-vm.sh env: @@ -875,6 +921,15 @@ jobs: fail_ci_if_error: false verbose: true + # keep this always as the last step + - name: Remove self-hosted + if: always() + run: | + .github/remove-linode-vm.sh + env: + LINODE_CLI_TOKEN: ${{ secrets.LINODE_CLI_TOKEN }} + LC_RUNNER_VM_NAME: ${{ runner.name }} + integration-test-blockchain: needs: - build-creditcoin-node-for-testing