Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: checks

on:
push:
pull_request:

jobs:
fedora-checks:
runs-on: ubuntu-latest
container:
image: fedora:43
steps:
- uses: actions/checkout@v4

- name: Install check dependencies
run: |
dnf install -y \
bash \
coreutils \
diffutils \
findutils \
grep \
sed \
util-linux \
which \
shellcheck

- name: Bash syntax checks
run: bash -n uki-setup.sh tests/test_uki_setup.sh

- name: ShellCheck
run: shellcheck -P . uki-setup.sh tests/test_uki_setup.sh

- name: Project checks
run: bash tests/test_uki_setup.sh
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,25 @@ Leave empty to auto-detect common Fedora paths.

---


## Continuous integration checks

GitHub Actions now runs checks in a Fedora container (`fedora:41`) on every push and pull request. The workflow verifies:

- Bash syntax for `uki-setup.sh` and test scripts.
- `shellcheck` linting.
- A project check script that sources `uki-setup.sh` with `UKI_SETUP_SKIP_MAIN=1` and validates the generated helper/plugin templates.

Run the same checks locally with:

```bash
bash -n uki-setup.sh tests/test_uki_setup.sh
shellcheck -P . uki-setup.sh tests/test_uki_setup.sh
bash tests/test_uki_setup.sh
```

---

## Files created by setup

Running `uki-setup.sh` creates/updates:
Expand Down
52 changes: 52 additions & 0 deletions tests/test_uki_setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/usr/bin/env bash
set -euo pipefail

REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$REPO_ROOT"

TMPDIR_WORK="$(mktemp -d)"
cleanup() {
rm -rf "$TMPDIR_WORK"
}
trap cleanup EXIT

export UKI_SETUP_SKIP_MAIN=1
# shellcheck source=uki-setup.sh
source "$REPO_ROOT/uki-setup.sh"

BUILD_SCRIPT="$TMPDIR_WORK/usr-local-sbin-uki-build.sh"
INSTALL_PLUGIN="$TMPDIR_WORK/usr-lib-kernel-install.d-90-uki-dracut.install"
BACKUP_ROOT="$TMPDIR_WORK/backups"
EFI_DIR="$TMPDIR_WORK/esp/EFI/Linux"
CMDLINE="root=UUID=test-uuid rw quiet"
AUTO_DETECT_CMDLINE=0
EFI_STUB="/usr/lib/systemd/boot/efi/linuxx64.efi.stub"

phase_write_build_script

[[ -x "$BUILD_SCRIPT" ]] || {
echo "Expected build script to be executable at $BUILD_SCRIPT"
exit 1
}

if grep -q '__EFI_DIR__\|__CMDLINE__\|__AUTO_DETECT_CMDLINE__\|__EFI_STUB__' "$BUILD_SCRIPT"; then
echo "Template placeholders were not fully substituted in build script"
exit 1
fi

grep -q "EFI_DIR=\"$EFI_DIR\"" "$BUILD_SCRIPT"
grep -q "CMDLINE=\"$CMDLINE\"" "$BUILD_SCRIPT"
grep -q 'AUTO_DETECT_CMDLINE=0' "$BUILD_SCRIPT"
grep -q "EFI_STUB=\"$EFI_STUB\"" "$BUILD_SCRIPT"

phase_write_plugin

[[ -x "$INSTALL_PLUGIN" ]] || {
echo "Expected install plugin to be executable at $INSTALL_PLUGIN"
exit 1
}

grep -q "BUILD_SCRIPT=\"$BUILD_SCRIPT\"" "$INSTALL_PLUGIN"
grep -Fq "UKI=\"${EFI_DIR}/linux-\${KERNEL_VER}.efi\"" "$INSTALL_PLUGIN"

echo "All local UKI setup checks passed."
18 changes: 10 additions & 8 deletions uki-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ phase_summary() {
echo " ${INSTALL_PLUGIN} ← auto-trigger on kernel installs"
echo ""
echo " UKIs are stored in: ${EFI_DIR}/"
ls -lh "${EFI_DIR}/"*.efi 2>/dev/null | sed 's/^/ /' || true
find "${EFI_DIR}" -maxdepth 1 -type f -name "*.efi" -exec ls -lh {} + 2>/dev/null | sed 's/^/ /' || true
echo ""
echo " Current UEFI boot entries:"
efibootmgr -v 2>/dev/null | grep -E 'BootOrder|Boot[0-9A-Fa-f]{4}' | sed 's/^/ /' || true
Expand All @@ -493,10 +493,12 @@ phase_summary() {
# Main
# =============================================================================

phase_preflight
phase_deps
phase_write_build_script
phase_write_plugin
phase_disable_bls_plugins
phase_initial_build
phase_summary
if [[ "${UKI_SETUP_SKIP_MAIN:-0}" -ne 1 ]]; then

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Handle skip-main flag without arithmetic evaluation

The new UKI_SETUP_SKIP_MAIN guard uses -ne, which triggers arithmetic evaluation under set -u; if a caller sets UKI_SETUP_SKIP_MAIN to a common string boolean like true/false, Bash treats that token as a variable name and exits with an unbound-variable error before any phase runs. This makes the script unexpectedly fail in automation environments that pass string-valued env flags instead of numeric 0/1.

Useful? React with 👍 / 👎.

phase_preflight
phase_deps
phase_write_build_script
phase_write_plugin
phase_disable_bls_plugins
phase_initial_build
phase_summary
fi
Loading