Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

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


### Bug Fixes

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

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

Expand Down
127 changes: 84 additions & 43 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 37 additions & 11 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ function setOutput(label) {
core.setOutput('label', label)
}

// This variable should only be defined for cleanup purpose.
let runnerName

async function cleanup() {
Expand All @@ -26,29 +25,33 @@ async function start() {
const provider = config.input.backend

let startInstanceResponse
let waitGithubResponse

for (let i = 1; i <= 3; i++) {
try {
startInstanceResponse = await slab.startInstanceRequest()
runnerName = startInstanceResponse.runner_name
waitGithubResponse = await slab.waitForGithub(
startInstanceResponse.task_id,
'configuration_fetching'
)
break
} catch (error) {
core.info('Retrying request now...')
}

if (i === 3) {
core.setFailed(
`${provider} instance start request has failed after 3 attempts`
`${provider} instance start request has failed after 3 attempts (reason: configuration fetching has failed)`
)
return
}
}

setOutput(startInstanceResponse.runner_name)
runnerName = waitGithubResponse.configuration_fetching.runner_name
setOutput(runnerName)

core.info(
`${provider} instance details: ${JSON.stringify(
startInstanceResponse.details
)}`
`${provider} instance details: ${waitGithubResponse.configuration_fetching.details}`
)

try {
Expand All @@ -60,10 +63,10 @@ async function start() {
const instanceId = waitInstanceResponse.start.instance_id
core.info(`${provider} instance started with ID: ${instanceId}`)

await waitForRunnerRegistered(startInstanceResponse.runner_name)
await waitForRunnerRegistered(runnerName)
} catch (error) {
core.info(`Clean up after error, stop ${provider} instance`)
await slab.stopInstanceRequest(startInstanceResponse.runner_name)
await slab.stopInstanceRequest(runnerName)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

runner name could be empty here maybe ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added an early return to avoid falling in this case.
In fact if Github operation fails in this function, the instance would not be started.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While writting my last message I think we can go back for the previous implem.
I've to check if the instance record is not updated in case of Github error.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I somewhat rolled back the implementation for start. Since it can be safely relaunched without having zombies.

core.setFailed(`${provider} instance start has failed`)
}
}
Expand All @@ -81,12 +84,35 @@ async function stop() {

if (i === 3) {
core.setFailed('Instance stop request has failed after 3 attempts')
return
}
}

await slab.waitForInstance(stopInstanceResponse.task_id, 'stop')
try {
const waitGithubResponse = await slab.waitForGithub(
stopInstanceResponse.task_id,
'runner_unregister'
)
const taskStatus = waitGithubResponse.runner_unregister.status.toLowerCase()
if (taskStatus === 'done') {
core.info(
`Runner ${config.input.label} unregistered from GitHub successfully`
)
}
} catch (error) {
// Unregistration failure is not critical, so we just log it and continue.
core.warning('An error occurred while unregistering runner, check job logs')
}

core.info('Instance successfully stopped')
try {
await slab.waitForInstance(stopInstanceResponse.task_id, 'stop')
core.info('Instance successfully stopped')
} catch (error) {
// Unregistration failure is not critical, so we just log it and continue.
core.setFailed(
'An error occurred while stopping instance, check for zombie instance in backend provider console.'
)
}
}

async function run() {
Expand Down
Loading
Loading