From 8b369c6aac5429354d71b1ba3eaf610f6c3a0ef5 Mon Sep 17 00:00:00 2001 From: kunxian xia Date: Wed, 30 Oct 2024 14:56:57 +0800 Subject: [PATCH 1/4] ci runs on self-hosted machine by default --- .github/workflows/integration.yml | 4 ++-- .github/workflows/lints.yml | 4 ++-- .github/workflows/tests.yml | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 2918a3ce1..daded6a51 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -10,7 +10,7 @@ on: jobs: skip_check: - runs-on: ubuntu-24.04 + runs-on: [self-hosted, Linux, X64] outputs: should_skip: ${{ steps.skip_check.outputs.should_skip }} steps: @@ -30,7 +30,7 @@ jobs: name: Integration testing timeout-minutes: 30 - runs-on: ubuntu-24.04 + runs-on: [self-hosted, Linux, X64] strategy: matrix: diff --git a/.github/workflows/lints.yml b/.github/workflows/lints.yml index 299714e9b..61ecda6c6 100644 --- a/.github/workflows/lints.yml +++ b/.github/workflows/lints.yml @@ -10,7 +10,7 @@ on: jobs: skip_check: - runs-on: ubuntu-24.04 + runs-on: [self-hosted, Linux, X64] outputs: should_skip: ${{ steps.skip_check.outputs.should_skip }} steps: @@ -30,7 +30,7 @@ jobs: name: Various lints timeout-minutes: 30 - runs-on: ubuntu-24.04 + runs-on: [self-hosted, Linux, X64] strategy: matrix: diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index a81dbb13d..9cfdc255f 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -10,7 +10,7 @@ on: jobs: skip_check: - runs-on: ubuntu-24.04 + runs-on: [self-hosted, Linux, X64] outputs: should_skip: ${{ steps.skip_check.outputs.should_skip }} steps: @@ -29,7 +29,7 @@ jobs: (github.event.action == 'ready_for_review' || needs.skip_check.outputs.should_skip != 'true') name: Run Tests timeout-minutes: 30 - runs-on: ubuntu-24.04 + runs-on: [self-hosted, Linux, X64] strategy: matrix: From b520cb8c294904f99fd2f9eb29ed0cd40fd4b3f3 Mon Sep 17 00:00:00 2001 From: kunxian xia Date: Thu, 31 Oct 2024 21:21:45 +0800 Subject: [PATCH 2/4] add Dockerfile for setting up self-hosted docker container --- scripts/ci/Dockerfile | 31 +++++++++++++++++++++++++++++++ scripts/ci/start.sh | 7 +++++++ 2 files changed, 38 insertions(+) create mode 100644 scripts/ci/Dockerfile create mode 100644 scripts/ci/start.sh diff --git a/scripts/ci/Dockerfile b/scripts/ci/Dockerfile new file mode 100644 index 000000000..2c0e1cf42 --- /dev/null +++ b/scripts/ci/Dockerfile @@ -0,0 +1,31 @@ +# this dockerfile is borrowed from https://baccini-al.medium.com/how-to-containerize-a-github-actions-self-hosted-runner-5994cc08b9fb +FROM ubuntu:22.04 + +ARG DEBIAN_FRONTEND=noninteractive +ARG RUNNER_VERSION="2.320.0" +ARG CHECKSUM="93ac1b7ce743ee85b5d386f5c1787385ef07b3d7c728ff66ce0d3813d5f46900" + +RUN apt update -y && apt upgrade -y && useradd -m docker +RUN apt install -y --no-install-recommends \ + curl jq build-essential libssl-dev libffi-dev python3 python3-venv python3-dev python3-pip + +# these are the dependencies of actions-runner +RUN apt install -y --no-install-recommends \ + libkrb5-3 zlib1g libicu70 + +RUN cd /home/docker && mkdir actions-runner && cd actions-runner \ + && curl -o actions-runner-linux-x64-$RUNNER_VERSION.tar.gz -L https://github.com/actions/runner/releases/download/v$RUNNER_VERSION/actions-runner-linux-x64-$RUNNER_VERSION.tar.gz \ + && echo "$CHECKSUM actions-runner-linux-x64-$RUNNER_VERSION.tar.gz" | shasum -a 256 -c \ + && tar xzf ./actions-runner-linux-x64-$RUNNER_VERSION.tar.gz + +RUN chown -R docker ~docker && cd /home/docker/actions-runner/bin/ \ + && chmod +x installdependencies.sh \ + && ./installdependencies.sh + +COPY start.sh start.sh +RUN chmod +x start.sh + +# ./config.sh & ./run.sh are not allowed to be run as root +USER docker + +ENTRYPOINT ["./start.sh"] diff --git a/scripts/ci/start.sh b/scripts/ci/start.sh new file mode 100644 index 000000000..d67bbba00 --- /dev/null +++ b/scripts/ci/start.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +cd /home/docker/actions-runner/ +echo "begin to configure" +./config.sh --url https://github.com/scroll-tech/ceno --token $TOKEN + +./run.sh From fb050e1e3f1d1392e2e27892eaef1c3eef753002 Mon Sep 17 00:00:00 2001 From: kunxian xia Date: Tue, 5 Nov 2024 13:41:10 +0800 Subject: [PATCH 3/4] improve wordings --- scripts/ci/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/ci/Dockerfile b/scripts/ci/Dockerfile index 2c0e1cf42..b8a1e9e9a 100644 --- a/scripts/ci/Dockerfile +++ b/scripts/ci/Dockerfile @@ -25,7 +25,7 @@ RUN chown -R docker ~docker && cd /home/docker/actions-runner/bin/ \ COPY start.sh start.sh RUN chmod +x start.sh -# ./config.sh & ./run.sh are not allowed to be run as root +# GitHub action runner scripts (config.sh and run.sh) are not allowed to be run as root USER docker ENTRYPOINT ["./start.sh"] From b64ab0fa7165b46c25ca0567a2be7ab7c17ea569 Mon Sep 17 00:00:00 2001 From: kunxian xia Date: Tue, 5 Nov 2024 13:59:59 +0800 Subject: [PATCH 4/4] add instructions for setting up docker containers for self-hosted CI runner --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index 70f435371..4c6fd6114 100644 --- a/README.md +++ b/README.md @@ -36,3 +36,12 @@ cargo clippy ``` Alas, `cargo build` doesn't work. That's a known problem and we're working on it. Please use `cargo make build` instead for now. + +### Setting up self-hosted CI docker container + +To set up docker container for CI, you can run the following command: + +```sh +docker build -t ceno-runner scripts/ci/ +docker run -d ceno-runner +```