Skip to content

Commit

Permalink
github: runner: collect data
Browse files Browse the repository at this point in the history
  • Loading branch information
xieby1 committed Nov 29, 2024
1 parent ab9325b commit 6b2dc1d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 23 deletions.
28 changes: 8 additions & 20 deletions .github/workflows/runner-service.nix
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# TODO: remove systemd, instead of use pueue or other lightweight manager
# Usage:
# 1. build service: `nix-build runner-service.nix --argstr spec2006src <SPEC2006SRC> --argstr github_token <GITHUB_TOKEN>`
# * The GitHub token (valid for 366 days, limited by OpenXiangShan) is needed to
Expand All @@ -19,13 +20,14 @@
runner = import (pkgs.fetchFromGitHub {
owner = "xieby1";
repo = "nix_config";
rev = "402ff6218615ca8ee61dc9a5e9147d1504fd8919";
hash = "sha256-AEUkkkcj6has+1RD7eFvRsH6gZB5PzYjU8Dn/30LDqA=";
rev = "3f08da6e040d2004246922b4f532d350cf5ce836";
hash = "sha256-B2LrDa2sYmFsKpeizJR2Pz0/bajeWBqJ032pgB05CAU=";
} + "/scripts/pkgs/github-runner.nix") {
inherit pkgs;
podmanExtraOpts = ["-v ${spec2006src}:${spec2006src}:ro"];
extraPodmanOpts = ["-v ${spec2006src}:${spec2006src}:ro"];
extraPkgsInPATH = [pkgs.git];
};
run = pkgs.writeShellScript "run" ''
run-ephemeral = pkgs.writeShellScriptBin name ''
resp=$(curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
Expand All @@ -34,24 +36,10 @@
Https://api.github.com/repos/OpenXiangShan/Deterload/actions/runners/registration-token)
# https://unix.stackexchange.com/questions/13466/can-grep-output-only-specified-groupings-that-match
runner_token=$(echo $resp | grep -oP '"token":\s*"\K[^"]*')
${runner}/bin/github-runner-nix \
${runner} \
--labels 'self-hosted,Linux,X64,nix' \
--ephemeral \
--url https://github.com/OpenXiangShan/Deterload \
--token $runner_token
'';
in pkgs.writeTextFile {
name = "${name}.service";
text = ''
[Install]
WantedBy=default.target
[Service]
ExecStart=${run}
Restart=always
[Unit]
After=network.target
Description=Auto start ${name}
'';
}
in run-ephemeral
24 changes: 21 additions & 3 deletions .github/workflows/runner.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
name: build-deterload
on: [push]
on:
push:
branches:
# push to data branch will not trigger this workflow
- main
jobs:
build-deterload:
timeout-minutes: 2880
Expand All @@ -8,5 +12,19 @@ jobs:
contents: write
steps:
- uses: actions/checkout@v4
- run: nix-build -A openblas
- run: nix-build -A spec2006 --arg src /nfs/share/home/spec2006.tar.gz -j29
- run: nix-build -A openblas -o result-openblas
- run: nix-build -A spec2006 --arg src /nfs/share/home/spec2006.tar.gz -j29 -o result-spec2006
- run: |
git rev-parse HEAD > /tmp/rev
(date +%y%m%d%H%M%S && cat /tmp/rev && readlink result-openblas) | tr '\n' ',' > /tmp/openblas.txt
(date +%y%m%d%H%M%S && cat /tmp/rev && for i in result-spec2006 result-spec2006/*; do readlink $i; done) | tr '\n' ',' > /tmp/spec2006.txt
- uses: actions/checkout@v4
with:
ref: data
- run: |
cat openblas.txt >> /tmp/openblas.txt; mv /tmp/openblas.txt openblas.txt; git add openblas.txt
cat spec2006.txt >> /tmp/spec2006.txt; mv /tmp/spec2006.txt spec2006.txt; git add spec2006.txt
git config --global user.name xieby1Runner
git config --global user.email "[email protected]"
git commit -m "update data for git commit $(cat /tmp/rev)"
git push

0 comments on commit 6b2dc1d

Please sign in to comment.