refactor(ci): consolidate build workflows and add Hugo version guards

This commit overhauls the CI build process to improve robustness, prevent version drift, and provide better compatibility testing.

The `ci-build-test-site.yml` workflow has been removed and its responsibilities have been merged into the `ci-build-starters-matrix.yml` workflow. This consolidation provides a single source of truth for all build logic.

Three new jobs have been added to the matrix to act as version guards:

1.  **smoke-test-min:** Builds the `test/` site using the minimum Hugo version declared in the framework's `hugo.yaml`. This ensures we do not accidentally introduce features that break our minimum supported version.

2.  **smoke-test-latest:** Builds the `test/` site using the latest available Hugo version. This job is allowed to fail and acts as a canary to provide early warning of breaking changes in new Hugo releases.

3.  **canary-academic-latest:** Builds the `academic-cv` starter with the latest Hugo version. As one of our most popular starters, this provides a more realistic canary for issues that new users might encounter.
This commit is contained in:
George Cushen committed 2025-10-07 00:29:09 +01:00
1 parent f5452a5491
commit 74ed4ecc15
2 files changed
+230 -184

No files matched your search

+230 -82
View File
@@ -2,104 +2,252 @@ name: CI - Build Starters Matrix
run-name: ${{ github.workflow }} - ${{ github.ref_name }}
on:
schedule:
- cron: "0 2 * * *"
workflow_dispatch:
push:
branches: [main]
paths:
- "modules/**"
- "starters/**"
pull_request:
paths:
- "modules/**"
- "starters/**"
schedule:
- cron: "0 2 * * *"
workflow_dispatch:
push:
branches: [main]
paths:
- "modules/**"
- "starters/**"
- "test/**"
- "scripts/**"
- "package.json"
- "pnpm-lock.yaml"
- "biome.json"
- ".stylelintrc.yaml"
- "vite.config.js"
pull_request:
paths:
- "modules/**"
- "starters/**"
- "test/**"
- "scripts/**"
- "package.json"
- "pnpm-lock.yaml"
- "biome.json"
- ".stylelintrc.yaml"
- "vite.config.js"
permissions:
contents: read
contents: read
concurrency:
group: starters-${{ github.ref }}
cancel-in-progress: true
group: starters-${{ github.ref }}
cancel-in-progress: true
env:
NODE_VERSION: "22"
NODE_VERSION: "22"
jobs:
build-starters:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
starter:
- name: academic-cv
path: starters/academic-cv
- name: landing-page
path: starters/landing-page
build-starters:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
starter:
- name: academic-cv
path: starters/academic-cv
- name: landing-page
path: starters/landing-page
steps:
- name: Checkout
uses: actions/checkout@v5
with:
submodules: true
fetch-depth: 0
steps:
- name: Checkout
uses: actions/checkout@v5
with:
submodules: true
fetch-depth: 0
- name: Compute resources cache key
id: reskey
run: |
set -euo pipefail
P=${{ matrix.starter.path }}
# Hash tracked files under assets/config and key files for invalidation
HASH=$(git ls-files -s "$P/assets" "$P/config" "$P/hugoblox.yaml" "$P/package.json" 2>/dev/null | sha256sum | cut -d' ' -f1 || true)
if [ -z "$HASH" ]; then HASH="nohash"; fi
echo "key=${{ runner.os }}-hugo-resources-${{ matrix.starter.name }}-$HASH" >> $GITHUB_OUTPUT
- name: Compute resources cache key
id: reskey
run: |
set -euo pipefail
P=${{ matrix.starter.path }}
# Hash tracked files under assets/config and key files for invalidation
HASH=$(git ls-files -s "$P/assets" "$P/config" "$P/hugoblox.yaml" "$P/package.json" 2>/dev/null | sha256sum | cut -d' ' -f1 || true)
if [ -z "$HASH" ]; then HASH="nohash"; fi
echo "key=${{ runner.os }}-hugo-resources-${{ matrix.starter.name }}-$HASH" >> $GITHUB_OUTPUT
- name: Cache Hugo resources (starter)
uses: actions/cache@v4
with:
path: ${{ matrix.starter.path }}/resources/
key: ${{ steps.reskey.outputs.key }}
restore-keys: |
${{ runner.os }}-hugo-resources-${{ matrix.starter.name }}-
- name: Cache Hugo resources (starter)
uses: actions/cache@v4
with:
path: ${{ matrix.starter.path }}/resources/
key: ${{ steps.reskey.outputs.key }}
restore-keys: |
${{ runner.os }}-hugo-resources-${{ matrix.starter.name }}-
- name: Enable Corepack (for pnpm cache)
run: corepack enable
- name: Enable Corepack (for pnpm cache)
run: corepack enable
- name: Setup Node.js
uses: actions/setup-node@v5
with:
node-version: "${{ env.NODE_VERSION }}"
cache: "pnpm"
- name: Setup Node.js
uses: actions/setup-node@v5
with:
node-version: "${{ env.NODE_VERSION }}"
cache: "pnpm"
- name: Activate pnpm from root package.json
run: pnpm --version
- name: Activate pnpm from root package.json
run: pnpm --version
- name: Install starter dependencies
working-directory: ${{ matrix.starter.path }}
# Don't use --frozen-lockfile as starters have auto-generated package.json with simple deps (Tailwind CLI)
# and may not have lock files checked into the repo
run: pnpm install
- name: Install starter dependencies
working-directory: ${{ matrix.starter.path }}
# Don't use --frozen-lockfile as starters have auto-generated package.json with simple deps (Tailwind CLI)
# and may not have lock files checked into the repo
run: pnpm install
- name: Read Hugo version from starter
id: hugo
run: |
set -euo pipefail
P=${{ matrix.starter.path }}
VERSION=$(grep -E "^\s*hugo_version:\s*['\"]?" "$P/hugoblox.yaml" | sed -E "s/.*hugo_version:\s*['\"]?([^'\"]+)['\"]?.*/\1/")
if [ -z "$VERSION" ]; then
echo "::error::Could not read hugo_version from $P/hugoblox.yaml"
exit 1
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Read Hugo version from starter
id: hugo
run: |
set -euo pipefail
P=${{ matrix.starter.path }}
VERSION=$(grep -E "^\s*hugo_version:\s*['\"]?" "$P/hugoblox.yaml" | sed -E "s/.*hugo_version:\s*['\"]?([^'\"]+)['\"]?.*/\1/")
if [ -z "$VERSION" ]; then
echo "::error::Could not read hugo_version from $P/hugoblox.yaml"
exit 1
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Setup Hugo
uses: peaceiris/actions-hugo@v3
with:
hugo-version: "${{ steps.hugo.outputs.version }}"
extended: true
- name: Setup Hugo
uses: peaceiris/actions-hugo@v3
with:
hugo-version: "${{ steps.hugo.outputs.version }}"
extended: true
- name: Build ${{ matrix.starter.name }}
working-directory: ${{ matrix.starter.path }}
run: hugo --minify --panicOnWarning
- name: Build ${{ matrix.starter.name }}
working-directory: ${{ matrix.starter.path }}
run: hugo --minify --panicOnWarning
smoke-test-latest:
name: Test site on latest Hugo (allowed to fail)
runs-on: ubuntu-latest
continue-on-error: true
steps:
- name: Checkout
uses: actions/checkout@v5
with:
submodules: true
fetch-depth: 0
- name: Enable Corepack (for pnpm cache)
run: corepack enable
- name: Setup Node.js
uses: actions/setup-node@v5
with:
node-version: "${{ env.NODE_VERSION }}"
cache: "pnpm"
- name: Install test dependencies
working-directory: test
run: pnpm install --frozen-lockfile
- name: Cache Hugo resources (test)
uses: actions/cache@v4
with:
path: test/resources/
key: ${{ runner.os }}-hugo-resources-test-${{ hashFiles('test/assets/**/*', 'test/config.yaml', 'test/package.json') }}
restore-keys: |
${{ runner.os }}-hugo-resources-test-
- name: Setup Hugo (latest)
uses: peaceiris/actions-hugo@v3
with:
hugo-version: latest
extended: true
- name: Build test site (latest)
working-directory: test
run: hugo --minify --panicOnWarning --templateMetrics --templateMetricsHints
canary-academic-latest:
name: academic-cv on latest Hugo (allowed to fail)
runs-on: ubuntu-latest
continue-on-error: true
steps:
- name: Checkout
uses: actions/checkout@v5
with:
submodules: true
fetch-depth: 0
- name: Enable Corepack (for pnpm cache)
run: corepack enable
- name: Setup Node.js
uses: actions/setup-node@v5
with:
node-version: "${{ env.NODE_VERSION }}"
cache: "pnpm"
- name: Install starter dependencies
working-directory: starters/academic-cv
run: pnpm install
- name: Cache Hugo resources (starter)
uses: actions/cache@v4
with:
path: starters/academic-cv/resources/
key: ${{ runner.os }}-hugo-resources-academic-latest-${{ hashFiles('starters/academic-cv/assets/**/*', 'starters/academic-cv/config/**/*', 'starters/academic-cv/hugoblox.yaml', 'starters/academic-cv/package.json') }}
restore-keys: |
${{ runner.os }}-hugo-resources-academic-latest-
- name: Setup Hugo (latest)
uses: peaceiris/actions-hugo@v3
with:
hugo-version: latest
extended: true
- name: Build academic-cv (latest)
working-directory: starters/academic-cv
run: hugo --minify --panicOnWarning
smoke-test-min:
name: Test site on minimum supported Hugo
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v5
with:
submodules: true
fetch-depth: 0
- name: Enable Corepack (for pnpm cache)
run: corepack enable
- name: Setup Node.js
uses: actions/setup-node@v5
with:
node-version: "${{ env.NODE_VERSION }}"
cache: "pnpm"
- name: Install test dependencies
working-directory: test
run: pnpm install --frozen-lockfile
- name: Read minimum Hugo version from framework
id: min
run: |
set -euo pipefail
VERSION=$(grep -E "^[[:space:]]*min:[[:space:]]*['\"]?" modules/blox-tailwind/hugo.yaml | head -n1 | sed -E "s/.*min:[[:space:]]*['\"]?([^'\"#]+).*/\\1/")
if [ -z "$VERSION" ]; then
echo "::error::Could not read module.hugoVersion.min from modules/blox-tailwind/hugo.yaml"
exit 1
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Cache Hugo resources (test - min)
uses: actions/cache@v4
with:
path: test/resources/
key: ${{ runner.os }}-hugo-resources-test-min-${{ steps.min.outputs.version }}-${{ hashFiles('test/assets/**/*', 'test/config.yaml', 'test/package.json') }}
restore-keys: |
${{ runner.os }}-hugo-resources-test-min-
- name: Setup Hugo (min)
uses: peaceiris/actions-hugo@v3
with:
hugo-version: "${{ steps.min.outputs.version }}"
extended: true
- name: Build test site (min)
working-directory: test
run: hugo --minify --panicOnWarning --templateMetrics --templateMetricsHints
-102
View File
@@ -1,102 +0,0 @@
name: CI - Build Test Site
run-name: ${{ github.workflow }} - ${{ github.ref_name }}
on:
push:
branches: [main]
paths:
- "modules/**"
- "test/**"
- "scripts/**"
- "package.json"
- "pnpm-lock.yaml"
- "biome.json"
- ".stylelintrc.yaml"
- "vite.config.js"
pull_request:
branches: [main]
paths:
- "modules/**"
- "test/**"
- "scripts/**"
- "package.json"
- "pnpm-lock.yaml"
- "biome.json"
- ".stylelintrc.yaml"
- "vite.config.js"
permissions:
contents: read
concurrency:
group: build-${{ github.ref }}
cancel-in-progress: true
env:
NODE_VERSION: "22"
HUGO_VERSION: "0.150.0"
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
# node-version: [22.x]
steps:
- uses: actions/checkout@v5
with:
submodules: true # Fetch any Git submodules (true OR recursive)
fetch-depth: 0 # Fetch all history for .GitInfo and .Lastmod
- name: Validate Hugo version consistency
run: |
set -euo pipefail
EXPECTED=$(grep -E "^\s*hugo_version:\s*['\"]?" starters/academic-cv/hugoblox.yaml | sed -E "s/.*hugo_version:\s*['\"]?([^'\"]+)['\"]?.*/\1/")
echo "Expected Hugo from starter: $EXPECTED"
echo "Hugo in CI: $HUGO_VERSION"
if [ "$EXPECTED" != "$HUGO_VERSION" ]; then
echo "::error::HUGO_VERSION ($HUGO_VERSION) does not match starters/academic-cv/hugoblox.yaml ($EXPECTED). Update .github/workflows env or starter version."
exit 1
fi
- name: Enable Corepack (for pnpm cache)
run: corepack enable
- name: Setup Node.js
uses: actions/setup-node@v5
with:
node-version: "${{ env.NODE_VERSION }}"
cache: "pnpm"
- name: Activate pnpm from root package.json
run: pnpm --version
- name: Install root dependencies
run: pnpm install --frozen-lockfile
- name: Install Tailwind v4 dependencies for test site
run: |
cd test
pnpm install --frozen-lockfile
cd ..
- name: Cache Hugo resources (test)
uses: actions/cache@v4
with:
path: test/resources/
key: ${{ runner.os }}-hugo-resources-test-${{ hashFiles('test/assets/**/*', 'test/config/**/*', 'test/hugo.yaml', 'test/package.json') }}
restore-keys: |
${{ runner.os }}-hugo-resources-test-
- name: Setup Hugo
uses: peaceiris/actions-hugo@v3
with:
hugo-version: "${{ env.HUGO_VERSION }}"
extended: true
- name: Build
run: hugo --minify --panicOnWarning --templateMetrics --templateMetricsHints
working-directory: test