mirror of
https://github.com/tiennm99/HugoBlox-kit.git
synced 2026-10-16 00:14:29 +00:00
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:
1 parent
f5452a5491
commit
74ed4ecc15
2 files changed
+230
-184
No files matched your search
@@ -2,104 +2,252 @@ name: CI - Build Starters Matrix
|
|||||||
run-name: ${{ github.workflow }} - ${{ github.ref_name }}
|
run-name: ${{ github.workflow }} - ${{ github.ref_name }}
|
||||||
|
|
||||||
on:
|
on:
|
||||||
schedule:
|
schedule:
|
||||||
- cron: "0 2 * * *"
|
- cron: "0 2 * * *"
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
push:
|
push:
|
||||||
branches: [main]
|
branches: [main]
|
||||||
paths:
|
paths:
|
||||||
- "modules/**"
|
- "modules/**"
|
||||||
- "starters/**"
|
- "starters/**"
|
||||||
pull_request:
|
- "test/**"
|
||||||
paths:
|
- "scripts/**"
|
||||||
- "modules/**"
|
- "package.json"
|
||||||
- "starters/**"
|
- "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:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
|
|
||||||
concurrency:
|
concurrency:
|
||||||
group: starters-${{ github.ref }}
|
group: starters-${{ github.ref }}
|
||||||
cancel-in-progress: true
|
cancel-in-progress: true
|
||||||
|
|
||||||
env:
|
env:
|
||||||
NODE_VERSION: "22"
|
NODE_VERSION: "22"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-starters:
|
build-starters:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
starter:
|
starter:
|
||||||
- name: academic-cv
|
- name: academic-cv
|
||||||
path: starters/academic-cv
|
path: starters/academic-cv
|
||||||
- name: landing-page
|
- name: landing-page
|
||||||
path: starters/landing-page
|
path: starters/landing-page
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@v5
|
||||||
with:
|
with:
|
||||||
submodules: true
|
submodules: true
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Compute resources cache key
|
- name: Compute resources cache key
|
||||||
id: reskey
|
id: reskey
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
P=${{ matrix.starter.path }}
|
P=${{ matrix.starter.path }}
|
||||||
# Hash tracked files under assets/config and key files for invalidation
|
# 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)
|
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
|
if [ -z "$HASH" ]; then HASH="nohash"; fi
|
||||||
echo "key=${{ runner.os }}-hugo-resources-${{ matrix.starter.name }}-$HASH" >> $GITHUB_OUTPUT
|
echo "key=${{ runner.os }}-hugo-resources-${{ matrix.starter.name }}-$HASH" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Cache Hugo resources (starter)
|
- name: Cache Hugo resources (starter)
|
||||||
uses: actions/cache@v4
|
uses: actions/cache@v4
|
||||||
with:
|
with:
|
||||||
path: ${{ matrix.starter.path }}/resources/
|
path: ${{ matrix.starter.path }}/resources/
|
||||||
key: ${{ steps.reskey.outputs.key }}
|
key: ${{ steps.reskey.outputs.key }}
|
||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-hugo-resources-${{ matrix.starter.name }}-
|
${{ runner.os }}-hugo-resources-${{ matrix.starter.name }}-
|
||||||
|
|
||||||
|
- name: Enable Corepack (for pnpm cache)
|
||||||
|
run: corepack enable
|
||||||
|
|
||||||
- name: Enable Corepack (for pnpm cache)
|
- name: Setup Node.js
|
||||||
run: corepack enable
|
uses: actions/setup-node@v5
|
||||||
|
with:
|
||||||
|
node-version: "${{ env.NODE_VERSION }}"
|
||||||
|
cache: "pnpm"
|
||||||
|
|
||||||
- name: Setup Node.js
|
- name: Activate pnpm from root package.json
|
||||||
uses: actions/setup-node@v5
|
run: pnpm --version
|
||||||
with:
|
|
||||||
node-version: "${{ env.NODE_VERSION }}"
|
|
||||||
cache: "pnpm"
|
|
||||||
|
|
||||||
- name: Activate pnpm from root package.json
|
- name: Install starter dependencies
|
||||||
run: pnpm --version
|
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
|
- name: Read Hugo version from starter
|
||||||
working-directory: ${{ matrix.starter.path }}
|
id: hugo
|
||||||
# Don't use --frozen-lockfile as starters have auto-generated package.json with simple deps (Tailwind CLI)
|
run: |
|
||||||
# and may not have lock files checked into the repo
|
set -euo pipefail
|
||||||
run: pnpm install
|
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
|
- name: Setup Hugo
|
||||||
id: hugo
|
uses: peaceiris/actions-hugo@v3
|
||||||
run: |
|
with:
|
||||||
set -euo pipefail
|
hugo-version: "${{ steps.hugo.outputs.version }}"
|
||||||
P=${{ matrix.starter.path }}
|
extended: true
|
||||||
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
|
- name: Build ${{ matrix.starter.name }}
|
||||||
uses: peaceiris/actions-hugo@v3
|
working-directory: ${{ matrix.starter.path }}
|
||||||
with:
|
run: hugo --minify --panicOnWarning
|
||||||
hugo-version: "${{ steps.hugo.outputs.version }}"
|
|
||||||
extended: true
|
|
||||||
|
|
||||||
- name: Build ${{ matrix.starter.name }}
|
smoke-test-latest:
|
||||||
working-directory: ${{ matrix.starter.path }}
|
name: Test site on latest Hugo (allowed to fail)
|
||||||
run: hugo --minify --panicOnWarning
|
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
|
||||||
@@ -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
|
|
||||||
Reference in new issue
Block a user