Skip to content
Open
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
35 changes: 16 additions & 19 deletions .github/workflows/frontend-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,9 @@ jobs:
node-version: ${{ inputs.node_version }}

# The E2E shards serve the site with StaticHost, as production does,
# from the build output this job uploads (statichost-bin). Its restore
# and compile need no site, so they run alongside the Astro build.
# from the build output this job uploads (statichost-bin). StaticHost
# reads the site from its web root per request, so its build needs no
# site and runs alongside the Astro build.
- uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0
with:
global-json-file: global.json
Expand Down Expand Up @@ -138,16 +139,6 @@ jobs:
bun run build:production
fi

# StaticHost serves its wwwroot, which holds a copy of dist (hard links)
# as in production. MapStaticAssets lists every file of the web root:
# this incremental build redoes only that, while the site archive is packed
# and uploaded.
- name: Start the StaticHost build
run: |
cp -alf dist/. ../statichost/StaticHost/wwwroot/
"$SETUP" wait statichost-compile
"$SETUP" start statichost-build dotnet build -c Release --no-restore ../statichost/StaticHost

- name: Save Astro build state
if: ${{ success() && (github.event_name == 'push' || steps.astro_cache.outputs.cache-matched-key == '') }}
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
Expand Down Expand Up @@ -226,7 +217,7 @@ jobs:

- name: Wait for the StaticHost build
run: |
"$SETUP" wait statichost-build
"$SETUP" wait statichost-compile
"$SETUP" report

- name: Upload the StaticHost build
Expand Down Expand Up @@ -457,17 +448,17 @@ jobs:
"$SETUP" start playwright-deps bun run playwright install-deps chromium
"$SETUP" start playwright-browsers bun run playwright install chromium

# The Frontend Build job built StaticHost against this run's dist.
# StaticHost reads the web root's files per request, so it starts
# before the site is there, and boots during its download.
# The Frontend Build job built StaticHost. It reads the web root's files
# per request, so it starts before the site is there, and boots during
# its download.
- name: Download the StaticHost build
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: statichost-bin
path: src/statichost/StaticHost/bin/Release/net10.0

# Any answer, a 404 included, means StaticHost built its routing table,
# which the first request does.
# Any answer, a 404 included, means StaticHost is up and has built its
# routing table, which the first request does.
- name: Start StaticHost
run: |
mkdir -p ../statichost/StaticHost/wwwroot
Expand All @@ -480,10 +471,16 @@ jobs:
name: frontend-site
path: ${{ runner.temp }}

# StaticHost treats the locale manifest as the sign that the web root is
# complete and stops re-indexing it, so the manifest lands last.
- name: Unpack site archive
run: |
set -euo pipefail
zstd -d -T0 -q -c "$RUNNER_TEMP/site.tar.zst" | tar -C ../statichost/StaticHost/wwwroot -xf -
wwwroot=../statichost/StaticHost/wwwroot
manifest="$wwwroot/locale-fallback/locales.json"
zstd -d -T0 -q -c "$RUNNER_TEMP/site.tar.zst" \
| tar -C "$wwwroot" -xf - --transform='s,^\./locale-fallback/locales\.json$,./locale-fallback/locales.json.pending,'
mv "$manifest.pending" "$manifest"
rm -f "$RUNNER_TEMP/site.tar.zst"

- name: Wait for StaticHost
Expand Down
15 changes: 9 additions & 6 deletions src/frontend/astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import { unified } from '@astrojs/markdown-remark';
import { sidebarTopics } from './config/sidebar/sidebar.topics.ts';
import { redirects } from './config/redirects.mjs';
import { locales } from './config/locales.ts';
import { getTranslatedPaths } from './config/translated-paths.mjs';
import { localeFallbackDevIntegration } from './config/locale-fallback-dev-integration.mjs';
import { isExcludedFromLinkValidation } from './config/links-validator-exclude.mjs';
import { headAttrs } from './config/head.attrs.ts';
import { socialConfig } from './config/socials.config.ts';
import { aspireProject } from './src/data/aspire-project.ts';
Expand Down Expand Up @@ -65,6 +68,7 @@ const prerenderWorkers = Number(process.env.ASPIRE_PRERENDER_WORKERS) || 4;
// https://astro.build/config
export default defineConfig({
cacheDir: './node_modules/.astro',
scopedStyleStrategy: 'where',
...(outDir ? { outDir } : {}),
vite: {
plugins: [starlightIconSprite()],
Expand All @@ -79,6 +83,9 @@ export default defineConfig({
define: {
// Resolve filesystem-backed redirects before prerender modules are bundled.
__ASPIRE_REDIRECT_PATHS__: JSON.stringify(Object.keys(redirects)),
// Untranslated locale routes aren't built (see the Starlight patch), so
// hreflang alternates only list localized routes that really exist.
__ASPIRE_TRANSLATED_PATHS__: JSON.stringify(getTranslatedPaths()),
},
...(staticHostUrl
? {
Expand Down Expand Up @@ -157,7 +164,6 @@ export default defineConfig({
}),
lunaria({
route: '/i18n',
sync: false,
}),
catppuccin(),
starlightSidebarTopics(sidebarTopics, {
Expand All @@ -173,11 +179,7 @@ export default defineConfig({
starlightLinksValidator({
errorOnRelativeLinks: false,
errorOnFallbackPages: false,
exclude: [
'/i18n/', '/reference/api', '/reference/api/**',
// Custom Astro destinations checked by the Dev Hub browser tests.
'/hub/', '/hub/glossary/ats/', '/get-started/glossary/#polyglot',
],
exclude: ({ link }) => isExcludedFromLinkValidation(link),
}),
starlightGitHubAlerts(),
starlightLlmsTxt({
Expand Down Expand Up @@ -256,6 +258,7 @@ export default defineConfig({
}),
...(isBuildTimingEnabled ? [buildTiming()] : []),
aspireVersionPlaceholdersIntegration(),
localeFallbackDevIntegration(),
],
build: {
concurrency: buildConcurrency,
Expand Down
Loading
Loading