Skip to content

Test workflow with LLVM trunk and Linux mainline #76

Test workflow with LLVM trunk and Linux mainline

Test workflow with LLVM trunk and Linux mainline #76

name: Test workflow with LLVM trunk and Linux mainline
on:
push:
branches:
- llvm-trunk
- llvm-trunk-next
paths:
- '.github/workflows/llvm-trunk-linux-mainline.yml'
- 'ci/linux-mainline/**'
- 'patches/v2.0/**'
- 'scripts/**'
workflow_dispatch:
schedule:
# Meaningless hh:mm field to avoid peak control traffic on GitHub
- cron: '44 22 * * *'
# Allow at most one run from any workflow in this repo at the same time, as most
# of them will operate on some shared directories of self-hosted runners and
# interfere with each other. Without this setting, the below could happen:
#
# T1 T2 T3 T4
# runner1 -(R1J1--------------------R1J2)-
# ---------(R2J1----R2J2)---------
#
# Now:
#
# T1 T2 T3 T4 T5 T6
# runner1 -(R1J1----R1J2)--xxxxxxxxxxxxxx--xxxxxxxxxxxxxx-
# -xxxxxxxxxxxxxx--(R2J1----R2J2)--xxxxxxxxxxxxxx-
# runner2 -xxxxxxxxxxxxxx--xxxxxxxxxxxxxx--(R3J1----R3J2)-
#
# Ideally we want a single runner to finish all jobs from a workflow before
# accepting any other job. But I don't know how.
#
# T1 T2 T3 T4 T5 T6
# runner1 -(R1J1----R1J2)--xxxxxxxxxxxxxx-----------------
# -xxxxxxxxxxxxxx--(R3J1----R3J2)-----------------
# runner2 ---------(R2J1----R2J2)--xxxxxxxxxxxxxx---------
# ---------xxxxxxxxxxxxxx--(R4J1----R4J2)---------
#
# Or maybe we should redesign the abstraction: what ought to be workflows? what
# ought to be jobs? and what ought to be steps?
concurrency:
group: ${{ github.repository }}
env:
MCDC_HOME: /home/github-runner/mcdc-workdir
jobs:
find_runner:
name: Find an available self-hosted runner
runs-on: self-hosted
# Enforce this same runner for all later jobs that depend on this one
# FIXME this requires each runner has a label the same as its name
outputs:
runner_name: ${{ runner.name }}
# Dummy, do nothing
steps:
- uses: actions/checkout@v4
install_deps:
name: 1. Install dependencies
needs: find_runner
# Enforce the same runner
runs-on: ${{ needs.find_runner.outputs.runner_name }}
outputs:
runner_name: ${{ runner.name }}
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: ./ci/linux-mainline/1_install_deps.sh
pull_source:
name: 2. Pull the source code and apply patches
needs: install_deps
# Enforce the same runner
runs-on: ${{ needs.install_deps.outputs.runner_name }}
outputs:
runner_name: ${{ runner.name }}
steps:
- uses: actions/checkout@v4
- name: Create a workspace from clean slate
run: |
rm -rf $MCDC_HOME
mkdir -p $MCDC_HOME
- name: Pull the source code and apply patches
run: ./ci/linux-mainline/2_pull_source.sh ${{ github.repository }} ${{ github.ref_name }}
get_llvm:
name: 3. Get LLVM
needs: pull_source
# Enforce the same runner
runs-on: ${{ needs.pull_source.outputs.runner_name }}
outputs:
runner_name: ${{ runner.name }}
steps:
- uses: actions/checkout@v4
- name: Build from source
run: ./ci/linux-mainline/3_get_llvm.sh
- name: Print LLVM build resource usage
run: |
cat /tmp/time.log
du -sh $MCDC_HOME/llvm-project
build_kernel:
name: 4. Build the kernel
needs: get_llvm
# Enforce the same runner
runs-on: ${{ needs.get_llvm.outputs.runner_name }}
outputs:
runner_name: ${{ runner.name }}
steps:
- uses: actions/checkout@v4
- name: Set up LLVM path
run: echo "$MCDC_HOME/llvm-project/build/bin" >> $GITHUB_PATH
- name: Print toolchain version
run: |
clang -v
llc --version
- name: Build the kernel
run: ./ci/linux-mainline/4_build_kernel.sh
- name: Print full kernel build log
run: cat /tmp/make.log
- name: Print kernel build resource usage
run: |
cat /tmp/time.log
du -sh $MCDC_HOME/linux
- name: Print kernel binary layout
run: |
llvm-readelf --sections -W $MCDC_HOME/linux/vmlinux
boot_kernel_and_collect_coverage:
name: 5. Boot the kernel and collect coverage
needs: build_kernel
# Enforce the same runner
runs-on: ${{ needs.build_kernel.outputs.runner_name }}
outputs:
runner_name: ${{ runner.name }}
steps:
- uses: actions/checkout@v4
- name: Set up LLVM path
run: echo "$MCDC_HOME/llvm-project/build/bin" >> $GITHUB_PATH
- name: Print toolchain version
run: |
clang -v
llc --version
- name: Boot the kernel and collect coverage
run: ./ci/linux-mainline/5_boot_kernel_and_collect_coverage.sh
- name: Print the index of coverage report (immediately after reset)
run: cat $MCDC_HOME/analysis_reset/text-coverage-reports/index.txt
- name: Print the index of coverage report
run: cat $MCDC_HOME/analysis/text-coverage-reports/index.txt