Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Github Action test #1

Open
wants to merge 21 commits into
base: rawhide
Choose a base branch
from
Open

Github Action test #1

wants to merge 21 commits into from

Conversation

coiby
Copy link
Owner

@coiby coiby commented Apr 15, 2022

No description provided.

@coiby coiby force-pushed the github_action_test branch from b07262b to 13a7017 Compare April 15, 2022 11:27
@coiby coiby force-pushed the github_action_test branch from 13a7017 to bc1db97 Compare April 15, 2022 11:29
@coiby coiby force-pushed the github_action_test branch from bc1db97 to 4c0c5d3 Compare April 15, 2022 11:32
@coiby coiby force-pushed the github_action_test branch 20 times, most recently from e9dacf0 to 3f142b4 Compare April 21, 2022 07:13
@coiby coiby force-pushed the github_action_test branch 2 times, most recently from 17b714a to 0a63a14 Compare June 28, 2022 04:01
@coiby coiby force-pushed the github_action_test branch from 6a51e21 to 895f101 Compare August 24, 2022 03:38
@coiby coiby changed the base branch from github_action to rawhide August 24, 2022 04:00
@coiby coiby changed the base branch from rawhide to github_action August 24, 2022 04:04
@coiby coiby changed the base branch from github_action to rawhide August 24, 2022 04:04
@coiby coiby force-pushed the github_action_test branch 2 times, most recently from 422992c to 6c01fd7 Compare August 24, 2022 04:07
@coiby coiby force-pushed the github_action_test branch from 6c01fd7 to 0a46f51 Compare November 16, 2022 14:12
coiby added 21 commits May 15, 2023 12:09
Signed-off-by: Coiby Xu <[email protected]>
As for EARLY_KDUMP_KERNELVER, it is no longer used so remove it.

Fixes: 8a476da ("earlykdump: generate symlink with stable name to kernel image and iniramfs")
Signed-off-by: Coiby Xu <[email protected]>
As detected by shellcheck,
  In dracut-fadump-init-fadump.sh line 18:
                  for FILE in $(ls -A /fadumproot/); do
                              ^-------------------^ SC2045: Iterating over ls output is fragile. Use globs.

  In dracut-fadump-init-fadump.sh line 19:
                        mv /fadumproot/$FILE /newroot/
                                       ^---^ SC2086: Double quote to prevent globbing and word splitting.

"ls -A" fails to address the case where a file name has spaces. Use
"find -exec mv" to fix SC2045 and SC2086 as well.

Signed-off-by: Coiby Xu <[email protected]>
uname initdir and etc. are from dracut. In these cases,  SC2154 warnings
are false positive for a dracut module.

Signed-off-by: Coiby Xu <[email protected]>
Quoting the rationale of SC2129,
> Rather than adding >> something after every single line, you can
> simply group the relevant commands and redirect the group. So the file
> has to be opened and closed only once and it means a performance gain.

Signed-off-by: Coiby Xu <[email protected]>
For the cases like passing ssh opts, we need to word-split ssh_opts
(renamed from rename _ssh_opt to improve readability). So they are false
 positives.  For other cases, quote them to avoid prevent globbing and
 word splitting.

Signed-off-by: Coiby Xu <[email protected]>
For those cases, we need to expand the variable so they are false
positives.

Signed-off-by: Coiby Xu <[email protected]>
DEFAULT_SSHKEY, and FENCE_KDUMP_SEND are used by whoever sources
kdump-lib-initramfs.sh and KDUMP_INITRD is used by kdumpctl. So they are
false positives.

FENCE_KDUMP_CONFIG_FILE is only used by kdumpctl and
dracut-module-setup.sh both of which source kdump-lib.sh so define
FENCE_KDUMP_CONFIG_FILE in kdump-lib.sh instead.

dracut_args is unused.

Signed-off-by: Coiby Xu <[email protected]>
Suppress SC2181 warning from kdump-lib.sh for the sake of readability.

For the other warning from kdump-migrate-action.sh, fix it following
shellcheck's advice,
  In kdump-migrate-action.sh line 4:
  if [ $? -ne 0 ]; then
       ^-- SC2181 (style): Check exit code directly with e.g. 'if ! mycmd;', not indirectly with $?.

Signed-off-by: Coiby Xu <[email protected]>
It's a known issue [1] that shellcheck fails to detect a variables
assigned and referenced in a trap.

[1] koalaman/shellcheck#1299

Signed-off-by: Coiby Xu <[email protected]>
Shellcheck finds
    In kdump-lib.sh line 249:
    	echo $(get_persistent_dev "$dev")
                 ^--------------------------^ SC2046: Quote this to prevent word splitting.
                 ^--------------------------^ SC2005: Useless echo? Instead of 'echo $(cmd)', just use 'cmd'.

Here echo is useless. By removing echo, we also get rid of SC2046.

