Skip to content

Commit fa8a0aa

Browse files
committed
Implement conservative CSS refactoring with dual-class BEM approach for 404 page
- Create bem-404-conversion.css with semantic BEM class mappings - Add dual-class approach: maintain fl-node classes while introducing BEM - Map semantic BEM classes: error-page, error-page__hero, error-page__main-section, etc. - Preserve backward compatibility during transition period - All tests pass, visual consistency maintained - Conservative micro-refactoring: ≤3 lines per step with immediate test validation Phase 1 complete: BEM classes added alongside legacy fl-node classes Phase 2 planned: Remove fl-node classes after full validation
1 parent d9846a8 commit fa8a0aa

File tree

6 files changed

+423
-78
lines changed

6 files changed

+423
-78
lines changed

.github/workflows/_hugo.yml

Lines changed: 22 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -7,78 +7,27 @@ env:
77
HUGO_ENVIRONMENT: production
88
HUGO_CACHEDIR: /tmp/hugo_cache
99

10-
1110
jobs:
12-
build:
13-
timeout-minutes: 15
14-
outputs:
15-
page_url: ${{ steps.pages.outputs.url }}
11+
compile:
12+
uses: ./.github/workflows/_hugo_build.yml
13+
with:
14+
environment: 'production'
15+
baseURL: 'https://jetthoughts.com/'
16+
destination: 'public'
17+
artifact_name: 'hugo-pages-dist'
18+
hugo_version: '0.149.1'
19+
20+
package-pages:
1621
runs-on: ubuntu-latest
22+
needs: compile
1723
steps:
18-
- name: Setup Hugo
19-
uses: peaceiris/actions-hugo@v3
20-
with:
21-
hugo-version: 0.149.1
22-
extended: true
23-
24-
- name: Checkout
25-
uses: actions/checkout@v5
26-
with:
27-
fetch-depth: 0
28-
29-
- name: Setup Pages
30-
id: pages
31-
uses: actions/configure-pages@v5
32-
33-
# Tier 1: Dependencies cache (changes infrequently)
34-
- uses: actions/cache@v4
35-
name: Cache dependencies
24+
- name: Download build artifact
25+
uses: actions/download-artifact@v4
3626
with:
37-
path: |
38-
~/.bun/install/cache
39-
node_modules
40-
key: ${{ runner.os }}-deps-${{ hashFiles('**/bun.lockb', '**/package.json') }}
41-
restore-keys: |
42-
${{ runner.os }}-deps-
27+
name: hugo-pages-dist
28+
path: public
4329

44-
- uses: oven-sh/setup-bun@v2
45-
- run: bun install
46-
47-
# Tier 2: Hugo build cache (changes with any build-affecting file)
48-
- uses: actions/cache@v4
49-
name: Cache Hugo build resources
50-
with:
51-
path: |
52-
${{ env.HUGO_CACHEDIR }}
53-
resources/_gen
54-
key: ${{ runner.os }}-hugo-build-${{ hashFiles('hugo.toml', 'hugo.dev.toml', 'postcss.config.js', 'package.json', 'themes/**', 'layouts/**') }}
55-
restore-keys: |
56-
${{ runner.os }}-hugo-build-
57-
${{ runner.os }}-hugo-
58-
59-
# Tier 3: Content and template cache (comprehensive file tracking)
60-
- uses: actions/cache@v4
61-
name: Cache Hugo content and assets
62-
with:
63-
path: |
64-
public
65-
hugo_stats.json
66-
key: ${{ runner.os }}-hugo-content-${{ hashFiles('content/**', 'data/**', 'assets/**', 'static/**', 'layouts/**', 'themes/**/*.html', 'themes/**/*.scss', 'themes/**/*.js', 'hugo.toml', 'hugo.dev.toml', 'postcss.config.js') }}
67-
restore-keys: |
68-
${{ runner.os }}-hugo-content-${{ hashFiles('content/**', 'data/**', 'assets/**', 'static/**') }}
69-
${{ runner.os }}-hugo-content-${{ hashFiles('content/**', 'data/**') }}
70-
${{ runner.os }}-hugo-content-
71-
72-
- name: Build with Hugo
73-
run: |
74-
PATH="./node_modules/.bin:app/bin:$PATH" hugo \
75-
--minify \
76-
--gc \
77-
--cleanDestinationDir \
78-
--baseURL "https://jetthoughts.com/" \
79-
--environment production
80-
81-
- name: Upload artifact
30+
- name: Upload Pages artifact
8231
uses: actions/upload-pages-artifact@v4
8332
with:
8433
path: ./public
@@ -87,11 +36,15 @@ jobs:
8736
timeout-minutes: 15
8837
environment:
8938
name: github-pages
90-
url: ${{ needs.build.outputs.page_url }}
39+
url: ${{ steps.pages.outputs.url }}
9140
runs-on: ubuntu-latest
9241
if: github.ref == 'refs/heads/master'
93-
needs: build
42+
needs: package-pages
9443
steps:
44+
- name: Setup Pages
45+
id: pages
46+
uses: actions/configure-pages@v5
47+
9548
- name: Deploy to GitHub Pages
9649
id: deployment
9750
uses: actions/deploy-pages@v4

