Skip to content

Commit

Permalink
githubrunner: update
Browse files Browse the repository at this point in the history
  • Loading branch information
Kamilcuk committed Oct 18, 2024
1 parent 9003365 commit 7522845
Show file tree
Hide file tree
Showing 10 changed files with 573 additions and 588 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,7 @@ run_githubrunner:
-var NOMAD_NAMESPACE=$$NOMAD_NAMESPACE \
-var VERBOSE=$(VERBOSE) \
./deploy/nomadtools-githubrunner.nomad.hcl

weles_run_githubrunner:
,rsync --delete $(CURDIR)/ kamil@weles:./myprojects/nomad-tools/
ssh kamil@weles make -C ./myprojects/nomad-tools/ run_githubrunner
1 change: 1 addition & 0 deletions deploy/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
githubcache.json
./githubcache.json
cachedir
17 changes: 11 additions & 6 deletions deploy/githubrunner.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
---
opts:
docker: host
repos:
- Kamilcuk
# - Kamilcuk/nomad-tools
# - Kamilcuk/runnertest
# - Kamilcuk
- Kamilcuk/nomad-tools
- Kamilcuk/runnertest
nomad:
namespace: github
runner_inactivity_timeout: 1w
loop: 60
loop: 10
# loop: 60
template_context:
docker: host
cachedir: /home/kamil/myprojects/nomad-tools/deploy/cachedir

1 change: 1 addition & 0 deletions src/nomad_tools/entry_githubrunner/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .entry_githubrunner import *
69 changes: 43 additions & 26 deletions src/nomad_tools/entry_githubrunner/default.nomad.hcl
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#{# param is all arguments, options and run configuration in one dictionary #}
#{% set param = (param | default({})) or {**arg, **opts, **run} %}
job "{{ param.JOB_NAME }}" {
type = "batch"
meta {
Expand All @@ -10,7 +8,14 @@ It also starts a docker daemon and is running as privileged
{% elif param.docker == "host" %}
It also mounts a docker daemon from the host it is running on
{% endif %}
EOF

{% if param.debug %}
PARAM = <<EOF
{{param | tojson}}
EOF
{% endif %}
}
group "{{ param.JOB_NAME }}" {
reschedule {
Expand All @@ -21,67 +26,79 @@ EOF
attempts = 0
mode = "fail"
}

task "{{ param.JOB_NAME }}" {
driver = "docker"
kill_timeout = "5m"
config {
image = "{{ param.image|default('myoung34/github-runner:latest') }}"
image = "{{ param.image | default('myoung34/github-runner:latest') }}"
init = true
entrypoint = ["bash", "/local/startscript.sh"]
#{% if param.cachedir %}

{% if param.cachedir %}
mount {
type = "bind"
source = "{{ param.cachedir }}"
target = "/_work"
readonly = false
}
#{% if param.docker == "dind" %}
{% endif %}

{% if param.docker == "dind" %}
privileged = true
#{% elif param.docker == "host" %}
{% elif param.docker == "host" %}
mount {
type = "bind"
source = "/var/run/docker.sock"
target = "/var/run/docker.sock"
}
#{% endif %}
#{{"\n"}}{{ param.config }}
{% endif %}

{{ param.extra_config }}
}
template {
destination = "local/startscript.sh"
data = <<EOF
{{ param.startscript }}
destination = "local/startscript.sh"
change_mode = "noop"
left_delimiter = "QWEQWEQEWQEEQ"
right_delimiter = "ASDASDADSADSA"
data = <<EOF
{% if not param.startscript %}{{ 1/0 }}{% endif %}
{{ escape(param.startscript) }}
EOF
}
env {
ACCESS_TOKEN = "{{ param.ACCESS_TOKEN }}"
ACCESS_TOKEN = "{{ CONFIG.github.token }}"
REPO_URL = "{{ param.REPO_URL }}"
RUNNER_NAME = "{{ param.JOB_NAME }}"
LABELS = "{{ param.LABELS }}"
RUNNER_SCOPE = "repo"
DISABLE_AUTO_UPDATE = "true"
# RUN_AS_ROOT = "false"
#{% if param.ephemeral == "true" %}

{% if param.ephemeral == "true" %}
EPHEMERAL = "true"
#{% endif %}
DISABLE_AUTO_UPDATE = "true"
#{% if param.docker == "dind" %}
{% endif %}
{% if param.docker == "dind" %}
START_DOCKER_SERVICE = "true"
#{% endif %}
#{% if param.debug %}
{% endif %}
{% if param.debug %}
DEBUG = "true"
#{% endif %}
{% endif %}
}
resources {
#{% if param.cpu %}
{% if param.cpu %}
cpu = {{ param.cpu }}
#{% endif %}
{% endif %}
{% if param.mem %}
memory = {{ param.mem }}
#{% if param.maxmem %}
{% endif %}
{% if param.maxmem %}
memory_max = {{ param.maxmem }}
#{% endif %}
{% endif %}
}
{{ param.task }}
{{ param.extra_task }}
}
{{ param.group }}
{{ param.extra_group }}
}
{{ param.job }}
{{ param.extra_job }}
}
Loading

0 comments on commit 7522845

Please sign in to comment.