From 62b9751927788e975e9a01997e8db79a4e599b1a Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Fri, 4 Dec 2026 19:47:50 -0500 Subject: [PATCH 1/2] ci: lint PKGBUILDs in the shared workflow --- .github/workflows/__call-common-lint.yml | 42 ++++++++++++++++++++++++ CONTRIBUTING.md | 2 ++ 2 files changed, 44 insertions(+) diff --git a/.github/workflows/__call-common-lint.yml b/.github/workflows/__call-common-lint.yml index fe282b42..ccfb1ff2 100644 --- a/.github/workflows/__call-common-lint.yml +++ b/.github/workflows/__call-common-lint.yml @@ -668,6 +668,48 @@ jobs: echo "::remove-matcher owner=shellcheck-gcc::" exit ${error} + - name: PKGBUILD - find files + id: pkgbuild_files + if: always() + shell: bash + run: | + recipes=$(git ls-files -- ':(glob)**/PKGBUILD') + if [[ -n $recipes ]]; then + echo 'found=true' >> "$GITHUB_OUTPUT" + fi + + - name: PKGBUILD - ShellCheck + if: always() && steps.pkgbuild_files.outputs.found == 'true' + shell: bash + run: | + echo '::add-matcher::.github/matchers/shellcheck-gcc.json' + trap 'echo "::remove-matcher owner=shellcheck-gcc::"' EXIT + # makepkg consumes the recipe variables, supplies its own variables, and stops on command failures. + # Recipes also write literal substitutions into generated metadata such as pkg-config files. + git ls-files -z -- ':(glob)**/PKGBUILD' | + xargs -0 shellcheck --shell=bash --format=gcc --exclude=SC2016,SC2034,SC2154,SC2164 -- + + - name: PKGBUILD - namcap + if: always() && steps.pkgbuild_files.outputs.found == 'true' && runner.os == 'Linux' && runner.arch == 'X64' + shell: bash + run: | + image=$(docker build --quiet - <<'DOCKERFILE' + FROM archlinux:base + RUN pacman -Syu --noconfirm --needed namcap && pacman -Scc --noconfirm + DOCKERFILE + ) + + # namcap loads the recipe as Bash. Give it read-only sources and no network. + report=$(git ls-files -z -- ':(glob)**/PKGBUILD' | + docker run --rm -i --network=none --read-only --tmpfs /tmp \ + --cap-drop=ALL --security-opt=no-new-privileges --user 65534:65534 \ + --mount "type=bind,source=$GITHUB_WORKSPACE,target=/workspace,readonly" \ + --workdir /workspace "$image" xargs -0 namcap --) + printf '%s\n' "$report" + if grep -qE '^PKGBUILD( \([^)]*\))? E:' <<< "$report"; then + exit 1 + fi + - name: YAML - find files id: yaml_files if: always() diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1d56c2ea..1c9c8f16 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -146,12 +146,14 @@ of the repository. The following table shows the labels and the corresponding te | `docker` | hadolint | | `github-action`, `github-workflow` | actionlint | | `jupyter`, `python` | flake8 | +| `PKGBUILD` | shellcheck, namcap | | `PowerShell` | PSScriptAnalyzer | | `rust` | rustfmt | | `shell` | shellcheck | | `yaml` | yamllint | Projects may have additional checks, `eslint` for example, depending on the project's requirements. +The shared workflow runs namcap on x64 Linux runners. #### Unit Testing We strive to have comprehensive unit tests for our projects, but this is still a work in progress for some projects. From dac74191c02179cc05a0a9fc4322ab6594be9675 Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Fri, 4 Dec 2026 19:58:01 -0500 Subject: [PATCH 2/2] ci: enable SC2016 for PKGBUILDs --- .github/workflows/__call-common-lint.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/__call-common-lint.yml b/.github/workflows/__call-common-lint.yml index ccfb1ff2..5feb30eb 100644 --- a/.github/workflows/__call-common-lint.yml +++ b/.github/workflows/__call-common-lint.yml @@ -685,9 +685,8 @@ jobs: echo '::add-matcher::.github/matchers/shellcheck-gcc.json' trap 'echo "::remove-matcher owner=shellcheck-gcc::"' EXIT # makepkg consumes the recipe variables, supplies its own variables, and stops on command failures. - # Recipes also write literal substitutions into generated metadata such as pkg-config files. git ls-files -z -- ':(glob)**/PKGBUILD' | - xargs -0 shellcheck --shell=bash --format=gcc --exclude=SC2016,SC2034,SC2154,SC2164 -- + xargs -0 shellcheck --shell=bash --format=gcc --exclude=SC2034,SC2154,SC2164 -- - name: PKGBUILD - namcap if: always() && steps.pkgbuild_files.outputs.found == 'true' && runner.os == 'Linux' && runner.arch == 'X64'