Skip to content

Commit ef70e84

Browse files
authored
ci: reduce self-hosted runner disk I/O (#207)
1 parent 4ace463 commit ef70e84

9 files changed

Lines changed: 94 additions & 44 deletions

File tree

.github/workflows/build.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
runs-on: ubuntu-latest
2626
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' || github.event.pull_request.head.repo.full_name != github.repository
2727
steps:
28-
- uses: actions/checkout@v4
28+
- uses: actions/checkout@v5
2929
with:
3030
submodules: recursive
3131
- uses: dtolnay/rust-toolchain@stable
@@ -39,7 +39,7 @@ jobs:
3939
runs-on: ubuntu-latest
4040
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' || github.event.pull_request.head.repo.full_name != github.repository
4141
steps:
42-
- uses: actions/checkout@v4
42+
- uses: actions/checkout@v5
4343
with:
4444
submodules: recursive
4545
- uses: dtolnay/rust-toolchain@stable
@@ -58,7 +58,7 @@ jobs:
5858
runs-on: ubuntu-latest
5959
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' || github.event.pull_request.head.repo.full_name != github.repository
6060
steps:
61-
- uses: actions/checkout@v4
61+
- uses: actions/checkout@v5
6262
with:
6363
submodules: recursive
6464
- uses: dtolnay/rust-toolchain@stable
@@ -71,7 +71,7 @@ jobs:
7171
runs-on: ubuntu-latest
7272
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' || github.event.pull_request.head.repo.full_name != github.repository
7373
steps:
74-
- uses: actions/checkout@v4
74+
- uses: actions/checkout@v5
7575
with:
7676
submodules: recursive
7777
- uses: actions-rust-lang/audit@v1

.github/workflows/gh-pages.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
concurrency:
1616
group: ${{ github.workflow }}-${{ github.ref }}
1717
steps:
18-
- uses: actions/checkout@v4
18+
- uses: actions/checkout@v5
1919

2020
- name: Setup mdBook
2121
uses: peaceiris/actions-mdbook@v2

.github/workflows/release-plz.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
cancel-in-progress: false
2121
steps:
2222
- name: Checkout repository
23-
uses: actions/checkout@v4
23+
uses: actions/checkout@v5
2424
with:
2525
fetch-depth: 0
2626
token: ${{ secrets.RELEASE_PLZ_TOKEN }}

.github/workflows/release.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jobs:
5656
env:
5757
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5858
steps:
59-
- uses: actions/checkout@v4
59+
- uses: actions/checkout@v5
6060
with:
6161
persist-credentials: false
6262
submodules: recursive
@@ -116,7 +116,7 @@ jobs:
116116
- name: enable windows longpaths
117117
run: |
118118
git config --global core.longpaths true
119-
- uses: actions/checkout@v4
119+
- uses: actions/checkout@v5
120120
with:
121121
persist-credentials: false
122122
submodules: recursive
@@ -175,7 +175,7 @@ jobs:
175175
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
176176
BUILD_MANIFEST_NAME: target/distrib/global-dist-manifest.json
177177
steps:
178-
- uses: actions/checkout@v4
178+
- uses: actions/checkout@v5
179179
with:
180180
persist-credentials: false
181181
submodules: recursive
@@ -225,7 +225,7 @@ jobs:
225225
outputs:
226226
val: ${{ steps.host.outputs.manifest }}
227227
steps:
228-
- uses: actions/checkout@v4
228+
- uses: actions/checkout@v5
229229
with:
230230
persist-credentials: false
231231
submodules: recursive
@@ -290,7 +290,7 @@ jobs:
290290
env:
291291
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
292292
steps:
293-
- uses: actions/checkout@v4
293+
- uses: actions/checkout@v5
294294
with:
295295
persist-credentials: false
296296
submodules: recursive

.github/workflows/test.yml

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ jobs:
2121
test-all-features:
2222
name: cargo test with all features
2323
strategy:
24-
max-parallel: 1
2524
fail-fast: false
2625
matrix:
2726
include:
@@ -35,25 +34,22 @@ jobs:
3534
llvm: "17"
3635
runs-on: ${{ matrix.kernel }}
3736
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' || github.event.pull_request.head.repo.full_name != github.repository
37+
env:
38+
# CI only needs line numbers for panic backtraces, not full DWARF.
39+
# Overrides the `debug = true` (for cargo flamegraph) in the root Cargo.toml
40+
# to cut release build artifact size and disk writes.
41+
CARGO_PROFILE_RELEASE_DEBUG: "line-tables-only"
42+
# LLVM is preinstalled on the runners (apt: clang-N llvm-N libclang-N-dev).
43+
# Point bindgen (via libbpf-sys) at the matching preinstalled libclang.
44+
LIBCLANG_PATH: /usr/lib/llvm-${{ matrix.llvm }}/lib
3845
steps:
39-
- uses: actions/checkout@v4
46+
- uses: actions/checkout@v5
4047
with:
4148
submodules: recursive
4249
- uses: dtolnay/rust-toolchain@stable
4350
- run: sudo apt update && sudo apt install ethtool iputils-ping iproute2 iperf3 pkg-config m4 libelf-dev libpcap-dev gcc-multilib libnftnl-dev libmnl-dev autoconf automake autopoint flex bison gawk libtool -y
44-
- name: Cache LLVM and Clang
45-
id: cache-llvm
46-
uses: maxnowack/local-cache@v2
47-
with:
48-
path: |
49-
C:/Program Files/LLVM
50-
./llvm
51-
key: llvm-${{ matrix.llvm }}
52-
- name: Install LLVM and Clang
53-
uses: KyleMayes/install-llvm-action@v2
54-
with:
55-
version: ${{ matrix.llvm }}
56-
cached: ${{ steps.cache-llvm.outputs.cache-hit }}
51+
- name: Use preinstalled LLVM ${{ matrix.llvm }}
52+
run: echo "/usr/lib/llvm-${{ matrix.llvm }}/bin" >> "$GITHUB_PATH"
5753
- name: Install nextest
5854
uses: taiki-e/install-action@nextest
5955
- run: cargo nextest run --profile ci -F http,xdp --release --workspace

.github/workflows/verify.yml

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,25 +27,22 @@ jobs:
2727
- kernel: "6.12"
2828
llvm: "17"
2929
runs-on: ${{ matrix.kernel }}
30+
env:
31+
# CI only needs line numbers for panic backtraces, not full DWARF.
32+
# Overrides the `debug = true` (for cargo flamegraph) in the root Cargo.toml
33+
# to cut release build artifact size and disk writes.
34+
CARGO_PROFILE_RELEASE_DEBUG: "line-tables-only"
35+
# LLVM is preinstalled on the runners (apt: clang-N llvm-N libclang-N-dev).
36+
# Point bindgen (via libbpf-sys) at the matching preinstalled libclang.
37+
LIBCLANG_PATH: /usr/lib/llvm-${{ matrix.llvm }}/lib
3038
steps:
31-
- uses: actions/checkout@v4
39+
- uses: actions/checkout@v5
3240
with:
3341
submodules: recursive
3442
- uses: dtolnay/rust-toolchain@stable
3543
- run: sudo apt update && sudo apt install ethtool iputils-ping iproute2 iperf3 datamash bc pkg-config m4 libelf-dev libpcap-dev gcc-multilib libnftnl-dev libmnl-dev autoconf automake autopoint flex bison gawk libtool -y
36-
- name: Cache LLVM and Clang
37-
id: cache-llvm
38-
uses: maxnowack/local-cache@v2
39-
with:
40-
path: |
41-
C:/Program Files/LLVM
42-
./llvm
43-
key: llvm-${{ matrix.llvm }}
44-
- name: Install LLVM and Clang
45-
uses: KyleMayes/install-llvm-action@v2
46-
with:
47-
version: ${{ matrix.llvm }}
48-
cached: ${{ steps.cache-llvm.outputs.cache-hit }}
44+
- name: Use preinstalled LLVM ${{ matrix.llvm }}
45+
run: echo "/usr/lib/llvm-${{ matrix.llvm }}/bin" >> "$GITHUB_PATH"
4946
- run: sudo ./scripts/clean_stdenv.sh -a
5047
- name: Performance verification
5148
run: |
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Extends the upstream github-runner image with a preinstalled LLVM/Clang
2+
# toolchain, so CI jobs (bindgen via libbpf-sys, BPF compilation) don't fetch
3+
# LLVM on every run. Everything lands under /usr/lib/llvm-${LLVM_VERSION},
4+
# matching the PATH / LIBCLANG_PATH that the test and verify workflows expect.
5+
ARG BASE_TAG=ubuntu-noble
6+
FROM myoung34/github-runner:${BASE_TAG}
7+
8+
# 14 for focal (kernel 5.4), 17 for jammy/noble. Overridden per image by ansible.
9+
ARG LLVM_VERSION=17
10+
11+
# Prefer distro packages (present on noble for 17); fall back to apt.llvm.org
12+
# for versions the distro repos lack (14 on focal, 17 on jammy).
13+
RUN set -eux; \
14+
export DEBIAN_FRONTEND=noninteractive; \
15+
apt-get update; \
16+
if ! apt-get install -y --no-install-recommends \
17+
"clang-${LLVM_VERSION}" "llvm-${LLVM_VERSION}" "libclang-${LLVM_VERSION}-dev"; then \
18+
apt-get install -y --no-install-recommends \
19+
wget gnupg lsb-release ca-certificates software-properties-common; \
20+
wget -qO /tmp/llvm.sh https://apt.llvm.org/llvm.sh; \
21+
chmod +x /tmp/llvm.sh; \
22+
/tmp/llvm.sh "${LLVM_VERSION}"; \
23+
apt-get install -y --no-install-recommends "libclang-${LLVM_VERSION}-dev"; \
24+
fi; \
25+
test -x "/usr/lib/llvm-${LLVM_VERSION}/bin/clang"; \
26+
test -e "/usr/lib/llvm-${LLVM_VERSION}/lib/libclang.so"; \
27+
rm -rf /var/lib/apt/lists/* /tmp/llvm.sh

ci/images/ansible/docker-compose.yml.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
services:
22
worker:
3-
image: myoung34/github-runner:{{ tag }}
3+
image: rattan/github-runner:{{ tag }}
44
container_name: github-runner
55
restart: always
66
privileged: true

ci/images/ansible/github-runner.yml

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44
path: /etc/runner
55
state: directory
66

7+
- name: derive LLVM version from kernel
8+
ansible.builtin.set_fact:
9+
# 5.4 (focal) pins LLVM 14; newer kernels use 17. Matches the test/verify
10+
# workflow matrix and the LIBCLANG_PATH / PATH they set.
11+
llvm_version: "{{ '14' if kernel_version == '5.4' else '17' }}"
12+
713
- name: write docker client proxy config for job-spawned containers
814
become: true
915
ansible.builtin.copy:
@@ -19,20 +25,44 @@
1925
}
2026
}
2127
28+
- name: copy github-runner Dockerfile
29+
become: true
30+
ansible.builtin.copy:
31+
src: Dockerfile.runner
32+
dest: /etc/runner/Dockerfile.runner
33+
mode: "0644"
34+
2235
- name: copy github-runner docker-compose file
2336
become: true
2437
ansible.builtin.template:
2538
src: docker-compose.yml.j2
2639
dest: /etc/runner/docker-compose.yml
2740

28-
- name: poll a image
41+
- name: build github-runner image with preinstalled LLVM
2942
become: true
3043
community.docker.docker_image:
31-
name: "docker.io/myoung34/github-runner:{{ tag }}"
32-
source: pull
44+
name: rattan/github-runner
45+
tag: "{{ tag }}"
46+
source: build
47+
force_source: true
48+
build:
49+
path: /etc/runner
50+
dockerfile: Dockerfile.runner
51+
# Pull a fresh upstream base each build.
52+
pull: true
53+
args:
54+
BASE_TAG: "{{ tag }}"
55+
LLVM_VERSION: "{{ llvm_version }}"
56+
http_proxy: "{{ http_proxy | default('') }}"
57+
https_proxy: "{{ http_proxy | default('') }}"
58+
HTTP_PROXY: "{{ http_proxy | default('') }}"
59+
HTTPS_PROXY: "{{ http_proxy | default('') }}"
60+
no_proxy: "localhost,127.0.0.1,::1"
3361

3462
- name: start the github-runner container
3563
become: true
3664
community.docker.docker_compose_v2:
3765
project_src: /etc/runner
3866
state: present
67+
# Image is built locally above; never try to pull it from a registry.
68+
pull: never

0 commit comments

Comments
 (0)