Skip to content

Commit

Permalink
chore(ci): format codebase using prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
soonum committed Dec 12, 2024
1 parent d749c5b commit de8e86c
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 22 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/registered_runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@ on:
required: true
type: string

permissions:
contents: read

jobs:
test-runner:
name: Test Runner
runs-on: ${{ inputs.runner-name }}
timeout-minutes: 5 # Job should be picked very quickly
timeout-minutes: 5 # Job should be picked very quickly
steps:
- name: Runner registered
run: |
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/removed_runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ on:
READ_REPO_TOKEN:
required: true

permissions:
contents: read

jobs:
test-removed-runner:
name: Test Removed Runner
Expand Down
19 changes: 11 additions & 8 deletions .github/workflows/test_spawn_terminate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
provider: [ aws, hyperstack ]
provider: [aws, hyperstack]
fail-fast: false
outputs:
runner-aws: ${{ steps.gen-output.outputs.runner_aws }}
Expand Down Expand Up @@ -45,27 +45,30 @@ jobs:
test-runner-alive-aws:
name: Test runner is alive (AWS)
needs: [ action-start ]
needs: [action-start]
uses: ./.github/workflows/registered_runner.yml
with:
runner-name: ${{ needs.action-start.outputs.runner-aws }}

test-runner-alive-hyperstack:
name: Test runner is alive (Hyperstack)
needs: [ action-start ]
needs: [action-start]
uses: ./.github/workflows/registered_runner.yml
with:
runner-name: ${{ needs.action-start.outputs.runner-hyperstack }}

action-stop:
name: GitHub Actions Test (terminate)
runs-on: ubuntu-latest
needs: [ action-start, test-runner-alive-aws, test-runner-alive-hyperstack ]
needs: [action-start, test-runner-alive-aws, test-runner-alive-hyperstack]
if: ${{ always() && needs.action-start.result != 'skipped' }}
strategy:
matrix:
runner: [ "${{ needs.action-start.outputs.runner-aws }}",
"${{ needs.action-start.outputs.runner-hyperstack }}" ]
runner:
[
'${{ needs.action-start.outputs.runner-aws }}',
'${{ needs.action-start.outputs.runner-hyperstack }}'
]
fail-fast: false
steps:
- name: Checkout
Expand All @@ -84,7 +87,7 @@ jobs:

test-runner-removed-aws:
name: Test runner is removed (AWS)
needs: [ action-start, action-stop ]
needs: [action-start, action-stop]
uses: ./.github/workflows/removed_runner.yml
with:
runner-name: ${{ needs.action-start.outputs.runner-aws }}
Expand All @@ -94,7 +97,7 @@ jobs:

test-runner-removed-hyperstack:
name: Test runner is removed (Hyperstack)
needs: [ action-start, action-stop ]
needs: [action-start, action-stop]
uses: ./.github/workflows/removed_runner.yml
with:
runner-name: ${{ needs.action-start.outputs.runner-hyperstack }}
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/test_start_stop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
action-start:
name: GitHub Actions Test (start)
runs-on: ubuntu-latest
needs: [ test-runner-exist ]
needs: [test-runner-exist]
steps:
- name: Checkout
id: checkout
Expand All @@ -43,15 +43,15 @@ jobs:

test-runner-alive:
name: Test runner is alive
needs: [ action-start ]
needs: [action-start]
uses: ./.github/workflows/registered_runner.yml
with:
runner-name: ci-persistent-runner

action-stop:
name: GitHub Actions Test (stop)
runs-on: ubuntu-latest
needs: [ action-start, test-runner-alive ]
needs: [action-start, test-runner-alive]
if: ${{ always() && needs.action-start.result != 'skipped' }}
steps:
- name: Checkout
Expand All @@ -70,7 +70,7 @@ jobs:

test-runner-persist:
name: Test runner is still registered
needs: [ action-stop ]
needs: [action-stop]
uses: ./.github/workflows/removed_runner.yml
with:
runner-name: ci-persistent-runner
Expand Down
19 changes: 10 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# On-demand self-hosted runner for GitHub Actions

Start your EC2 [self-hosted runner](https://docs.github.com/en/free-pro-team@latest/actions/hosting-your-own-runners)
right before you need it.
Run the job on it. Finally, stop it when you finish.
Start your EC2
[self-hosted runner](https://docs.github.com/en/free-pro-team@latest/actions/hosting-your-own-runners)
right before you need it. Run the job on it. Finally, stop it when you finish.
And all this automatically as a part of your GitHub Actions workflow.

It relies on Slab CI bot to do all the heavy-lifting.
Expand All @@ -22,7 +22,7 @@ See [below](#example) the YAML code of the depicted workflow.
### Inputs

| Name | Required | Description |
|----------------|-----------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| -------------- | --------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `mode` | Always required. | Specify here which mode you want to use: `start` to start a new runner, `stop` to stop the previously created runner. |
| `github-token` | Always required. | GitHub Personal Access Token with the `repo` scope assigned. |
| `slab-url` | Always required. | URL to Slab CI server. |
Expand All @@ -33,13 +33,14 @@ See [below](#example) the YAML code of the depicted workflow.

### Outputs

| Name | Description |
|---------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `label` | Name of the unique label assigned to the runner. The label is used in two cases: to use as the input of `runs-on` property for the following jobs and to remove the runner from GitHub when it is not needed anymore. |
| Name | Description |
| ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `label` | Name of the unique label assigned to the runner. The label is used in two cases: to use as the input of `runs-on` property for the following jobs and to remove the runner from GitHub when it is not needed anymore. |

### Examples

Here's an example workflow. It uses a backend profile declared in `ci/slab.toml` within the calling repository
Here's an example workflow. It uses a backend profile declared in `ci/slab.toml`
within the calling repository

```yml
name: do-the-job
Expand All @@ -62,7 +63,7 @@ jobs:
profile: cpu-test

do-the-job:
# ... #
# ... #

stop-runner:
name: Stop self-hosted EC2 runner
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"ci-test": "jest --passWithNoTests",
"format:write": "prettier --write **/*.js",
"format:check": "prettier --check **/*.js",
"format:codebase": "prettier --write **/*js **/*.yml **/*.md",
"lint": "npx eslint . -c ./.github/linters/.eslintrc.yml",
"package": "ncc build src/index.js --license licenses.txt",
"package:watch": "npm run package -- --watch",
Expand Down

0 comments on commit de8e86c

Please sign in to comment.