Files
wolfssl/.github/workflows/check-source-text.yml
T
Juliusz Sosinowicz dd2f9d3ab8 CI: offload ccache/apt/buildx caches off the GitHub Actions cache
The 10 GB, LRU-evicted, PR-scoped Actions cache was being thrashed - the
docker simulator buildx layers (~6 GiB), plus per-PR ccache and apt-archive
writes whose keys never hit - which kept evicting the shared ccache, while
the apt mirror timed out often enough to break PR CI. Move the heavy caches
to ghcr (free, separate pool) and make PR runs read-only against the Actions
cache.

apt dependencies from prebuilt ghcr .deb bundles
  - ci-deps-image.yml resolves each package list under .github/ci-deps/ into
    its .deb closure and publishes ghcr.io/<owner>/wolfssl-ci-debs:<tag> in
    two tiers: <ver>-minimal (make-check family) and <ver>-full (interop
    superset), for ubuntu-22.04 and 24.04.
  - install-apt-deps gains a ghcr-debs-tag input: pull the bundle and install
    offline (--no-download) so the apt mirror is never on the PR critical
    path. Any failure (bundle missing/not public/incomplete) falls through to
    the existing apt path, so it is always safe to set.

sim-test buildx layers to a shared ghcr registry cache
  - the 7 docker simulator workflows switch from cache-to: type=gha to
    ghcr.io/wolfssl/wolfssl-sim-cache:<scope>. cache-from reads on every run
    (anonymous); cache-to writes only on the weekend cron and manual
    workflow_dispatch. Per-distinct-image tags and de-duplicated writers keep
    parallel matrix jobs from racing on one ref.

ccache: PRs read, the schedule writes
  - ccache-setup gains read-only: PR runs restore the shared master-scoped
    cache but never upload; schedule/push runs refresh it. Wired across
    os-check (linux + macOS), pq-all, smoke-test and the 12 small make-check
    workflows.
  - parallel-make-check.py gains --build-only (compile every config, skip the
    test phase) so weekday-morning seed crons warm the cache PR runs consume.

artifact retention capped at 7 days on the failure-log/result uploads that
previously defaulted to 90.

ONE-TIME SETUP: after their first publish, make the ghcr packages
wolfssl-ci-debs and wolfssl-sim-cache PUBLIC so anonymous pulls work from PR
(including fork) runs; until then everything falls back cleanly.
2026-06-15 22:36:35 +00:00

111 lines
3.8 KiB
YAML

name: Check Source Text
# Source-hygiene + shell-script lint. Runs on drafts too - fast feedback.
#
# Checks:
# * check-source-text.sh: trailing whitespace, hard tabs in C/H, CRLF,
# BOM / non-ASCII.
# * bash -n + shellcheck (warning level) on shell scripts.
#
# Scope:
# * pull_request: only files changed in the PR (catches new violations
# without failing on historical debt).
# * push: scan the full tree (baseline guard on master).
on:
push:
branches: [ master, main ]
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
branches: [ master, main ]
concurrency:
group: check-source-text-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
check:
# Only run from the wolfssl org to avoid burning forks' CI minutes.
if: github.repository_owner == 'wolfssl'
runs-on: ubuntu-24.04
timeout-minutes: 5
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Install shellcheck
uses: ./.github/actions/install-apt-deps
with:
packages: shellcheck
ghcr-debs-tag: ubuntu-24.04-full
- name: Collect files to check
id: files
run: |
if [ "${{ github.event_name }}" = "pull_request" ]; then
BASE_SHA="${{ github.event.pull_request.base.sha }}"
HEAD_SHA="${{ github.event.pull_request.head.sha }}"
git diff --name-only --diff-filter=ACMR "$BASE_SHA" "$HEAD_SHA" \
> changed.txt || true
grep -E '\.sh$' changed.txt > changed-sh.txt || true
echo "Files changed in PR:"
cat changed.txt
echo "Shell scripts changed:"
cat changed-sh.txt
echo "count=$(wc -l < changed.txt)" >> "$GITHUB_OUTPUT"
echo "sh_count=$(wc -l < changed-sh.txt)" >> "$GITHUB_OUTPUT"
else
: > changed.txt
git ls-files '*.sh' > changed-sh.txt
echo "count=0" >> "$GITHUB_OUTPUT"
echo "sh_count=$(wc -l < changed-sh.txt)" >> "$GITHUB_OUTPUT"
fi
- name: Run check-source-text (PR changed files)
if: github.event_name == 'pull_request' && steps.files.outputs.count != '0'
run: |
# shellcheck disable=SC2046
./.github/scripts/check-source-text.sh $(cat changed.txt)
- name: Run check-source-text (full tree)
if: github.event_name != 'pull_request'
run: ./.github/scripts/check-source-text.sh
- name: bash -n (syntax check)
if: steps.files.outputs.sh_count != '0'
run: |
fail=0
while IFS= read -r f; do
[ -f "$f" ] || continue
if ! bash -n "$f"; then
echo "::error file=$f::bash -n syntax error"
fail=1
fi
done < changed-sh.txt
exit "$fail"
- name: shellcheck (warning level)
if: steps.files.outputs.sh_count != '0'
run: |
# Mirrors the internal multi-test check-shell-scripts subtest:
# --severity=warning
# -e SC2226,SC2166,SC2164,SC2046,SC2034,SC2188,SC2043
# SC2226 (no ln destination), SC2166 ([ p -a q ]), SC2164 (cd ||),
# SC2046 (word splitting), SC2034 (unused var), SC2188 (redirect
# w/o command), SC2043 (loop runs once) - common in this codebase,
# suppressed in the internal multi-test for the same reason.
fail=0
while IFS= read -r f; do
[ -f "$f" ] || continue
if ! shellcheck --severity=warning \
--exclude=SC2226,SC2166,SC2164,SC2046,SC2034,SC2188,SC2043 \
--format=gcc "$f"; then
fail=1
fi
done < changed-sh.txt
exit "$fail"