Skip to content

Commit

Permalink
ci: create a reusable workflow for loading kernel cache
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeHillion committed Jan 30, 2025
1 parent 9e7418b commit 00b4071
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 162 deletions.
26 changes: 26 additions & 0 deletions .github/actions/restore-kernel-cache/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: 'Restore kernel cache'
description: 'Restore a previously built kernel cache, failing if not available'
inputs:
git-repo:
required: true
type: string
branch:
required: true
type: string

runs:
using: "composite"
steps:
- name: Get hash from repo/branch
run: echo "SCHED_EXT_KERNEL_COMMIT=$(git ls-remote ${{ inputs.git-repo }} heads/${{ inputs.branch }} | awk '{print $1}')" >> $GITHUB_ENV
shell: bash

- name: Load cache
uses: actions/cache/restore@v4
with:
fail-on-cache-miss: true
key: kernel-build-${{ env.SCHED_EXT_KERNEL_COMMIT }}-5
path: |
linux/arch/x86/boot/bzImage
linux/usr/include
linux/**/*.h
20 changes: 3 additions & 17 deletions .github/workflows/bpf-next-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,24 +95,10 @@ jobs:
- if: ${{ steps.cache-virtiofsd.outputs.cache-hit != 'true' }}
run: cargo install virtiofsd && sudo cp -a ~/.cargo/bin/virtiofsd /usr/lib/

# get latest head commit of sched_ext for-next
- run: echo "SCHED_EXT_KERNEL_COMMIT=$(git ls-remote https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git heads/for-next | awk '{print $1}')" >> $GITHUB_ENV

# use cached kernel if available, create after job if not
- name: Cache Kernel
id: cache-kernel
uses: actions/cache@v4
- uses: ./.github/actions/restore-kernel-cache
with:
path: |
linux/arch/x86/boot/bzImage
linux/usr/include
linux/**/*.h
key: kernel-build-${{ env.SCHED_EXT_KERNEL_COMMIT }}-bpf-1

# need to re-run job when kernel head changes between build and test running.
- if: ${{ steps.cache-kernel.outputs.cache-hit != 'true' }}
name: exit if cache stale
run: exit -1
git-repo: "https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git"
branch: for-next

# veristat
- run: wget https://github.com/libbpf/veristat/releases/download/v0.3.2/veristat-v0.3.2-amd64.tar.gz
Expand Down
74 changes: 12 additions & 62 deletions .github/workflows/caching-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -175,23 +175,10 @@ jobs:
- if: ${{ steps.cache-virtiofsd.outputs.cache-hit != 'true' }}
run: cargo install virtiofsd && sudo cp -a ~/.cargo/bin/virtiofsd /usr/lib/

- run: echo "SCHED_EXT_KERNEL_COMMIT=$(git ls-remote https://git.kernel.org/pub/scm/linux/kernel/git/tj/sched_ext.git heads/for-6.13 | awk '{print $1}')" >> $GITHUB_ENV

# use cached kernel if available, create after job if not
- name: Cache Kernel
id: cache-kernel
uses: actions/cache@v4
- uses: ./.github/actions/restore-kernel-cache
with:
path: |
linux/arch/x86/boot/bzImage
linux/usr/include
linux/**/*.h
key: kernel-build-${{ env.SCHED_EXT_KERNEL_COMMIT }}-5

# need to re-run job when kernel head changes between build and test running.
- if: ${{ steps.cache-kernel.outputs.cache-hit != 'true' }}
name: exit if cache stale
run: exit -1
git-repo: "https://git.kernel.org/pub/scm/linux/kernel/git/tj/sched_ext.git"
branch: for-6.13

# veristat
- run: wget https://github.com/libbpf/veristat/releases/download/v0.3.2/veristat-v0.3.2-amd64.tar.gz
Expand Down Expand Up @@ -264,23 +251,10 @@ jobs:
- if: ${{ steps.cache-virtiofsd.outputs.cache-hit != 'true' }}
run: cargo install virtiofsd && sudo cp -a ~/.cargo/bin/virtiofsd /usr/lib/

