Merge pull request #10948 from RuoqingHe/better-matrix

ci: Refactor matrix for `build-checks`
This commit is contained in:
Steve Horsman 2025-03-11 14:13:10 +00:00 committed by GitHub
commit 420b282279
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 90 additions and 69 deletions

View File

@ -19,23 +19,31 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
component:
- agent-ctl
- trace-forwarder
- genpolicy
command: command:
- "make vendor" - "make vendor"
- "make check" - "make check"
- "make test" - "make test"
- "sudo -E PATH=\"$PATH\" make test" - "sudo -E PATH=\"$PATH\" make test"
include: component:
- component: agent-ctl - name: agent-ctl
component-path: src/tools/agent-ctl path: src/tools/agent-ctl
- component: trace-forwarder needs:
component-path: src/tools/trace-forwarder - rust
- install-libseccomp: no - musl-tools
- component: genpolicy - protobuf-compiler
component-path: src/tools/genpolicy - clang
- name: trace-forwarder
path: src/tools/trace-forwarder
needs:
- rust
- musl-tools
- name: genpolicy
path: src/tools/genpolicy
needs:
- rust
- musl-tools
- protobuf-compiler
steps: steps:
- name: Adjust a permission for repo - name: Adjust a permission for repo
run: | run: |
@ -54,23 +62,23 @@ jobs:
env: env:
INSTALL_IN_GOPATH: false INSTALL_IN_GOPATH: false
- name: Install golang - name: Install golang
if: ${{ matrix.component == 'runtime' }} if: contains(matrix.component.needs, 'golang')
run: | run: |
./tests/install_go.sh -f -p ./tests/install_go.sh -f -p
echo "/usr/local/go/bin" >> "$GITHUB_PATH" echo "/usr/local/go/bin" >> "$GITHUB_PATH"
- name: Install rust - name: Setup rust
if: ${{ matrix.component != 'runtime' }} if: contains(matrix.component.needs, 'rust')
run: | run: |
./tests/install_rust.sh ./tests/install_rust.sh
echo "${HOME}/.cargo/bin" >> "$GITHUB_PATH" echo "${HOME}/.cargo/bin" >> "$GITHUB_PATH"
- name: Install musl-tools if [ "$(uname -m)" == "x86_64" ] || [ "$(uname -m)" == "aarch64" ]; then
if: ${{ matrix.component != 'runtime' }} sudo apt-get -y install musl-tools
run: sudo apt-get -y install musl-tools fi
- name: Install devicemapper - name: Install devicemapper
if: ${{ matrix.command == 'make check' && matrix.component == 'agent' }} if: contains(matrix.component.needs, 'libdevmapper') && matrix.command == 'make check'
run: sudo apt-get -y install libdevmapper-dev run: sudo apt-get -y install libdevmapper-dev
- name: Install libseccomp - name: Install libseccomp
if: ${{ matrix.command != 'make vendor' && matrix.command != 'make check' && matrix.install-libseccomp == 'yes' }} if: contains(matrix.component.needs, 'libseccomp') && matrix.command != 'make vendor' && matrix.command != 'make check'
run: | run: |
libseccomp_install_dir=$(mktemp -d -t libseccomp.XXXXXXXXXX) libseccomp_install_dir=$(mktemp -d -t libseccomp.XXXXXXXXXX)
gperf_install_dir=$(mktemp -d -t gperf.XXXXXXXXXX) gperf_install_dir=$(mktemp -d -t gperf.XXXXXXXXXX)
@ -79,19 +87,19 @@ jobs:
echo "LIBSECCOMP_LINK_TYPE=static" >> "$GITHUB_ENV" echo "LIBSECCOMP_LINK_TYPE=static" >> "$GITHUB_ENV"
echo "LIBSECCOMP_LIB_PATH=${libseccomp_install_dir}/lib" >> "$GITHUB_ENV" echo "LIBSECCOMP_LIB_PATH=${libseccomp_install_dir}/lib" >> "$GITHUB_ENV"
- name: Install protobuf-compiler - name: Install protobuf-compiler
if: ${{ matrix.command != 'make vendor' && (matrix.component == 'agent' || matrix.component == 'genpolicy' || matrix.component == 'agent-ctl') }} if: contains(matrix.component.needs, 'protobuf-compiler') && matrix.command != 'make vendor'
run: sudo apt-get -y install protobuf-compiler run: sudo apt-get -y install protobuf-compiler
- name: Install clang - name: Install clang
if: ${{ matrix.command == 'make check' && (matrix.component == 'agent' || matrix.component == 'agent-ctl') }} if: contains(matrix.component.needs, 'clang') && matrix.command == 'make check'
run: sudo apt-get -y install clang run: sudo apt-get -y install clang
- name: Setup XDG_RUNTIME_DIR for the `runtime` tests - name: Setup XDG_RUNTIME_DIR
if: ${{ matrix.command != 'make vendor' && matrix.command != 'make check' && matrix.component == 'runtime' }} if: contains(matrix.component.needs, 'XDG_RUNTIME_DIR') && matrix.command != 'make check'
run: | run: |
XDG_RUNTIME_DIR=$(mktemp -d "/tmp/kata-tests-$USER.XXX" | tee >(xargs chmod 0700)) XDG_RUNTIME_DIR=$(mktemp -d "/tmp/kata-tests-$USER.XXX" | tee >(xargs chmod 0700))
echo "XDG_RUNTIME_DIR=${XDG_RUNTIME_DIR}" >> "$GITHUB_ENV" echo "XDG_RUNTIME_DIR=${XDG_RUNTIME_DIR}" >> "$GITHUB_ENV"
- name: Running `${{ matrix.command }}` for ${{ matrix.component }} - name: Running `${{ matrix.command }}` for ${{ matrix.component.name }}
run: | run: |
cd ${{ matrix.component-path }} cd ${{ matrix.component.path }}
${{ matrix.command }} ${{ matrix.command }}
env: env:
RUST_BACKTRACE: "1" RUST_BACKTRACE: "1"

