Skip to content

Commit

Permalink
test: arm64 runner
Browse files Browse the repository at this point in the history
  • Loading branch information
2moe committed May 24, 2024
1 parent f02d048 commit 0a3cec1
Show file tree
Hide file tree
Showing 3 changed files with 156 additions and 0 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/test-arm64.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: arm64 runner
# auto-task.start-build-time = ?

on:
push:
branches: ["dev"]
paths:
- .github/workflows/test-arm64.yml

jobs:
docker:
strategy:
fail-fast: false
matrix:
include:
- arch: x64
runner: ubuntu-24.04
- arch: arm64
runner: circle-arm64
runs-on: ${{matrix.runner}}

defaults:
run:
shell: zsh --pipefail -fex {0}
env:
circle_runner: ${{ startsWith(matrix.runner, "circle") }}
steps:
# - name: install zsh
# shell: sh -e {0}
# run: ${{ vars.INSTALL_ZSH }}
# - uses: actions/checkout@v4
# with:
# ref: dev
- name: trigger arm64
if: (!fromJSON(env.circle_runner))
run: ${{ secrets.WEBHOOK_TRIGGER }}

- name: test
run: uname -a
107 changes: 107 additions & 0 deletions assets/ci/circle/arm64.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
# This file is automatically generated, do not edit it manually.
version: 2.1
jobs:
setup-runner:
resource_class: arm.medium
steps:
- run:
command: |
curl -Lo gh.json https://api.github.com/repos/actions/runner/releases/latest
docker run --rm -v /usr/local/bin:/host ghcr.io/2moe/zsh-static cp zsh /host/
name: get gh-api json & install zsh
shell: sh -e
- run:
command: |
const fs = require("fs");
fs.readFile("gh.json", "utf8", (_e, data) => {
const url = JSON.parse(data)
.assets.map((x) => x.browser_download_url)
.find((x) => x.includes(`linux-${process.env.ARCH}`));
console.log(url);
fs.writeFile("url.txt", url, (err) => {
if (err) throw err;
});
});
name: parse json
shell: node
- run:
command: |
url=$(<url.txt)
mkdir -p ~/runner
cd ~/runner
if [[ -z $url ]] {
exit 1
}
curl -Lo a.tgz $url
tar -xf a.tgz
unlink a.tgz
name: install github runner
shell: zsh --pipefail -fex
- run:
command: |
for i ("$REPO" "$_PAT") {
[[ -n $i ]] || exit 9
}
# if env("REPO").contains("/") => personal
# _ => organizational
repo_type=orgs
if [[ $REPO == */* ]] {
repo_type=repos
}
url="https://api.github.com/$repo_type/$REPO/actions/runners/registration-token"
args=(
-L
-X POST
-H 'Accept: application/vnd.github+json'
-H "Authorization: Bearer $_PAT"
-H 'X-GitHub-Api-Version: 2022-11-28'
$url
)
unset _PAT CIRCLE_USERNAME
json=$(curl $args)
self_hosted_tk=$(
node -e 'console.log(JSON.parse(process.argv[1]).token)' -- $json
)
[[ -n $self_hosted_tk ]] || exit 9
conf=(
--url "https://github.com/$REPO"
--token $self_hosted_tk
--labels circle-$ARCH
--name "circle-$RANDOM"
)
yes "" | ./config.sh $conf ||:
# async wait + loop wait
# If the runner_connected file is not detected, it will exit automatically.
(
sleep 5
print Checking the status of the runner connection.
while {true} {
sleep 10
if [[ ! -e /run/runner_connected ]] {
$PWD/config.sh remove --token $self_hosted_tk
exit 0
}
}) &
loop_task=$!
unset self_hosted_tk
./run.sh &
wait $loop_task
name: start runner
shell: zsh --pipefail -fe
working_directory: ~/runner
environment:
ARCH: arm64
REPO: 2cd
machine:
image: ubuntu-2204:current
workflows:
download-and-run:
jobs:
- setup-runner:
context: github
10 changes: 10 additions & 0 deletions assets/ci/update-arm64-ci.zsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env zsh
# depends: curl, tomlyre
#
set -fexo pipefail
url='https://raw.githubusercontent.com/2moe/circle-runner/main/.circleci/config.yml'
cfg=circle/arm64.yml
curl -Lo $cfg $url
tomlyre set $cfg -k jobs.setup-runner.environment.REPO -s "2cd" --save

sed '1i # This file is automatically generated, do not edit it manually.' -i $cfg

0 comments on commit 0a3cec1

Please sign in to comment.