Skip to content

Commit

Permalink
Fix issue with ARM64, refactor info messages (#41)
Browse files Browse the repository at this point in the history
* Fix issue with ARM64, refactor info messages

* Update runner version to the latest

* Update dist

Co-authored-by: GitHub Actions <runner@fv-az90-102.oknmvzgco44exlvyi5fejcivhg.gx.internal.cloudapp.net>
  • Loading branch information
machulav and GitHub Actions authored Apr 22, 2021
1 parent 649ba91 commit 700df61
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 24 deletions.
25 changes: 13 additions & 12 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55094,9 +55094,10 @@ async function startEc2Instance(label, githubRegistrationToken) {
'#!/bin/bash',
'mkdir actions-runner && cd actions-runner',
'case $(uname -m) in aarch64) ARCH="arm64" ;; amd64|x86_64) ARCH="x64" ;; esac && export RUNNER_ARCH=${ARCH}',
'curl -O -L https://github.com/actions/runner/releases/download/v2.277.1/actions-runner-linux-${RUNNER_ARCH}-2.277.1.tar.gz',
'tar xzf ./actions-runner-linux-${RUNNER_ARCH}-2.277.1.tar.gz',
'curl -O -L https://github.com/actions/runner/releases/download/v2.278.0/actions-runner-linux-${RUNNER_ARCH}-2.278.0.tar.gz',
'tar xzf ./actions-runner-linux-${RUNNER_ARCH}-2.278.0.tar.gz',
'export RUNNER_ALLOW_RUNASROOT=1',
'export DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1',
`./config.sh --url https://github.com/${config.githubContext.owner}/${config.githubContext.repo} --token ${githubRegistrationToken} --labels ${label}`,
'./run.sh',
];
Expand Down Expand Up @@ -55153,7 +55154,7 @@ async function waitForInstanceRunning(ec2InstanceId) {
core.info(`AWS EC2 instance ${ec2InstanceId} is up and running`);
return;
} catch (error) {
core.error(`AWS EC2 instance ${ec2InstanceId} init error`);
core.error(`AWS EC2 instance ${ec2InstanceId} initialization error`);
throw error;
}
}
Expand Down Expand Up @@ -55297,33 +55298,33 @@ async function removeRunner() {
}
}