View File

@ -12,40 +12,53 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
component:
- agent
- dragonball
- runtime
- runtime-rs
- agent-ctl
- kata-ctl
- trace-forwarder
- genpolicy
command: command:
- "make vendor" - "make vendor"
- "make check" - "make check"
- "make test" - "make test"
- "sudo -E PATH=\"$PATH\" make test" - "sudo -E PATH=\"$PATH\" make test"
include: component:
- component: agent - name: agent
component-path: src/agent path: src/agent
- component: dragonball needs:
component-path: src/dragonball - rust
- component: runtime - libdevmapper
component-path: src/runtime - libseccomp
- component: runtime-rs - protobuf-compiler
component-path: src/runtime-rs - clang
- component: agent-ctl - name: dragonball
component-path: src/tools/agent-ctl path: src/dragonball
- component: kata-ctl needs:
component-path: src/tools/kata-ctl - rust
- component: trace-forwarder - name: runtime
component-path: src/tools/trace-forwarder path: src/runtime
- install-libseccomp: no needs:
- component: agent - golang
install-libseccomp: yes - XDG_RUNTIME_DIR
- component: genpolicy - name: runtime-rs
component-path: src/tools/genpolicy path: src/runtime-rs
needs:
- rust
- name: agent-ctl
path: src/tools/agent-ctl
needs:
- rust
- protobuf-compiler
- clang
- name: kata-ctl
path: src/tools/kata-ctl
needs:
- rust
- name: trace-forwarder
path: src/tools/trace-forwarder
needs:
- rust
- name: genpolicy
path: src/tools/genpolicy
needs:
- rust
- protobuf-compiler
steps: steps:
- name: Adjust a permission for repo - name: Adjust a permission for repo
run: | run: |
@ -64,23 +77,23 @@ jobs:
env: env:
INSTALL_IN_GOPATH: false INSTALL_IN_GOPATH: false
- name: Install golang - name: Install golang
if: ${{ matrix.component == 'runtime' }} if: contains(matrix.component.needs, 'golang')
run: | run: |
./tests/install_go.sh -f -p ./tests/install_go.sh -f -p
echo "/usr/local/go/bin" >> "$GITHUB_PATH" echo "/usr/local/go/bin" >> "$GITHUB_PATH"
- name: Install rust - name: Setup rust
if: ${{ matrix.component != 'runtime' }} if: contains(matrix.component.needs, 'rust')
run: | run: |
./tests/install_rust.sh ./tests/install_rust.sh
echo "${HOME}/.cargo/bin" >> "$GITHUB_PATH" echo "${HOME}/.cargo/bin" >> "$GITHUB_PATH"
- name: Install musl-tools if [ "$(uname -m)" == "x86_64" ] || [ "$(uname -m)" == "aarch64" ]; then
if: ${{ matrix.component != 'runtime' }} sudo apt-get -y install musl-tools
run: sudo apt-get -y install musl-tools fi
- name: Install devicemapper - name: Install devicemapper
if: ${{ matrix.command == 'make check' && matrix.component == 'agent' }} if: contains(matrix.component.needs, 'libdevmapper') && matrix.command == 'make check'
run: sudo apt-get -y install libdevmapper-dev run: sudo apt-get -y install libdevmapper-dev
- name: Install libseccomp - name: Install libseccomp
if: ${{ matrix.command != 'make vendor' && matrix.command != 'make check' && matrix.install-libseccomp == 'yes' }} if: contains(matrix.component.needs, 'libseccomp') && matrix.command != 'make vendor' && matrix.command != 'make check'
run: | run: |
libseccomp_install_dir=$(mktemp -d -t libseccomp.XXXXXXXXXX) libseccomp_install_dir=$(mktemp -d -t libseccomp.XXXXXXXXXX)
gperf_install_dir=$(mktemp -d -t gperf.XXXXXXXXXX) gperf_install_dir=$(mktemp -d -t gperf.XXXXXXXXXX)
@ -89,13 +102,13 @@ jobs:
echo "LIBSECCOMP_LINK_TYPE=static" >> "$GITHUB_ENV" echo "LIBSECCOMP_LINK_TYPE=static" >> "$GITHUB_ENV"
echo "LIBSECCOMP_LIB_PATH=${libseccomp_install_dir}/lib" >> "$GITHUB_ENV" echo "LIBSECCOMP_LIB_PATH=${libseccomp_install_dir}/lib" >> "$GITHUB_ENV"
- name: Install protobuf-compiler - name: Install protobuf-compiler
if: ${{ matrix.command != 'make vendor' && (matrix.component == 'agent' || matrix.component == 'genpolicy' || matrix.component == 'agent-ctl') }} if: contains(matrix.component.needs, 'protobuf-compiler') && matrix.command != 'make vendor'
run: sudo apt-get -y install protobuf-compiler run: sudo apt-get -y install protobuf-compiler
- name: Install clang - name: Install clang
if: ${{ matrix.command == 'make check' && (matrix.component == 'agent' || matrix.component == 'agent-ctl') }} if: contains(matrix.component.needs, 'clang') && matrix.command == 'make check'
run: sudo apt-get -y install clang run: sudo apt-get -y install clang
- name: Setup XDG_RUNTIME_DIR for the `runtime` tests - name: Setup XDG_RUNTIME_DIR
if: ${{ matrix.command != 'make vendor' && matrix.command != 'make check' && matrix.component == 'runtime' }} if: contains(matrix.component.needs, 'XDG_RUNTIME_DIR') && matrix.command != 'make check'
run: | run: |
XDG_RUNTIME_DIR=$(mktemp -d "/tmp/kata-tests-$USER.XXX" | tee >(xargs chmod 0700)) XDG_RUNTIME_DIR=$(mktemp -d "/tmp/kata-tests-$USER.XXX" | tee >(xargs chmod 0700))
echo "XDG_RUNTIME_DIR=${XDG_RUNTIME_DIR}" >> "$GITHUB_ENV" echo "XDG_RUNTIME_DIR=${XDG_RUNTIME_DIR}" >> "$GITHUB_ENV"
@ -103,9 +116,9 @@ jobs:
if: ${{ endsWith(inputs.instance, '-arm') }} if: ${{ endsWith(inputs.instance, '-arm') }}
run: | run: |
echo "GITHUB_RUNNER_CI_ARM64=true" >> "$GITHUB_ENV" echo "GITHUB_RUNNER_CI_ARM64=true" >> "$GITHUB_ENV"
- name: Running `${{ matrix.command }}` for ${{ matrix.component }} - name: Running `${{ matrix.command }}` for ${{ matrix.component.name }}
run: | run: |
cd ${{ matrix.component-path }} cd ${{ matrix.component.path }}
${{ matrix.command }} ${{ matrix.command }}
env: env:
RUST_BACKTRACE: "1" RUST_BACKTRACE: "1"