1
0
mirror of https://github.com/kata-containers/kata-containers.git synced 2025-05-01 21:24:36 +00:00

ci: Refactor build-checks workflow

Refator matrix setup and according dependencies installation logic in
`build-checks.yaml` and `build-checks-preview-riscv64.yaml` to provide
better readability and maintainability.

Signed-off-by: Ruoqing He <heruoqing@iscas.ac.cn>
This commit is contained in:
Ruoqing He 2025-02-27 11:27:04 +08:00
parent eb94700590
commit 09030ee96e
2 changed files with 91 additions and 59 deletions

View File

@ -19,22 +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
- component: genpolicy - musl-tools
component-path: src/tools/genpolicy - protobuf-compiler
- 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: |
@ -53,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: Install 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 - name: Install musl-tools
if: ${{ matrix.component != 'runtime' }} if: contains(matrix.component.needs, 'musl-tools')
run: sudo apt-get -y install musl-tools run: sudo apt-get -y install musl-tools
- 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.component == 'agent' }} 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)
@ -78,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,37 +12,60 @@ 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 - musl-tools
component-path: src/runtime - libdevmapper
- component: runtime-rs - libseccomp
component-path: src/runtime-rs - protobuf-compiler
- component: agent-ctl - clang
component-path: src/tools/agent-ctl - name: dragonball
- component: kata-ctl path: src/dragonball
component-path: src/tools/kata-ctl needs:
- component: trace-forwarder - rust
component-path: src/tools/trace-forwarder - musl-tools
- component: genpolicy - name: runtime
component-path: src/tools/genpolicy path: src/runtime
needs:
- golang
- XDG_RUNTIME_DIR
- name: runtime-rs
path: src/runtime-rs
needs:
- rust
- musl-tools
- name: agent-ctl
path: src/tools/agent-ctl
needs:
- rust
- musl-tools
- protobuf-compiler
- clang
- name: kata-ctl
path: src/tools/kata-ctl
needs:
- rust
- musl-tools
- 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: |
@ -61,23 +84,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: Install 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 - name: Install musl-tools
if: ${{ matrix.component != 'runtime' }} if: contains(matrix.component.needs, 'musl-tools')
run: sudo apt-get -y install musl-tools run: sudo apt-get -y install musl-tools
- 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.component == 'agent' }} 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)
@ -86,13 +109,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"
@ -100,9 +123,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"