Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: test paginate #40

Closed
wants to merge 1 commit into from
Closed
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
21 changes: 19 additions & 2 deletions dist/index.js

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

16 changes: 15 additions & 1 deletion src/gh.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,19 @@ async function getRunner(label) {
}
}

async function getAllRunner() {
const octokit = github.getOctokit(config.input.githubToken)

try {
const runners = await octokit.paginate(
'GET /repos/zama-ai/kms-core/actions/runners'
)
return runners.length
} catch (error) {
return null
}
}

async function waitForRunnerRegistered(label) {
const timeoutSeconds = 1800
const retryIntervalSeconds = 10
Expand Down Expand Up @@ -61,5 +74,6 @@ async function waitForRunnerRegistered(label) {
}

module.exports = {
waitForRunnerRegistered
waitForRunnerRegistered,
getAllRunner
}
5 changes: 4 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
const slab = require('./slab')
const config = require('./config')
const core = require('@actions/core')
const { waitForRunnerRegistered } = require('./gh')
const { waitForRunnerRegistered, getAllRunner } = require('./gh')

function setOutput(label) {
core.setOutput('label', label)
}

async function start() {
const runnerCount = await getAllRunner()
core.info(`Number of runner found in kms-core: ${runnerCount}`)

const start_instance_response = await slab.startInstanceRequest()
const wait_instance_response = await slab.waitForInstance(
start_instance_response.task_id,
Expand Down
Loading