Skip to content

Commit e277c1b

Browse files
committed
tests: enable Github action
With this patch, four kinds of tests are triggered when there is a pull request created in a Github kdump-uitls repo, - format check using shfmt - static analysis using shellcheck - ShellSpec unit tests (test cases in spec/) - integration tests (tests cases in tests/) Signed-off-by: Coiby Xu <[email protected]>
1 parent 9bc3430 commit e277c1b

File tree

2 files changed

+84
-0
lines changed

2 files changed

+84
-0
lines changed

.github/workflows/main.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: kdump-utils tests
2+
3+
on: pull_request
4+
5+
jobs:
6+
format-check:
7+
runs-on: ubuntu-latest
8+
container: docker.io/fedora:latest
9+
steps:
10+
- uses: actions/checkout@v4
11+
- run: dnf install shfmt -y
12+
- run: shfmt -s -d *.sh kdumpctl mk*dumprd tests/*/*/*.sh
13+
14+
static-analysis:
15+
runs-on: ubuntu-latest
16+
container: docker.io/fedora:latest
17+
steps:
18+
- uses: actions/checkout@v4
19+
- run: dnf install shellcheck -y
20+
# Currently, for kdump-utils, there is need for shellcheck to require
21+
# the sourced file to give correct warnings about the checked file
22+
- run: shellcheck -x *.sh spec/*.sh kdumpctl mk*dumprd
23+
- run: shellcheck -x dracut/*/*.sh
24+
- run: shellcheck tests/*/*/*.sh
25+
26+
unit-tests:
27+
runs-on: ubuntu-latest
28+
container: docker.io/fedora:latest
29+
steps:
30+
- uses: actions/checkout@v4
31+
- run: sudo dnf install -y make dracut grubby hostname
32+
- run: curl -L -O https://github.com/shellspec/shellspec/archive/latest.tar.gz && tar -xzf latest.tar.gz
33+
- run: cd shellspec-latest && sudo make install
34+
- run: shellspec
35+
36+
integration-tests:
37+
runs-on: self-hosted
38+
timeout-minutes: 45
39+
concurrency:
40+
group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.fedora_version }}-${{ matrix.test }}
41+
cancel-in-progress: true
42+
strategy:
43+
matrix:
44+
fedora_version: [
45+
"40",
46+
]
47+
fail-fast: false
48+
steps:
49+
- name: "Checkout Repository"
50+
uses: actions/checkout@v4
51+
with:
52+
fetch-depth: 0
53+
- name: "${{ matrix.fedora_version }} kdump tests"
54+
run: tools/run-integration-tests.sh ${{ matrix.fedora_version }}

tools/run-integration-tests.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
2+
3+
set -ex
4+
5+
[[ -d ${0%/*} ]] && cd "${0%/*}"/../
6+
7+
fedora_version=${1:-40}
8+
9+
dist_abbr=.fc$fedora_version
10+
11+
VERSION=$(rpmspec -q --queryformat "%{VERSION}" kdump-utils.spec)
12+
SRC_ARCHIVE=kdump-utils-$VERSION.tar.gz
13+
if ! git archive --format=tar.gz -o "$SRC_ARCHIVE" --prefix="kdump-utils-$VERSION/" HEAD; then
14+
echo "Failed to create kdump-utils source archive"
15+
exit 1
16+
fi
17+
18+
if ! rpmbuild -ba -D "dist $dist_abbr" -D "_sourcedir $(pwd)" -D "_builddir $(pwd)" -D "_srcrpmdir $(pwd)" -D "_rpmdir $(pwd)" kdump-utils.spec; then
19+
echo "Failed to build kdump-utils rpm"
20+
exit 1
21+
fi
22+
23+
arch=$(uname -m)
24+
rpm_name=$(rpmspec -D "dist $dist_abbr" -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}' kdump-utils.spec)
25+
rpm_path="$(pwd)/${arch}/${rpm_name}.rpm"
26+
if [[ ! -f $rpm_path ]]; then
27+
echo "Failed to find built kdump-utils rpm ($rpm_path doesn't eixst)"
28+
fi
29+
30+
cd tests && tmt run --environment CUSTOM_MIRROR=https://mirrors.tuna.tsinghua.edu.cn/fedora --environment KDUMP_UTILS_RPM="$rpm_path" -a provision -h virtual -i fedora:"$fedora_version"

0 commit comments

Comments
 (0)