- run: echo "SCHED_EXT_KERNEL_COMMIT=$(git ls-remote https://git.kernel.org/pub/scm/linux/kernel/git/tj/sched_ext.git heads/for-6.13 | awk '{print $1}')" >> $GITHUB_ENV

# use cached kernel if available, create after job if not
- name: Cache Kernel
id: cache-kernel
uses: actions/cache@v4
- uses: ./.github/actions/restore-kernel-cache
with:
path: |
linux/arch/x86/boot/bzImage
linux/usr/include
linux/**/*.h
key: kernel-build-${{ env.SCHED_EXT_KERNEL_COMMIT }}-5

# need to re-run job when kernel head changes between build and test running.
- if: ${{ steps.cache-kernel.outputs.cache-hit != 'true' }}
name: exit if cache stale
run: exit -1
git-repo: "https://git.kernel.org/pub/scm/linux/kernel/git/tj/sched_ext.git"
branch: for-6.13

# The actual build:
- run: meson setup build -Dkernel=../linux/arch/x86/boot/bzImage -Dkernel_headers=../linux -Denable_stress=true -Dvng_rw_mount=true -Dextra_sched_args=" ${{ matrix.topo }} ${{ matrix.antistall }}"
Expand Down Expand Up @@ -338,22 +312,10 @@ jobs:
- if: ${{ steps.cache-virtiofsd.outputs.cache-hit != 'true' }}
run: cargo install virtiofsd && sudo cp -a ~/.cargo/bin/virtiofsd /usr/lib/

- run: echo "SCHED_EXT_KERNEL_COMMIT=$(git ls-remote https://git.kernel.org/pub/scm/linux/kernel/git/tj/sched_ext.git heads/for-6.13 | awk '{print $1}')" >> $GITHUB_ENV

- name: Cache Kernel
id: cache-kernel
uses: actions/cache@v4
- uses: ./.github/actions/restore-kernel-cache
with:
path: |
linux/arch/x86/boot/bzImage
linux/usr/include
linux/**/*.h
key: kernel-build-${{ env.SCHED_EXT_KERNEL_COMMIT }}-5

# need to re-run job when kernel head changes between build and test running.
- if: ${{ steps.cache-kernel.outputs.cache-hit != 'true' }}
name: exit if cache stale
run: exit -1
git-repo: "https://git.kernel.org/pub/scm/linux/kernel/git/tj/sched_ext.git"
branch: for-6.13

- run: cargo build --manifest-path rust/${{ matrix.component }}/Cargo.toml
- run: vng -v --rw --memory 10G --cpu 8 -r linux/arch/x86/boot/bzImage --network user -- cargo test --manifest-path rust/${{ matrix.component }}/Cargo.toml
Expand All @@ -380,22 +342,10 @@ jobs:
- if: ${{ steps.cache-virtiofsd.outputs.cache-hit != 'true' }}
run: cargo install virtiofsd && sudo cp -a ~/.cargo/bin/virtiofsd /usr/lib/

- run: echo "SCHED_EXT_KERNEL_COMMIT=$(git ls-remote https://git.kernel.org/pub/scm/linux/kernel/git/tj/sched_ext.git heads/for-6.13 | awk '{print $1}')" >> $GITHUB_ENV
# Cache Kernel alone for rust tests
- name: Cache Kernel
id: cache-kernel
uses: actions/cache@v4
- uses: ./.github/actions/restore-kernel-cache
with:
path: |
linux/arch/x86/boot/bzImage
linux/usr/include
linux/**/*.h
key: kernel-build-${{ env.SCHED_EXT_KERNEL_COMMIT }}-5

# need to re-run job when kernel head changes between build and test running.
- if: ${{ steps.cache-kernel.outputs.cache-hit != 'true' }}
name: exit if cache stale
run: exit -1
git-repo: "https://git.kernel.org/pub/scm/linux/kernel/git/tj/sched_ext.git"
branch: for-6.13