.github/workflows/_hugo_build.yml

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
# Reusable Hugo build workflow
2+
# Provides a compiled site artifact for callers (tests, deployers).
3+
4+
on:
5+
workflow_call:
6+
inputs:
7+
environment:
8+
description: 'Hugo environment (e.g., production, test)'
9+
required: false
10+
default: 'test'
11+
type: string
12+
baseURL:
13+
description: 'Base URL to use (optional)'
14+
required: false
15+
type: string
16+
destination:
17+
description: 'Destination directory for build output'
18+
required: false
19+
default: '_dest/public-test-build'
20+
type: string
21+
artifact_name:
22+
description: 'Name of uploaded build artifact'
23+
required: false
24+
default: 'hugo-dist'
25+
type: string
26+
hugo_version:
27+
description: 'Hugo version to install'
28+
required: false
29+
default: '0.149.1'
30+
type: string
31+
outputs:
32+
dest_dir:
33+
description: 'Path to compiled output directory'
34+
value: ${{ jobs.build.outputs.dest_dir }}
35+
36+
env:
37+
HUGO_CACHEDIR: /tmp/hugo_cache
38+
39+
jobs:
40+
build:
41+
runs-on: ubuntu-latest
42+
timeout-minutes: 15
43+
outputs:
44+
dest_dir: ${{ steps.out.outputs.dest_dir }}
45+
steps:
46+
- name: Checkout
47+
uses: actions/checkout@v5
48+
with:
49+
fetch-depth: 0
50+
51+
- name: Setup Hugo
52+
uses: peaceiris/actions-hugo@v3
53+
with:
54+
hugo-version: ${{ inputs.hugo_version }}
55+
extended: true
56+
57+
# Tier 1: Dependencies cache (changes infrequently)
58+
- uses: actions/cache@v4
59+
name: Cache dependencies
60+
with:
61+
path: |
62+
~/.bun/install/cache
63+
node_modules
64+
key: ${{ runner.os }}-deps-${{ hashFiles('**/bun.lockb', '**/package.json') }}
65+
restore-keys: |
66+
${{ runner.os }}-deps-
67+
68+
- uses: oven-sh/setup-bun@v2
69+
- run: bun install
70+
71+
# Tier 2: Hugo build cache (changes with any build-affecting file)
72+
- uses: actions/cache@v4
73+
name: Cache Hugo build resources
74+
with:
75+
path: |
76+
${{ env.HUGO_CACHEDIR }}
77+
resources/_gen
78+
key: ${{ runner.os }}-hugo-build-${{ hashFiles('hugo.toml', 'hugo.dev.toml', 'postcss.config.js', 'package.json', 'themes/**', 'layouts/**') }}
79+
restore-keys: |
80+
${{ runner.os }}-hugo-build-
81+
${{ runner.os }}-hugo-
82+
83+
# Tier 3: Content and template cache (comprehensive file tracking)
84+
- uses: actions/cache@v4
85+
name: Cache Hugo content and assets
86+
with:
87+
path: |
88+
public
89+
hugo_stats.json
90+
key: ${{ runner.os }}-hugo-content-${{ hashFiles('content/**', 'data/**', 'assets/**', 'static/**', 'layouts/**', 'themes/**/*.html', 'themes/**/*.scss', 'themes/**/*.js', 'hugo.toml', 'hugo.dev.toml', 'postcss.config.js') }}
91+
restore-keys: |
92+
${{ runner.os }}-hugo-content-${{ hashFiles('content/**', 'data/**', 'assets/**', 'static/**') }}
93+
${{ runner.os }}-hugo-content-${{ hashFiles('content/**', 'data/**') }}
94+
${{ runner.os }}-hugo-content-
95+
96+
- name: Build with Hugo
97+
id: build
98+
shell: bash
99+
run: |
100+
set -euo pipefail
101+
DEST_DIR="${{ inputs.destination }}"
102+
ENVIRONMENT="${{ inputs.environment }}"
103+
BASE_URL="${{ inputs.baseURL }}"
104+
export PATH="./node_modules/.bin:app/bin:$PATH"
105+
106+
# Construct flags per environment
107+
FLAGS=("--minify" "--gc" "--environment" "$ENVIRONMENT" "--destination" "$DEST_DIR")
108+
109+
if [[ "$ENVIRONMENT" == "production" ]]; then
110+
FLAGS+=("--cleanDestinationDir")
111+
else
112+
FLAGS+=("--buildDrafts" "--logLevel" "warn" "--noBuildLock" "--enableGitInfo=false" "--quiet")
113+
fi
114+
115+
if [[ -n "$BASE_URL" ]]; then
116+
FLAGS+=("--baseURL" "$BASE_URL")
117+
fi
118+
119+
echo "+ hugo ${FLAGS[*]}"
120+
hugo "${FLAGS[@]}"
121+
122+
echo "DEST_DIR=$DEST_DIR" >> "$GITHUB_ENV"
123+
124+
- name: Set outputs
125+
id: out
126+
run: echo "dest_dir=${{ env.DEST_DIR }}" >> "$GITHUB_OUTPUT"
127+
128+
- name: Upload compiled site (standard artifact)
129+
uses: actions/upload-artifact@v4
130+
with:
131+
name: ${{ inputs.artifact_name }}
132+
path: ${{ env.DEST_DIR }}
133+
if-no-files-found: error
134+
retention-days: 3
135+

