Skip to content
Merged
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
34 changes: 34 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Set up pnpm and Node.js
description: Install pnpm and Node.js (.node-version) and the dependencies from the lockfile.

inputs:
install-scripts:
# Jobs that hold deployment credentials leave this off, so no install
# script ever runs next to a token.
description: '"true" runs the install scripts of dependencies; "false" passes --ignore-scripts.'
required: false
default: "false"

runs:
using: composite
steps:
- uses: pnpm/action-setup@0977fd99725f1db4007ccb2928dbb4e90d06cc86 # v6

- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7
with:
node-version-file: .node-version
cache: pnpm

- name: Install dependencies
shell: bash
run: |
case "$INSTALL_SCRIPTS" in
Comment thread
kryota-dev marked this conversation as resolved.
Resolved
true) pnpm install --frozen-lockfile ;;
false) pnpm install --frozen-lockfile --ignore-scripts ;;
*)
echo "install-scripts must be \"true\" or \"false\": $INSTALL_SCRIPTS" >&2
exit 1
;;
esac
env:
INSTALL_SCRIPTS: ${{ inputs.install-scripts }}
83 changes: 38 additions & 45 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,33 +24,21 @@ jobs:
with:
persist-credentials: false

- uses: pnpm/action-setup@0977fd99725f1db4007ccb2928dbb4e90d06cc86 # v6

- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7
- uses: ./.github/actions/setup
with:
node-version-file: .node-version
cache: pnpm

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Lint (ESLint, Stylelint)
run: pnpm lint

- name: Format check (Prettier)
run: pnpm format:check

- name: Type check (astro check)
run: pnpm check

- name: Build
run: pnpm build
install-scripts: "true"

- name: HTML validation (html-validate)
run: pnpm test:html
# The installs below run in the background while the checks and the
# build run; their PATH changes take effect only after a wait step.
- id: playwright
name: Install Playwright browser
background: true
run: pnpm exec playwright install --with-deps chromium

# Pinned by version and checksum. The tests below use it as well.
- name: Install lychee
- id: lychee
name: Install lychee
background: true
run: |
archive="lychee-x86_64-unknown-linux-gnu"
curl --proto "=https" --tlsv1.2 -fsSLo "${RUNNER_TEMP}/lychee.tar.gz" \
Expand All @@ -64,15 +52,36 @@ jobs:
LYCHEE_VERSION: 0.24.2
LYCHEE_SHA256: 1f4e0ef7f6554a6ed33dd7ac144fb2e1bbed98598e7af973042fc5cd43951c9a

# The build stays out of this group: astro check writes .astro/ as well.
- parallel:
Comment thread
kryota-dev marked this conversation as resolved.
Resolved
- name: Lint (ESLint, Stylelint)
run: pnpm lint

- name: Format check (Prettier)
run: pnpm format:check

- name: Type check (astro check)
run: pnpm check

- name: Build
run: pnpm build

- name: HTML validation (html-validate)
run: pnpm test:html

- name: Wait for lychee
wait: lychee
Comment thread
kryota-dev marked this conversation as resolved.
Resolved

- name: Link check (lychee, internal links only)
run: pnpm test:links

- name: Install Playwright browser
run: pnpm exec playwright install --with-deps chromium
- name: Wait for the Playwright browser
wait: playwright

- name: Accessibility (axe, light/dark x mobile/desktop)
run: pnpm test:a11y

# Not alongside the tests: sharing the CPU skews the scores.
- name: Lighthouse CI
run: pnpm test:lighthouse

Expand Down Expand Up @@ -131,16 +140,8 @@ jobs:
with:
persist-credentials: false

- uses: pnpm/action-setup@0977fd99725f1db4007ccb2928dbb4e90d06cc86 # v6

- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7
with:
node-version-file: .node-version
cache: pnpm

# Only wrangler is needed here; no install scripts run next to the token.
- name: Install dependencies
run: pnpm install --frozen-lockfile --ignore-scripts
# Only wrangler is needed here; install scripts stay off next to the token.
- uses: ./.github/actions/setup