- run: cargo build --manifest-path scheds/rust/${{ matrix.scheduler }}/Cargo.toml
- run: vng -v --rw --memory 10G --cpu 8 -r linux/arch/x86/boot/bzImage --network user -- cargo test --manifest-path scheds/rust/${{ matrix.scheduler }}/Cargo.toml
Expand Down
78 changes: 12 additions & 66 deletions .github/workflows/for-next-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,24 +116,10 @@ jobs:
- if: ${{ steps.cache-virtiofsd.outputs.cache-hit != 'true' }}
run: cargo install virtiofsd && sudo cp -a ~/.cargo/bin/virtiofsd /usr/lib/

# get latest head commit of sched_ext for-next
- run: echo "SCHED_EXT_KERNEL_COMMIT=$(git ls-remote https://git.kernel.org/pub/scm/linux/kernel/git/tj/sched_ext.git heads/for-next | awk '{print $1}')" >> $GITHUB_ENV

# use cached kernel if available, create after job if not
- name: Cache Kernel
id: cache-kernel
uses: actions/cache@v4
- uses: ./.github/actions/restore-kernel-cache
with:
path: |
linux/arch/x86/boot/bzImage
linux/usr/include
linux/**/*.h
key: kernel-build-${{ env.SCHED_EXT_KERNEL_COMMIT }}-5

# need to re-run job when kernel head changes between build and test running.
- if: ${{ steps.cache-kernel.outputs.cache-hit != 'true' }}
name: exit if cache stale
run: exit -1
git-repo: "https://git.kernel.org/pub/scm/linux/kernel/git/tj/sched_ext.git"
branch: for-next

# veristat
- run: wget https://github.com/libbpf/veristat/releases/download/v0.3.2/veristat-v0.3.2-amd64.tar.gz
Expand Down Expand Up @@ -206,24 +192,10 @@ jobs:
- if: ${{ steps.cache-virtiofsd.outputs.cache-hit != 'true' }}
run: cargo install virtiofsd && sudo cp -a ~/.cargo/bin/virtiofsd /usr/lib/

# get latest head commit of sched_ext for-next
- run: echo "SCHED_EXT_KERNEL_COMMIT=$(git ls-remote https://git.kernel.org/pub/scm/linux/kernel/git/tj/sched_ext.git heads/for-next | awk '{print $1}')" >> $GITHUB_ENV

# use cached kernel if available, create after job if not
- name: Cache Kernel
id: cache-kernel
uses: actions/cache@v4
- uses: ./.github/actions/restore-kernel-cache
with:
path: |
linux/arch/x86/boot/bzImage
linux/usr/include
linux/**/*.h
key: kernel-build-${{ env.SCHED_EXT_KERNEL_COMMIT }}-5

# need to re-run job when kernel head changes between build and test running.
- if: ${{ steps.cache-kernel.outputs.cache-hit != 'true' }}
name: exit if cache stale
run: exit -1
git-repo: "https://git.kernel.org/pub/scm/linux/kernel/git/tj/sched_ext.git"
branch: for-next

# The actual build:
- run: meson setup build -Dkernel=../linux/arch/x86/boot/bzImage -Dkernel_headers=../linux -Denable_stress=true -Dvng_rw_mount=true -Dextra_sched_args=" ${{ matrix.topo }} ${{ matrix.antistall }}"
Expand Down Expand Up @@ -281,23 +253,10 @@ jobs:
- if: ${{ steps.cache-virtiofsd.outputs.cache-hit != 'true' }}
run: cargo install virtiofsd && sudo cp -a ~/.cargo/bin/virtiofsd /usr/lib/

# get latest head commit of sched_ext for-next
- run: echo "SCHED_EXT_KERNEL_COMMIT=$(git ls-remote https://git.kernel.org/pub/scm/linux/kernel/git/tj/sched_ext.git heads/for-next | awk '{print $1}')" >> $GITHUB_ENV