Signed-off-by: Coiby Xu <[email protected]>
Shellcheck complains that

  In kdump-lib.sh line 528:
  	awk '                                                       \
                                                                      ^-- SC1004: This backslash+linefeed is literal. Break outside single quotes if you just want to break the line.
   ...

There is no need to use backslash+linefeed for awk and we can include
the linefeed  without a backlash.

Signed-off-by: Coiby Xu <[email protected]>
Fix the following shellcheck SC2295 warnings,
    In kdump-lib.sh line 177:
            _path=${1#$_mnt}
                      ^---^ SC2295 (info): Expansions inside ${..} need to be quoted separately, otherwise they match as patterns.

    Did you mean:
            _path=${1#"$_mnt"}

    In kdump-lib.sh line 194:
            _fsroot=${_src#${_src_nofsroot}[}
                           ^--------------^ SC2295 (info): Expansions inside ${..} need to be quoted separately, otherwise they match as patterns.

    Did you mean:
            _fsroot=${_src#"${_src_nofsroot}"[}

    In kdump-lib.sh line 203:
                    _fsroot=${_fsroot#$_subvol}
                                      ^------^ SC2295 (info): Expansions inside ${..} need to be quoted separately, otherwise they match as patterns.

    Did you mean:
                _fsroot=${_fsroot#"$_subvol"}

Signed-off-by: Coiby Xu <[email protected]>
KDUMP_*LOGLVL are defined in /etc/kdump/sysconfig. They are accessible
to kdump-logger.sh because scripts like kdumpcl will first source
/etc/kdump/sysconfig and then source kdump-logger.sh.

Signed-off-by: Coiby Xu <[email protected]>
Fix two POSIX issues detected by shellcheck,
    In kdump-logger.sh line 122:
    	if [ "$UID" -ne 0 ]; then
                  ^--^ SC3028 (warning): In POSIX sh, UID is undefined.

    In kdump-logger.sh line 135:
    			exec 15> "$_systemdcatfile"
                                 ^--------------------^ SC3023 (warning): In POSIX sh, FDs outside 0-9 are undefined.

Signed-off-by: Coiby Xu <[email protected]>
    In kdump-lib.sh line 855:
    		IFS=, read start start_unit end end_unit size <<< \
                          ^--^ SC2162 (info): read without -r will mangle backslashes.

    In kdump-lib.sh line 877:
    kdump_get_arch_recommend_crashkernel()
    ^-- SC2120 (warning): kdump_get_arch_recommend_crashkernel references arguments, but none are ever passed.

    In kdump-lib.sh line 920:
    	_ck_cmdline=$(kdump_get_arch_recommend_crashkernel)
                          ^-- SC2119 (info): Use kdump_get_arch_recommend_crashkernel "$@" if function's $1 should mean script's $1.

Signed-off-by: Coiby Xu <[email protected]>
shellcheck complains that,
    In spec/kdumpctl_general_spec.sh line 100:
    			'' failure
                            ^-- SC2286 (error): This empty string is interpreted as a command name. Double check syntax (or use 'true' as a no-op).

Eliminate this warning by disabling SC2286 file-wide as is the same with
the many shellspec files e.g.
https://github.com/shellspec/shellspec/blob/b8935ec266d2c5f7f364c6024730e4d68432cce3/spec/core/modifiers/length_spec.sh

Signed-off-by: Coiby Xu <[email protected]>
Currently tests depends on the kernel nbd module to the test image. But
the nbd module may not exist (e.g. Gitlab CI's shared runner doesn't
provide it) or we simply don't have the root permission to use /dev/nbd
(e.g. in a rootless container) for security concerns. To address these
limitations, use libguestfs's guestmount/guestunmount to mount/unmount
when USE_GUESTMOUNT=1. Another benefit of guestmount is it can handle
the case where a qemu image has multiple partitions automatically.

Note
1. guestmount doesn't need root permission but dnf currently mandates
   sudo. So still use sudo to call guestmount to simply make dnf happy.
   pkcon doesn't require sudo but unfornately it doesn't support
   --installroot.

2. guestunmount is similar to an async command, so we need to implement
   our own logic to wait for unmounting to be truly finished.

Signed-off-by: Coiby Xu <[email protected]>
Currently, a VM is allowed to run at hard-coded 10mins at maximum. In
cases where the tests are running inside Github or Gitlab's CI testing
machines, it takes much longer time. Make it configurable by the
KUMP_TEST_QEMU_TIMEOUT environment variable.

Signed-off-by: Coiby Xu <[email protected]>
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-36-1.5.x86_64.qcow2 to avoid
repeatedly downloading the Fedora 36 cloud base image each time the
tests are triggered.

Signed-off-by: Coiby Xu <[email protected]>
@coiby coiby force-pushed the github_action_test branch from 0a46f51 to b6cc9de Compare May 15, 2023 04:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant