-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
With this patch, four kinds of tests are triggered when there is a pull request created in a Github kexec-tools repo, - format check using shfmt - static analysis using shellcheck - ShellSpec unit tests (test cases in spec/) - integration tests ( tests cases in tests/) The tests are run inside a docker image. This docker image has all the needed software installed including fedpkg, shellspec and etc. This Docker image also provides /usr/share/cloud_images/Fedora-Cloud-Base-Generic.x86_64-40-1.14.qcow2 to avoid repeatedly downloading the Fedora 40 cloud base image each time the tests are triggered. Signed-off-by: Coiby Xu <coxu@redhat.com>
- Loading branch information
Showing
2 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
name: kexec-tools tests | ||
|
||
on: pull_request | ||
|
||
jobs: | ||
format-check: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- run: wget https://github.com/mvdan/sh/releases/download/v3.4.3/shfmt_v3.4.3_linux_amd64 -O /usr/local/bin/shfmt && chmod +x /usr/local/bin/shfmt | ||
- run: shfmt -d *.sh kdumpctl mk*dumprd | ||
|
||
static-analysis: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- run: curl -L -O https://github.com/koalaman/shellcheck/releases/download/v0.8.0/shellcheck-v0.8.0.linux.x86_64.tar.xz && tar -xJf shellcheck-v0.8.0.linux.x86_64.tar.xz | ||
# Currently, for kexec-tools, there is need for shellcheck to require | ||
# the sourced file to give correct warnings about the checked file | ||
- run: shellcheck-v0.8.0/shellcheck --exclude=1090,1091 *.sh spec/*.sh kdumpctl mk*dumprd | ||
|
||
unit-tests: | ||
runs-on: ubuntu-latest | ||
container: docker.io/fedora:latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- run: sudo dnf install -y make dracut grubby hostname | ||
- run: curl -L -O https://github.com/shellspec/shellspec/archive/latest.tar.gz && tar -xzf latest.tar.gz | ||
- run: cd shellspec-latest && sudo make install | ||
- run: shellspec | ||
|
||
integration-tests: | ||
runs-on: self-hosted | ||
timeout-minutes: 45 | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.container }}-${{ matrix.test }} | ||
cancel-in-progress: true | ||
strategy: | ||
matrix: | ||
container: [ | ||
"fedora:40", | ||
] | ||
fail-fast: false | ||
container: | ||
image: ghcr.io/coiby/${{ matrix.container }} | ||
options: "--privileged -v /dev:/dev -v /lib/modules:/lib/modules:ro" | ||
steps: | ||
- name: "Checkout Repository" | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
- name: "${{ matrix.container }} kdump tests" | ||
run: bash ./tools/run-integration-tests.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/bin/bash | ||
set -ex | ||
|
||
[[ -d ${0%/*} ]] && cd "${0%/*}"/../ | ||
|
||
source /etc/os-release | ||
|
||
cd tests | ||
|
||
# fedpkg fetch sources based on branch.f$VERSION_ID.remote | ||
if ! grep -q fedora_src <(git remote show); then | ||
git remote add fedora_src https://src.fedoraproject.org/rpms/kexec-tools.git | ||
fi | ||
git config --add branch.f$VERSION_ID.remote fedora_src | ||
|
||
can_we_use_qemu_nbd() | ||
{ | ||
_tmp_img=/tmp/test.qcow2 | ||
|
||
(sudo -v && sudo modprobe nbd \ | ||
&& qemu-img create -fqcow2 $_tmp_img 10m \ | ||
&& qemu-nbd -c /dev/nbd0 $_tmp_img && sudo qemu-nbd -d /dev/nbd0 && rm $_tmp_img) &> /dev/null | ||
} | ||
|
||
if ! can_we_use_qemu_nbd; then | ||
USE_GUESTMOUNT=1 | ||
fi | ||
|
||
KUMP_TEST_QEMU_TIMEOUT=20m USE_GUESTMOUNT=$USE_GUESTMOUNT BASE_IMAGE=/usr/share/cloud_images/Fedora-Cloud-Base-Generic.x86_64-40-1.14.qcow2 RELEASE=$VERSION_ID make test-run |