async function waitForRunnerCreated(label) {
async function waitForRunnerRegistered(label) {
const timeoutMinutes = 5;
const retryIntervalSeconds = 10;
const quietPeriodSeconds = 30;
let waitSeconds = 0;

core.info(`Waiting ${quietPeriodSeconds}s before polling for runner`);
core.info(`Waiting ${quietPeriodSeconds}s for the AWS EC2 instance to be registered in GitHub as a new self-hosted runner`);
await new Promise(r => setTimeout(r, quietPeriodSeconds * 1000));
core.info(`Polling for runner every ${retryIntervalSeconds}s`);
core.info(`Checking every ${retryIntervalSeconds}s if the GitHub self-hosted runner is registered`);

return new Promise((resolve, reject) => {
const interval = setInterval(async () => {
const runner = await getRunner(label);

if (waitSeconds > timeoutMinutes * 60) {
core.error('GitHub self-hosted runner creation error');
core.error('GitHub self-hosted runner registration error');
clearInterval(interval);
reject(`A timeout of ${timeoutMinutes} minutes is exceeded. Please ensure your EC2 instance has access to the Internet.`);
reject(`A timeout of ${timeoutMinutes} minutes is exceeded. Your AWS EC2 instance was not able to register itself in GitHub as a new self-hosted runner.`);
}

if (runner && runner.status === 'online') {
core.info(`GitHub self-hosted runner ${runner.name} is created and ready to use`);
core.info(`GitHub self-hosted runner ${runner.name} is registered and ready to use`);
clearInterval(interval);
resolve();
} else {
waitSeconds += retryIntervalSeconds;
core.info('Waiting...');
core.info('Checking...');
}
}, retryIntervalSeconds * 1000);
});
Expand All @@ -55332,7 +55333,7 @@ async function waitForRunnerCreated(label) {
module.exports = {
getRegistrationToken,
removeRunner,
waitForRunnerCreated,
waitForRunnerRegistered,
};


Expand All @@ -55357,7 +55358,7 @@ async function start() {
const ec2InstanceId = await aws.startEc2Instance(label, githubRegistrationToken);
setOutput(label, ec2InstanceId);
await aws.waitForInstanceRunning(ec2InstanceId);
await gh.waitForRunnerCreated(label);
await gh.waitForRunnerRegistered(label);
}

async function stop() {
Expand Down
7 changes: 4 additions & 3 deletions src/aws.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ async function startEc2Instance(label, githubRegistrationToken) {
'#!/bin/bash',
'mkdir actions-runner && cd actions-runner',
'case $(uname -m) in aarch64) ARCH="arm64" ;; amd64|x86_64) ARCH="x64" ;; esac && export RUNNER_ARCH=${ARCH}',
'curl -O -L https://github.com/actions/runner/releases/download/v2.277.1/actions-runner-linux-${RUNNER_ARCH}-2.277.1.tar.gz',
'tar xzf ./actions-runner-linux-${RUNNER_ARCH}-2.277.1.tar.gz',
'curl -O -L https://github.com/actions/runner/releases/download/v2.278.0/actions-runner-linux-${RUNNER_ARCH}-2.278.0.tar.gz',
'tar xzf ./actions-runner-linux-${RUNNER_ARCH}-2.278.0.tar.gz',
'export RUNNER_ALLOW_RUNASROOT=1',
'export DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1',
`./config.sh --url https://github.com/${config.githubContext.owner}/${config.githubContext.repo} --token ${githubRegistrationToken} --labels ${label}`,
'./run.sh',
];
Expand Down Expand Up @@ -70,7 +71,7 @@ async function waitForInstanceRunning(ec2InstanceId) {
core.info(`AWS EC2 instance ${ec2InstanceId} is up and running`);
return;
} catch (error) {
core.error(`AWS EC2 instance ${ec2InstanceId} init error`);
core.error(`AWS EC2 instance ${ec2InstanceId} initialization error`);
throw error;
}
}
Expand Down
16 changes: 8 additions & 8 deletions src/gh.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,33 +51,33 @@ async function removeRunner() {
}
}

async function waitForRunnerCreated(label) {
async function waitForRunnerRegistered(label) {
const timeoutMinutes = 5;
const retryIntervalSeconds = 10;
const quietPeriodSeconds = 30;
let waitSeconds = 0;

core.info(`Waiting ${quietPeriodSeconds}s before polling for runner`);
core.info(`Waiting ${quietPeriodSeconds}s for the AWS EC2 instance to be registered in GitHub as a new self-hosted runner`);
await new Promise(r => setTimeout(r, quietPeriodSeconds * 1000));
core.info(`Polling for runner every ${retryIntervalSeconds}s`);
core.info(`Checking every ${retryIntervalSeconds}s if the GitHub self-hosted runner is registered`);

return new Promise((resolve, reject) => {
const interval = setInterval(async () => {
const runner = await getRunner(label);

if (waitSeconds > timeoutMinutes * 60) {
core.error('GitHub self-hosted runner creation error');
core.error('GitHub self-hosted runner registration error');
clearInterval(interval);
reject(`A timeout of ${timeoutMinutes} minutes is exceeded. Please ensure your EC2 instance has access to the Internet.`);
reject(`A timeout of ${timeoutMinutes} minutes is exceeded. Your AWS EC2 instance was not able to register itself in GitHub as a new self-hosted runner.`);
}

if (runner && runner.status === 'online') {
core.info(`GitHub self-hosted runner ${runner.name} is created and ready to use`);
core.info(`GitHub self-hosted runner ${runner.name} is registered and ready to use`);
clearInterval(interval);
resolve();
} else {
waitSeconds += retryIntervalSeconds;
core.info('Waiting...');
core.info('Checking...');
}
}, retryIntervalSeconds * 1000);
});
Expand All @@ -86,5 +86,5 @@ async function waitForRunnerCreated(label) {
module.exports = {
getRegistrationToken,
removeRunner,
waitForRunnerCreated,
waitForRunnerRegistered,
};
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ async function start() {
const ec2InstanceId = await aws.startEc2Instance(label, githubRegistrationToken);
setOutput(label, ec2InstanceId);
await aws.waitForInstanceRunning(ec2InstanceId);
await gh.waitForRunnerCreated(label);
await gh.waitForRunnerRegistered(label);
}

async function stop() {
Expand Down

0 comments on commit 700df61

Please sign in to comment.