diff --git a/.github/workflows/pr_workflow.yml b/.github/workflows/pr_workflow.yml index 4ce286d3..4cf181ed 100644 --- a/.github/workflows/pr_workflow.yml +++ b/.github/workflows/pr_workflow.yml @@ -4,7 +4,7 @@ on: push jobs: test: - runs-on: ubuntu-latest + runs-on: self-hosted defaults: run: shell: bash -l {0} diff --git a/config.flake8 b/config.flake8 index 87ff3f8a..87d4a236 100644 --- a/config.flake8 +++ b/config.flake8 @@ -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, diff --git a/runner/ansible/ansible.cfg b/runner/ansible/ansible.cfg new file mode 100644 index 00000000..65b45aab --- /dev/null +++ b/runner/ansible/ansible.cfg @@ -0,0 +1,2 @@ +[defaults] +remote_user=ubuntu \ No newline at end of file diff --git a/runner/ansible/github-runner.yml b/runner/ansible/github-runner.yml new file mode 100644 index 00000000..a2c72eb2 --- /dev/null +++ b/runner/ansible/github-runner.yml @@ -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 \ No newline at end of file diff --git a/runner/ansible/inventory.txt b/runner/ansible/inventory.txt new file mode 100644 index 00000000..01a2a813 --- /dev/null +++ b/runner/ansible/inventory.txt @@ -0,0 +1,2 @@ +[all] +172.16.110.198 runner_name=vesuvio-runner \ No newline at end of file diff --git a/runner/ansible/roles/host/handlers/main.yml b/runner/ansible/roles/host/handlers/main.yml new file mode 100644 index 00000000..988db33f --- /dev/null +++ b/runner/ansible/roles/host/handlers/main.yml @@ -0,0 +1,5 @@ +- name: Remove docker image + community.docker.docker_image: + state: absent + force_absent: true + name: vesuvio-runner diff --git a/runner/ansible/roles/host/tasks/main.yml b/runner/ansible/roles/host/tasks/main.yml new file mode 100644 index 00000000..7dbafc54 --- /dev/null +++ b/runner/ansible/roles/host/tasks/main.yml @@ -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 \ No newline at end of file diff --git a/runner/ansible/roles/runner/tasks/main.yml b/runner/ansible/roles/runner/tasks/main.yml new file mode 100644 index 00000000..e48823fe --- /dev/null +++ b/runner/ansible/roles/runner/tasks/main.yml @@ -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 diff --git a/runner/ansible/setup/setup.sh b/runner/ansible/setup/setup.sh new file mode 100644 index 00000000..6bf9097c --- /dev/null +++ b/runner/ansible/setup/setup.sh @@ -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 diff --git a/runner/docker/runner.Dockerfile b/runner/docker/runner.Dockerfile new file mode 100644 index 00000000..a83aeb51 --- /dev/null +++ b/runner/docker/runner.Dockerfile @@ -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 \ No newline at end of file