-
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 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]>
- Loading branch information
Showing
2 changed files
with
84 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,54 @@ | ||
name: kdump-utils tests | ||
|
||
on: pull_request | ||
|
||
jobs: | ||
format-check: | ||
runs-on: ubuntu-latest | ||
container: docker.io/fedora:latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- run: dnf install shfmt -y | ||
- run: shfmt -s -d *.sh kdumpctl mk*dumprd tests/*/*/*.sh dracut/*/*.sh tools/*.sh | ||
|
||
static-analysis: | ||
runs-on: ubuntu-latest | ||
container: docker.io/fedora:latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- run: dnf install shellcheck -y | ||
# Currently, for kdump-utils, there is need for shellcheck to require | ||
# the sourced file to give correct warnings about the checked file | ||
- run: shellcheck -x *.sh spec/*.sh kdumpctl mk*dumprd | ||
- run: shellcheck -x dracut/*/*.sh | ||
- run: shellcheck -x tests/*/*/*.sh tools/*.sh | ||
|
||
unit-tests: | ||
runs-on: ubuntu-latest | ||
container: docker.io/fedora:latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- 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.fedora_version }}-${{ matrix.test }} | ||
cancel-in-progress: true | ||
strategy: | ||
matrix: | ||
fedora_version: [ | ||
"40", | ||
] | ||
fail-fast: false | ||
steps: | ||
- name: "Checkout Repository" | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: "${{ matrix.fedora_version }} kdump tests" | ||
run: tools/run-integration-tests.sh ${{ matrix.fedora_version }} |
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,30 @@ | ||
#!/bin/bash | ||
|
||
set -ex | ||
|
||
[[ -d ${0%/*} ]] && cd "${0%/*}"/../ | ||
|
||
fedora_version=${1:-40} | ||
|
||
dist_abbr=.fc$fedora_version | ||
|
||
VERSION=$(rpmspec -q --queryformat "%{VERSION}" kdump-utils.spec) | ||
SRC_ARCHIVE=kdump-utils-$VERSION.tar.gz | ||
if ! git archive --format=tar.gz -o "$SRC_ARCHIVE" --prefix="kdump-utils-$VERSION/" HEAD; then | ||
echo "Failed to create kdump-utils source archive" | ||
exit 1 | ||
fi | ||
|
||
if ! rpmbuild -ba -D "dist $dist_abbr" -D "_sourcedir $(pwd)" -D "_builddir $(pwd)" -D "_srcrpmdir $(pwd)" -D "_rpmdir $(pwd)" kdump-utils.spec; then | ||
echo "Failed to build kdump-utils rpm" | ||
exit 1 | ||
fi | ||
|
||
arch=$(uname -m) | ||
rpm_name=$(rpmspec -D "dist $dist_abbr" -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}' kdump-utils.spec) | ||
rpm_path="$(pwd)/${arch}/${rpm_name}.rpm" | ||
if [[ ! -f $rpm_path ]]; then | ||
echo "Failed to find built kdump-utils rpm ($rpm_path doesn't eixst)" | ||
fi | ||
|
||
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" |