Skip to content

Commit

Permalink
Merge pull request #85 from mantidproject/0_add_self_hosted_runner
Browse files Browse the repository at this point in the history
Use self hosted github runner
  • Loading branch information
MialLewis authored Dec 17, 2023
2 parents 0458bfa + b887f08 commit 8f29ffa
Show file tree
Hide file tree
Showing 10 changed files with 90 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/pr_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on: push

jobs:
test:
runs-on: ubuntu-latest
runs-on: self-hosted
defaults:
run:
shell: bash -l {0}
Expand Down
1 change: 1 addition & 0 deletions config.flake8
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[flake8]
ignore = E114,E115,E116,E121,E123,E126,E133,E2,E704,E722,E741,E743,W503,F403,F405,F999
exclude =
.,
.git,
build,
buildconfig,
Expand Down
2 changes: 2 additions & 0 deletions runner/ansible/ansible.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[defaults]
remote_user=ubuntu
19 changes: 19 additions & 0 deletions runner/ansible/github-runner.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
- name: Deploy self-hosted github runner for vesuvio repository
hosts: all
vars:
package_updates_reboot: true # dannixon.system.package_updates

roles:
- role: dannixon.system.package_updates
tags: "initial-setup"
- role: dannixon.system.interactive_users
tags: "initial-setup"
- role: geerlingguy.docker
become: yes
tags: "initial-setup"
- role: host
become: yes
tags: runner
- role: runner
become: yes
tags: runner
2 changes: 2 additions & 0 deletions runner/ansible/inventory.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[all]
172.16.110.198 runner_name=vesuvio-runner
5 changes: 5 additions & 0 deletions runner/ansible/roles/host/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- name: Remove docker image
community.docker.docker_image:
state: absent
force_absent: true
name: vesuvio-runner
15 changes: 15 additions & 0 deletions runner/ansible/roles/host/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
- name: Copy setup script to host
copy:
src: setup/setup.sh
dest: /tmp/setup.sh
mode: '0755'

- name: Copy dockerfile to host
copy:
src: ../docker/runner.Dockerfile
dest: /tmp/runner.Dockerfile
mode: '0755'
notify:
- Remove docker image

- meta: flush_handlers
27 changes: 27 additions & 0 deletions runner/ansible/roles/runner/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
- name: Build docker image
community.docker.docker_image:
build:
path: /tmp/
dockerfile: runner.Dockerfile
name: vesuvio-runner
source: build

- name: Deploy dockerized github runner
community.docker.docker_container:
name: "{{ runner_name }}"
image: vesuvio-runner
detach: yes
init: yes
network_mode: host
recreate: yes
pull: no
shm_size: 512M
volumes:
- /tmp/setup.sh:/home/setup.sh
command: /home/setup.sh
user: nonroot

- name: Remove setup script
ansible.builtin.file:
path: /tmp/setup.sh
state: absent
7 changes: 7 additions & 0 deletions runner/ansible/setup/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#! /bin/bash
set -ex
mkdir /home/nonroot/actions-runner && cd /home/nonroot/actions-runner
curl -o actions-runner-linux-x64-2.311.0.tar.gz -L https://github.com/actions/runner/releases/download/v2.311.0/actions-runner-linux-x64-2.311.0.tar.gz
tar xzf ./actions-runner-linux-x64-2.311.0.tar.gz
./config.sh --url https://github.com/mantidproject/vesuvio --token AWZQ65WBHOW75IEIVFMRX63FP6IBQ
./run.sh
11 changes: 11 additions & 0 deletions runner/docker/runner.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM ubuntu:focal-20231128

RUN apt-get update && apt-get install -y \
curl \
tar \
apt-transport-https \
libicu66 \
libglu1-mesa \
&& rm -rf /var/lib/apt/lists/*

RUN useradd -m nonroot

0 comments on commit 8f29ffa

Please sign in to comment.