Skip to content

Commit d2c3496

Browse files
committed
feat(slab): using slab new routes to handle async tasks
This ensure to wait for individual asynchronous tasks since there are GitHub related operations and backend providers ones.
1 parent 973c1d2 commit d2c3496

File tree

4 files changed

+164
-46
lines changed

4 files changed

+164
-46
lines changed

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
## [1.4.2](https://github.com/zama-ai/slab-github-runner/compare/v1.4.1...v1.4.2) (2025-11-28)
44

5-
65
### Bug Fixes
76

8-
* **gh:** print out any error on the runner list query ([38175e5](https://github.com/zama-ai/slab-github-runner/commit/38175e59c2c30e5cd4c7fe81d16ecfad751d0db5))
7+
- **gh:** print out any error on the runner list query
8+
([38175e5](https://github.com/zama-ai/slab-github-runner/commit/38175e59c2c30e5cd4c7fe81d16ecfad751d0db5))
99

1010
## [1.4.1](https://github.com/zama-ai/slab-github-runner/compare/v1.4.0...v1.4.1) (2024-12-20)
1111

dist/index.js

Lines changed: 81 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/index.js

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ function setOutput(label) {
77
core.setOutput('label', label)
88
}
99

10-
// This variable should only be defined for cleanup purpose.
1110
let runnerName
1211

1312
async function cleanup() {
@@ -30,27 +29,30 @@ async function start() {
3029
for (let i = 1; i <= 3; i++) {
3130
try {
3231
startInstanceResponse = await slab.startInstanceRequest()
33-
runnerName = startInstanceResponse.runner_name
32+
33+
const waitGithubResponse = await slab.waitForGithub(
34+
startInstanceResponse.task_id,
35+
'configuration_fetching'
36+
)
37+
38+
runnerName = waitGithubResponse.configuration_fetching.runner_name
39+
setOutput(runnerName)
40+
41+
core.info(
42+
`${provider} instance details: ${waitGithubResponse.configuration_fetching.details}`
43+
)
3444
break
3545
} catch (error) {
3646
core.info('Retrying request now...')
3747
}
3848

3949
if (i === 3) {
4050
core.setFailed(
41-
`${provider} instance start request has failed after 3 attempts`
51+
`${provider} instance start request has failed after 3 attempts (reason: configuration fetching has failed)`
4252
)
4353
}
4454
}
4555

46-
setOutput(startInstanceResponse.runner_name)
47-
48-
core.info(
49-
`${provider} instance details: ${JSON.stringify(
50-
startInstanceResponse.details
51-
)}`
52-
)
53-
5456
try {
5557
const waitInstanceResponse = await slab.waitForInstance(
5658
startInstanceResponse.task_id,
@@ -60,10 +62,10 @@ async function start() {
6062
const instanceId = waitInstanceResponse.start.instance_id
6163
core.info(`${provider} instance started with ID: ${instanceId}`)
6264

63-
await waitForRunnerRegistered(startInstanceResponse.runner_name)
65+
await waitForRunnerRegistered(runnerName)
6466
} catch (error) {
6567
core.info(`Clean up after error, stop ${provider} instance`)
66-
await slab.stopInstanceRequest(startInstanceResponse.runner_name)
68+
await slab.stopInstanceRequest(runnerName)
6769
core.setFailed(`${provider} instance start has failed`)
6870
}
6971
}
@@ -74,6 +76,19 @@ async function stop() {
7476
for (let i = 1; i <= 3; i++) {
7577
try {
7678
stopInstanceResponse = await slab.stopInstanceRequest(config.input.label)
79+
80+
const waitGithubResponse = await slab.waitForGithub(
81+
stopInstanceResponse.task_id,
82+
'runner_unregister'
83+
)
84+
const taskStatus =
85+
waitGithubResponse.runner_unregister.status.toLowerCase()
86+
if (taskStatus === 'done') {
87+
core.info(
88+
`Runner ${config.input.label} unregistered from GitHub successfully`
89+
)
90+
}
91+
7792
break
7893
} catch (error) {
7994
core.info('Retrying request now...')

0 commit comments

Comments
 (0)