diff --git a/.github/actions/build-and-test/action.yml b/.github/actions/build-and-test/action.yml new file mode 100644 index 00000000..ecaa5c1d --- /dev/null +++ b/.github/actions/build-and-test/action.yml @@ -0,0 +1,45 @@ +# Build homa.ko and util, and run the unit tests, both for the module as +# it is and stripped (__STRIP__=1). The calling job sets up the kernel +# tree first (e.g. actions/checkout) and exports its location as KDIR; +# other build settings (e.g. KBUILD_MODPOST_WARN) also come from the +# job's environment. +name: Build and test Homa +description: Build homa.ko and util, and run the unit tests, plain and stripped. + +runs: + using: composite + steps: + - name: Build homa.ko + shell: bash + run: make + + # Build only: running these tools needs a loaded Homa module. + - name: Build util + shell: bash + run: make -C util -j$(nproc) + + - name: Unit tests (IPv6) + shell: bash + run: make -C test -j$(nproc) unit && cd test && ./unit + + - name: Unit tests (IPv4) + if: ${{ !cancelled() }} + shell: bash + run: cd test && ./unit --ipv4 + + # The stripped version (__STRIP__=1), with the same kernel. + - name: Build homa.ko (stripped) + if: ${{ !cancelled() }} + shell: bash + run: make __STRIP__=1 + + # Clean first: both versions of the unit tests use the same object files. + - name: Unit tests, stripped (IPv6) + if: ${{ !cancelled() }} + shell: bash + run: make -C test clean && make -C test -j$(nproc) __STRIP__=1 unit && cd test && ./unit + + - name: Unit tests, stripped (IPv4) + if: ${{ !cancelled() }} + shell: bash + run: cd test && ./unit --ipv4 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3acb0e7d..f9826762 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,6 +15,9 @@ jobs: runs-on: ubuntu-24.04 env: LINUX_VERSION: 6.17.8 + # Without vmlinux there is no Module.symvers, so modpost can't + # resolve kernel symbols; report those as warnings. + KBUILD_MODPOST_WARN: 1 # The base for checkpatch: a pull request's base, or the branch tip before a push. BASE_SHA: ${{ github.event.pull_request.base.sha || github.event.before }} steps: @@ -38,35 +41,8 @@ jobs: make -j$(nproc) modules_prepare echo "KDIR=$PWD" >> $GITHUB_ENV - # Without vmlinux there is no Module.symvers, so modpost can't - # resolve kernel symbols; report those as warnings. - - name: Build homa.ko - run: make KBUILD_MODPOST_WARN=1 - - # Build only: running these tools needs a loaded Homa module. - - name: Build util - run: make -C util -j$(nproc) - - - name: Unit tests (IPv6) - run: make -C test -j$(nproc) unit && cd test && ./unit - - - name: Unit tests (IPv4) - if: ${{ !cancelled() }} - run: cd test && ./unit --ipv4 - - # The stripped version (__STRIP__=1), with the same kernel. - - name: Build homa.ko (stripped) - if: ${{ !cancelled() }} - run: make KBUILD_MODPOST_WARN=1 __STRIP__=1 - - # Clean first: both versions of the unit tests use the same object files. - - name: Unit tests, stripped (IPv6) - if: ${{ !cancelled() }} - run: make -C test clean && make -C test -j$(nproc) __STRIP__=1 unit && cd test && ./unit - - - name: Unit tests, stripped (IPv4) - if: ${{ !cancelled() }} - run: cd test && ./unit --ipv4 + - name: Build and test + uses: ./.github/actions/build-and-test # checkpatch the change of a pull request or push (see the script): # the module sources as they are, then the files that go upstream. diff --git a/.github/workflows/rhel-ci.yml b/.github/workflows/rhel-ci.yml new file mode 100644 index 00000000..943dd02d --- /dev/null +++ b/.github/workflows/rhel-ci.yml @@ -0,0 +1,77 @@ +# Build homa.ko and run the unit tests against a RHEL kernel (kernel-devel). +name: CI (RHEL) + +# Run for the RHEL branches and pull requests into them (a pull request's +# branches filter matches its base branch). Pushes to other branches +# don't run this; use workflow_dispatch to run it on one by hand. +on: + push: + branches: [rhel8, rhel_9.5] + pull_request: + branches: [rhel8, rhel_9.5] + workflow_dispatch: + +jobs: + # Pick the RHEL target from the branch: a pull request's base, or the + # pushed branch. Branches for no RHEL target get an empty target, and + # the build is skipped. + select: + runs-on: ubuntu-24.04 + env: + # Per-branch target: the container image and the exact kernel + # (kernel-devel) to build and test against. "repo" is the AlmaLinux + # repository the packages come from: a minor release that is no + # longer current is only in vault.almalinux.org. + TARGETS: >- + { + "rhel8": {"image": "almalinux:8.10", "kver": "4.18.0-553.190.1.el8_10", "repo": "https://repo.almalinux.org/almalinux/8.10"}, + "rhel_9.5": {"image": "almalinux:9.5", "kver": "5.14.0-503.40.1.el9_5", "repo": "https://vault.almalinux.org/9.5"} + } + BRANCH: ${{ github.base_ref || github.ref_name }} + outputs: + image: ${{ steps.select.outputs.image }} + kver: ${{ steps.select.outputs.kver }} + repo: ${{ steps.select.outputs.repo }} + steps: + - id: select + run: | + case "$BRANCH" in + *rhel_9.5*) name=rhel_9.5 ;; + *rhel8*) name=rhel8 ;; + *) name= ;; + esac + target='{}' + if [ -n "$name" ]; then + target=$(jq -c --arg name "$name" '.[$name]' <<< "$TARGETS") + fi + echo "Branch $BRANCH: target ${name:-none} $target" + for field in image kver repo; do + echo "$field=$(jq -r --arg f "$field" '.[$f] // ""' <<< "$target")" >> "$GITHUB_OUTPUT" + done + + build-and-test: + needs: select + if: ${{ needs.select.outputs.image != '' }} + name: build-and-test (${{ needs.select.outputs.image }}, kernel ${{ needs.select.outputs.kver }}) + runs-on: ubuntu-24.04 + container: ${{ needs.select.outputs.image }} # run the build in a container for RHEL compatibility + env: + KVER: ${{ needs.select.outputs.kver }} + ALMA_REPO: ${{ needs.select.outputs.repo }} + steps: + - uses: actions/checkout@v5 + + - name: Install kernel build dependencies + run: | + # Install from the target's repository only, not the image's + # mirrors: those carry just the current minor release. + dnf install -y --repo=baseos,appstream \ + --setopt='*.mirrorlist=' \ + --setopt="baseos.baseurl=$ALMA_REPO/BaseOS/\$basearch/os/" \ + --setopt="appstream.baseurl=$ALMA_REPO/AppStream/\$basearch/os/" \ + "kernel-devel-$KVER" gcc gcc-c++ make elfutils-libelf-devel libasan + + - name: Build and test + uses: ./.github/actions/build-and-test + env: + KDIR: "/usr/src/kernels/${{ env.KVER }}.x86_64"