forked from paritytech/substrate
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate CI jobs to Linode instead of Azure
- Loading branch information
Showing
9 changed files
with
210 additions
and
950 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/bash | ||
|
||
if [ ! -f "/etc/apt/sources.list.d/docker.list" ]; then | ||
sudo apt-get remove -y docker docker-engine docker.io containerd runc || echo | ||
sudo apt-get update | ||
sudo apt-get install -y ca-certificates curl gnupg lsb-release | ||
sudo mkdir -p /etc/apt/keyrings | ||
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg | ||
echo \ | ||
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \ | ||
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null | ||
sudo apt-get update | ||
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#cloud-config | ||
|
||
users: | ||
- default | ||
- name: ubuntu | ||
shell: /bin/bash | ||
lock_passwd: true | ||
groups: | ||
- sudo | ||
sudo: | ||
- ALL=(ALL) NOPASSWD:ALL | ||
# WARNING: always keep this line at the end | ||
# b/c runner provisioning appends the actual keys | ||
ssh_authorized_keys: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#!/bin/bash | ||
|
||
set -x | ||
|
||
# Install linode-cli | ||
python3 --version | ||
pip install -r .github/requirements.txt | ||
linode-cli --version | ||
|
||
# Authorize hosted-runner | ||
mkdir -p ~/.ssh/ | ||
ssh-keygen -q -t rsa -N '' -f ~/.ssh/id_rsa | ||
cat ~/.ssh/id_rsa.pub >> .github/authorized_keys | ||
|
||
|
||
# Provision VM | ||
echo "INFO: From ENVs: RUNNER_VM_NAME=$LC_RUNNER_VM_NAME" | ||
|
||
# inject authorized keys into cloud-init for the `ubuntu@` user | ||
while read -r LINE; do | ||
echo " - $LINE" >> .github/linode-cloud-init.template | ||
done < .github/authorized_keys | ||
|
||
# retry until we get a VM | ||
IP_ADDRESS="" | ||
COUNTER=0 | ||
while [ -z "$IP_ADDRESS" ]; do | ||
# if all jobs retry rate-limited queries at the same time they still hit the limit | ||
# and subsequently fail. Max number of retries is hard-coded to 3 in linodecli | ||
# use up to 60 sec random delay to avoid everything being scheduled at once! | ||
sleep $((RANDOM % 60)) | ||
|
||
# WARNING: we do not specify --authorized_keys for root b/c | ||
# linode-cli expects each key as a separate argument and iteratively constructing | ||
# the argument list hits issues with quoting the jey values b/c of white-space. | ||
# All SSH logins should be via the `ubuntu@` user. For more info see: | ||
# https://www.linode.com/community/questions/21290/how-to-pass-multiple-ssh-public-keys-with-linode-cli-linodes-create | ||
linode-cli linodes create --json \ | ||
--image 'linode/ubuntu24.04' --region "$LINODE_REGION" \ | ||
--type "$LINODE_VM_SIZE" --label "$LC_RUNNER_VM_NAME" \ | ||
--root_pass "$(uuidgen)" --backups_enabled false --booted true --private_ip false \ | ||
--metadata.user_data "$(base64 --wrap 0 < .github/linode-cloud-init.template)" > "retry_$COUNTER.json" | ||
|
||
IP_ADDRESS=$(jq -r '.[0].ipv4[0]' < "retry_$COUNTER.json") | ||
|
||
(( COUNTER=COUNTER+1 )) | ||
done | ||
|
||
# provision the GitHub Runner binary on the VM | ||
# passing additional ENV values | ||
SSH_USER_AT_HOSTNAME="ubuntu@$IP_ADDRESS" | ||
echo "INFO: $SSH_USER_AT_HOSTNAME" | ||
|
||
until ssh -i ~/.ssh/id_rsa \ | ||
-o StrictHostKeyChecking=no "$SSH_USER_AT_HOSTNAME" < .github/install-docker-engine-from-upstream.sh; do | ||
echo "DEBUG: retrying ssh connection ..." | ||
sleep 30 | ||
done | ||
|
||
until ssh -i ~/.ssh/id_rsa \ | ||
-o SendEnv=LC_GITHUB_REPO_ADMIN_TOKEN,LC_RUNNER_VM_NAME,LC_WORKFLOW_ID,LC_PROXY_ENABLED,LC_PROXY_SECRET_VARIANT,LC_PROXY_TYPE \ | ||
-o StrictHostKeyChecking=no "$SSH_USER_AT_HOSTNAME" < .github/provision-github-runner.sh; do | ||
echo "DEBUG: retrying ssh connection ..." | ||
sleep 30 | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/bash | ||
|
||
set -x | ||
|
||
# Install linode-cli | ||
python3 --version | ||
pipx install linode-cli | ||
export PATH="$PATH:~/.local/bin" | ||
linode-cli --version | ||
|
||
# if a specific VM was not specified then remove all zombies | ||
if [ -z "$LC_RUNNER_VM_NAME" ]; then | ||
THRESHOLD=$(date --utc "+%Y-%m-%dT%H:%M:%S" -d "5 hours ago") | ||
|
||
for VM_ID in $(linode-cli linodes list --json | jq ".[] | select(.created <= \"$THRESHOLD\")" | jq -r '.id'); do | ||
echo "INFO: going to remove expired VM $VM_ID" | ||
linode-cli linodes delete "$VM_ID" | ||
done | ||
else | ||
VM_ID=$(linode-cli linodes list --json --label "$LC_RUNNER_VM_NAME" | jq -r '.[0].id') | ||
linode-cli linodes delete "$VM_ID" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
linode-cli==5.54.0 |
Oops, something went wrong.