From 57d3e5f075c88dde6162a19d48a992276db029f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Test=C3=A9?= Date: Mon, 18 Nov 2024 18:39:26 +0100 Subject: [PATCH] chore(ci): test start-stop aws instance --- .github/workflows/ci.yml | 44 +++++++++++++++++++++++-- .github/workflows/registered_runner.yml | 19 +++++++++++ ci/slab.toml | 8 +++++ dist/index.js | 2 +- src/gh.js | 2 +- 5 files changed, 71 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/registered_runner.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d7a8789..a4a157f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,8 +43,8 @@ jobs: id: npm-ci-test run: npm run ci-test - test-action: - name: GitHub Actions Test + test-action-spawn-terminate: + name: GitHub Actions Test (spawn -> terminate) runs-on: ubuntu-latest strategy: matrix: @@ -66,6 +66,11 @@ jobs: backend: ${{ matrix.provider }} profile: ci-test + - name: Test runner is alive + uses: ./.github/workflows/registered_runner.yml + with: + runner-name: ${{ steps.test-start.outputs.label }} + - name: Test stop instance id: test-stop if: ${{ always() }} @@ -76,3 +81,38 @@ jobs: slab-url: ${{ secrets.SLAB_BASE_URL_PRE_PROD }} job-secret: ${{ secrets.JOB_SECRET }} label: ${{ steps.test-start.outputs.label }} + + test-action-start-stop: + name: GitHub Actions Test (start -> stop) + runs-on: ubuntu-latest + steps: + - name: Checkout + id: checkout + uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 + + - name: Test start instance + id: test-start + uses: ./ + with: + mode: start + github-token: ${{ secrets.SLAB_ACTION_TOKEN }} + slab-url: ${{ secrets.SLAB_BASE_URL_PRE_PROD }} + job-secret: ${{ secrets.JOB_SECRET }} + backend: aws + profile: ci-test-start-stop + + - name: Test runner is alive + uses: ./.github/workflows/registered_runner.yml + with: + runner-name: ci-persistent-runner + + - name: Test stop instance + id: test-stop + if: ${{ always() }} + uses: ./ + with: + mode: stop + github-token: ${{ secrets.SLAB_ACTION_TOKEN }} + slab-url: ${{ secrets.SLAB_BASE_URL_PRE_PROD }} + job-secret: ${{ secrets.JOB_SECRET }} + label: ci-persistent-runner diff --git a/.github/workflows/registered_runner.yml b/.github/workflows/registered_runner.yml new file mode 100644 index 0000000..16810ae --- /dev/null +++ b/.github/workflows/registered_runner.yml @@ -0,0 +1,19 @@ +# This simple workflow is used to test if a runner is registered on GitHub platform. +name: Test registered runner + +on: + workflow_call: + inputs: + runner-name: + required: true + type: string + +jobs: + test-runner: + name: Test Runner + runs-on: ${{ inputs.runner-name }} + timeout-minutes: 5 # Job should be picked very quickly + steps: + - name: Checkout + id: checkout + uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 diff --git a/ci/slab.toml b/ci/slab.toml index 513defe..5941f70 100644 --- a/ci/slab.toml +++ b/ci/slab.toml @@ -6,6 +6,14 @@ image_id = "ami-01d21b7be69801c2f" # Ubuntu 22.04 instance_type = "t3.2xlarge" user = "ubuntu" +# This instance is a persistent one with a runner already registered +[backend.aws.ci-test-start-stop] +region = "eu-west-3" +image_id = "ami-01d21b7be69801c2f" # Ubuntu 22.04 +instance_type = "t3.2xlarge" +instance_id = "i-042a592f53f5ab592" +runner_name = "ci-persistent-runner" + [backend.hyperstack.ci-test] environment_name = "canada" image_name = "Ubuntu Server 22.04 LTS R535 CUDA 12.2" diff --git a/dist/index.js b/dist/index.js index ea7be2e..b7b88e2 100644 --- a/dist/index.js +++ b/dist/index.js @@ -49671,7 +49671,7 @@ async function waitForRunnerRegistered(label) { ) await utils.sleep(quietPeriodSeconds) core.info( - `Checking every ${retryIntervalSeconds}s if the GitHub self-hosted runner is registered` + `Checking every ${retryIntervalSeconds}s if the GitHub self-hosted runner is registered (runner: ${label})` ) while (waitSeconds < timeoutSeconds) { diff --git a/src/gh.js b/src/gh.js index 0f1455e..de3da4c 100644 --- a/src/gh.js +++ b/src/gh.js @@ -35,7 +35,7 @@ async function waitForRunnerRegistered(label) { ) await utils.sleep(quietPeriodSeconds) core.info( - `Checking every ${retryIntervalSeconds}s if the GitHub self-hosted runner is registered` + `Checking every ${retryIntervalSeconds}s if the GitHub self-hosted runner is registered (runner: ${label})` ) while (waitSeconds < timeoutSeconds) {