- name: Download the build
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8
Expand Down Expand Up @@ -213,16 +214,8 @@ jobs:
with:
persist-credentials: false

- uses: pnpm/action-setup@0977fd99725f1db4007ccb2928dbb4e90d06cc86 # v6

- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7
with:
node-version-file: .node-version
cache: pnpm

# Only wrangler is needed here; no install scripts run next to the token.
- name: Install dependencies
run: pnpm install --frozen-lockfile --ignore-scripts
# Only wrangler is needed here; install scripts stay off next to the token.
- uses: ./.github/actions/setup

- name: Download the build
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8
Expand Down
12 changes: 2 additions & 10 deletions .github/workflows/preview-cleanup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,8 @@ jobs:
with:
persist-credentials: false

- uses: pnpm/action-setup@0977fd99725f1db4007ccb2928dbb4e90d06cc86 # v6

- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7
with:
node-version-file: .node-version
cache: pnpm

# Only wrangler is needed here; no install scripts run next to the token.
- name: Install dependencies
run: pnpm install --frozen-lockfile --ignore-scripts
# Only wrangler is needed here; install scripts stay off next to the token.
- uses: ./.github/actions/setup

# The Worker that holds the Previews; see the preview job in ci.yml.
- name: Delete the Preview
Expand Down
3 changes: 2 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ pnpm test:lighthouse # Lighthouse CI(Performance ≥ 0.95、他 3 項目 = 1

- Playwright は `pnpm build` 済みの `dist/client` を検査する。ソースを変えたらビルドし直してから走らせる。
- 単一テスト: `pnpm exec playwright test tests/seo.spec.ts`、名前で絞るなら `-g "<title>"`、プロジェクトを絞るなら `--project=mobile-light`(`{mobile,desktop}-{light,dark}` の 4 つ)。
- CI(`.github/workflows/ci.yml`)は lint → format:check → check → build → test:html → test:links → test:a11y → test:lighthouse の順に走る。PR テンプレートのチェックリストも同じ項目。
- CI(`.github/workflows/ci.yml`)は lint・format:check・check を並列に走らせた後、build → test:html → test:links → test:a11y → test:lighthouse の順に走る。Playwright のブラウザと lychee は、その裏で入れる。PR テンプレートのチェックリストも同じ項目。
- ワークフローの依存の準備(pnpm・Node・install)は composite action `.github/actions/setup` にまとめてある。install スクリプトは既定で動かさず、品質ゲートのジョブだけが `install-scripts: "true"` で動かす。

## アーキテクチャ

Expand Down
2 changes: 1 addition & 1 deletion docs/deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
2. PR のとき `preview` ジョブ: 1 の artifact を `wrangler preview` で Preview Worker に `pr-<番号>` として上げ、URL を PR にコメントする(同じコメントを更新し続ける)
3. main への push のとき `deploy` ジョブ: 1 の artifact を `wrangler deploy` で本番に上げる

デプロイのジョブはビルドし直さず、検査を通った成果物をそのまま配信します。依存も `--ignore-scripts` で入れ、トークンのある環境では install スクリプトを動かしません。
デプロイのジョブはビルドし直さず、検査を通った成果物をそのまま配信します。依存の準備は composite action `.github/actions/setup` が行い、既定では `--ignore-scripts` で入れます。install スクリプトを動かすのは、Cloudflare のトークンを持たない `ci` ジョブだけ(`install-scripts: "true"`)です。

デプロイの後には `scripts/check-deployed-headers.mjs` が、配信された URL のレスポンスヘッダーが `dist/client/_headers` の `/*` のルール(CSP を含む)と一致するかを確かめます。デプロイ直後は古い版が応答することがあるため、5 秒間隔で最大 12 回試します(各リクエストのタイムアウトは 10 秒)。workers.dev のホストには `X-Robots-Tag: noindex` があること、kryota.dev には無いことも検査します。

Expand Down
Loading