- name: Cache Kernel
id: cache-kernel
uses: actions/cache@v4
- uses: ./.github/actions/restore-kernel-cache
with:
path: |
linux/arch/x86/boot/bzImage
linux/usr/include
linux/**/*.h
key: kernel-build-${{ env.SCHED_EXT_KERNEL_COMMIT }}-5

# need to re-run job when kernel head changes between build and test running.
- if: ${{ steps.cache-kernel.outputs.cache-hit != 'true' }}
name: exit if cache stale
run: exit -1
git-repo: "https://git.kernel.org/pub/scm/linux/kernel/git/tj/sched_ext.git"
branch: for-next

- run: cargo build --manifest-path rust/${{ matrix.component }}/Cargo.toml
- run: vng -v --rw --memory 10G --cpu 8 -r linux/arch/x86/boot/bzImage --network user -- cargo test --manifest-path rust/${{ matrix.component }}/Cargo.toml
Expand All @@ -324,23 +283,10 @@ jobs:
- if: ${{ steps.cache-virtiofsd.outputs.cache-hit != 'true' }}
run: cargo install virtiofsd && sudo cp -a ~/.cargo/bin/virtiofsd /usr/lib/

# get latest head commit of sched_ext for-next
- run: echo "SCHED_EXT_KERNEL_COMMIT=$(git ls-remote https://git.kernel.org/pub/scm/linux/kernel/git/tj/sched_ext.git heads/for-next | awk '{print $1}')" >> $GITHUB_ENV
# Cache Kernel alone for rust tests
- name: Cache Kernel
id: cache-kernel
uses: actions/cache@v4
- uses: ./.github/actions/restore-kernel-cache
with:
path: |
linux/arch/x86/boot/bzImage
linux/usr/include
linux/**/*.h
key: kernel-build-${{ env.SCHED_EXT_KERNEL_COMMIT }}-5

# need to re-run job when kernel head changes between build and test running.
- if: ${{ steps.cache-kernel.outputs.cache-hit != 'true' }}
name: exit if cache stale
run: exit -1
git-repo: "https://git.kernel.org/pub/scm/linux/kernel/git/tj/sched_ext.git"
branch: for-next

- run: cargo build --manifest-path scheds/rust/${{ matrix.scheduler }}/Cargo.toml
- run: vng -v --rw --memory 10G --cpu 8 -r linux/arch/x86/boot/bzImage --network user -- cargo test --manifest-path scheds/rust/${{ matrix.scheduler }}/Cargo.toml
Expand Down
20 changes: 3 additions & 17 deletions .github/workflows/stable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,24 +95,10 @@ jobs:
- if: ${{ steps.cache-virtiofsd.outputs.cache-hit != 'true' }}
run: cargo install virtiofsd && sudo cp -a ~/.cargo/bin/virtiofsd /usr/lib/

# get latest head commit of linux-rolling-stable
- run: echo "SCHED_EXT_KERNEL_COMMIT=$(git ls-remote https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git heads/linux-rolling-stable | awk '{print $1}')" >> $GITHUB_ENV

# use cached kernel if available, create after job if not
- name: Cache Kernel
id: cache-kernel
uses: actions/cache@v4
- uses: ./.github/actions/restore-kernel-cache
with:
path: |
linux/arch/x86/boot/bzImage
linux/usr/include
linux/**/*.h
key: kernel-build-${{ env.SCHED_EXT_KERNEL_COMMIT }}-stable-1

# need to re-run job when kernel head changes between build and test running.
- if: ${{ steps.cache-kernel.outputs.cache-hit != 'true' }}
name: exit if cache stale
run: exit -1
git-repo: "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git"
branch: linux-rolling-stable

# veristat
- run: wget https://github.com/libbpf/veristat/releases/download/v0.3.2/veristat-v0.3.2-amd64.tar.gz
Expand Down

0 comments on commit 00b4071

Please sign in to comment.