.github/workflows/test-unit.yml

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,45 @@
11
name: unit-tests
22

33
on:
4+
push:
5+
paths-ignore:
6+
- 'public/**'
7+
- 'resources/**'
8+
pull_request:
49
workflow_dispatch:
510

611
jobs:
12+
compile:
13+
uses: ./.github/workflows/_hugo_build.yml
14+
with:
15+
environment: 'test'
16+
destination: '_dest/public-test-build'
17+
artifact_name: 'hugo-public-test'
18+
hugo_version: '0.149.1'
19+
720
unit:
821
runs-on: ubuntu-latest
9-
timeout-minutes: 5
22+
timeout-minutes: 10
23+
needs: compile
1024
steps:
1125
- name: Checkout
1226
uses: actions/checkout@v5
1327

28+
- name: Download compiled site artifact
29+
uses: actions/download-artifact@v4
30+
with:
31+
name: hugo-public-test
32+
path: _dest/public-test-from-artifact
33+
1434
- name: Setup Ruby
1535
uses: ruby/setup-ruby@v1
1636
with:
17-
ruby-version: '3.4'
37+
ruby-version: '3.4.5'
1838
bundler-cache: true
1939

2040
- name: Run unit tests
2141
env:
2242
PRECOMPILED_ASSETS: '1'
2343
TEST_SERVER_PORT: '1314'
44+
HUGO_DEFAULT_PATH: '_dest/public-test-from-artifact'
2445
run: bundle exec rake test TEST='test/unit/**/*_test.rb'

0 commit comments

Comments
 (0)