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
41 changes: 41 additions & 0 deletions .github/workflows/__call-common-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,47 @@ 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.
git ls-files -z -- ':(glob)**/PKGBUILD' |
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'
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()
Expand Down
2 changes: 2 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading