Skip to content
Draft
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
139 changes: 95 additions & 44 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,9 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npx tsx bin/post-pr-ci-failure-comment/index.ts

build:
name: Build
pre-build:
name: Pre Build
runs-on: ubuntu-latest
outputs:
link_check_failed: ${{ steps.check_link_result.outputs.failed }}
permissions:
contents: read
pull-requests: write
Expand All @@ -114,7 +112,8 @@ jobs:
exit 1
fi

- run: |
- name: Check for invalid file extensions
run: |
FILES=$(
find src/content \
-type f \
Expand All @@ -132,38 +131,81 @@ jobs:
exit 1
fi

- name: Cache node_modules
- name: Restore node_modules (cache hit)
id: node-modules-cache
uses: actions/cache@v5
with:
path: node_modules
key: node-modules-${{ runner.os }}-${{ hashFiles('package-lock.json') }}

- name: Run sync (if cache hit)
run: npm run sync
if: steps.node-modules-cache.outputs.cache-hit == 'true'

- name: Node install (cache miss)
- name: Install node_modules (cache miss)
run: npm ci
if: steps.node-modules-cache.outputs.cache-hit != 'true'

- uses: actions/cache/restore@v5
with:
path: |
node_modules/.astro/assets
key: static

- run: npx tsx bin/post-codeowners-comment/index.ts
continue-on-error: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- run: npm run check

- run: npm run check:worker

- uses: reviewdog/action-eslint@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
reporter: github-pr-review
fail_level: error
filter_mode: nofilter

- run: npm run format:core:check

- name: Validate redirects
run: npx tsm bin/validate-redirects.ts

- name: Tests
run: npm run test:prebuild

build:
name: Build
needs: pre-build
runs-on: ubuntu-latest
outputs:
link_check_failed: ${{ steps.check_link_result.outputs.failed }}
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 1

- uses: actions/setup-node@v6
with:
node-version: 22.x
cache: npm

- name: Restore node_modules (cache hit)
id: node-modules-cache
uses: actions/cache@v5
with:
path: node_modules
key: node-modules-${{ runner.os }}-${{ hashFiles('package-lock.json') }}

- name: Install node_modules (cache miss)
run: npm ci
if: steps.node-modules-cache.outputs.cache-hit != 'true'

- uses: actions/cache@v5
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- uses: actions/cache@v5
- name: Restore Astro assets from cache
- uses: actions/cache@v5

with:
path: |
node_modules/.astro/assets
key: static

# The starlight-links-validator plugin runs in astro:build:done, which fires
# AFTER all pages have been written to dist/. If link validation fails, the
# build exits non-zero but dist/ is complete. We use continue-on-error so the
# job succeeds (allowing deploy + validate to run), then check the outcome below.
# job succeeds (allowing deploy + post-build to run), then check the outcome below.
- run: npm run build
id: build_step
name: Build
Expand All @@ -188,19 +230,13 @@ jobs:
echo "failed=false" >> "$GITHUB_OUTPUT"
fi

- uses: actions/cache/save@v5
with:
path: |
node_modules/.astro/assets
key: static

- uses: actions/upload-artifact@v7
with:
name: dist
path: dist

validate:
name: Validate
post-build:
name: Post Build
needs: build
runs-on: ubuntu-latest
permissions:
Expand All @@ -216,27 +252,24 @@ jobs:
node-version: 22.x
cache: npm

- run: npm ci
- name: Restore node_modules (cache hit)
id: node-modules-cache
uses: actions/cache@v5
with:
path: node_modules
key: node-modules-${{ runner.os }}-${{ hashFiles('package-lock.json') }}

- name: Install node_modules (cache miss)
run: npm ci
if: steps.node-modules-cache.outputs.cache-hit != 'true'

- uses: actions/download-artifact@v8
with:
name: dist
path: dist

- uses: reviewdog/action-eslint@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
reporter: github-pr-review
fail_level: error
filter_mode: nofilter

- run: npm run format:core:check

- name: Validate redirects
run: npx tsm bin/validate-redirects.ts

- name: Tests
run: npm run test
- name: Tests (Workers)
run: npm run test:postbuild

- name: Link validation
if: needs.build.outputs.link_check_failed == 'true'
Expand All @@ -246,7 +279,7 @@ jobs:

notify:
name: Notify
needs: [build, validate]
needs: [pre-build, build, post-build]
if: always()
runs-on: ubuntu-latest
permissions:
Expand All @@ -262,7 +295,16 @@ jobs:
node-version: 22.x
cache: npm

- run: npm ci
- name: Restore node_modules (cache hit)
id: node-modules-cache
uses: actions/cache@v5
with:
path: node_modules
key: node-modules-${{ runner.os }}-${{ hashFiles('package-lock.json') }}

- name: Install node_modules (cache miss)
run: npm ci
if: steps.node-modules-cache.outputs.cache-hit != 'true'

- name: Post PR CI failure comment
continue-on-error: true
Expand All @@ -288,7 +330,16 @@ jobs:
node-version: 22.x
cache: npm

- run: npm ci
- name: Restore node_modules (cache hit)
id: node-modules-cache
uses: actions/cache@v5
with:
path: node_modules
key: node-modules-${{ runner.os }}-${{ hashFiles('package-lock.json') }}

- name: Install node_modules (cache miss)
run: npm ci
if: steps.node-modules-cache.outputs.cache-hit != 'true'

- uses: actions/download-artifact@v8
with:
Expand Down
7 changes: 5 additions & 2 deletions bin/post-pr-ci-failure-comment/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,14 @@ async function run(): Promise<void> {
});

const ciJobs = run.jobs.filter(
(job) => job.name === "Build" || job.name === "Validate",
(job) =>
job.name === "Pre Build" ||
job.name === "Build" ||
job.name === "Post Build",
);

if (ciJobs.length === 0) {
core.setFailed(`Could not find Build or Validate jobs`);
core.setFailed(`Could not find Pre Build, Build, or Post Build jobs`);
process.exit();
}

Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
"start": "npx astro dev",
"sync": "npx astro sync",
"test": "npx vitest",
"test:prebuild": "npx vitest --project Node --project Astro",
"test:postbuild": "npx vitest --project Workers",
"lint": "npx eslint",
"ai-setup:import-from-opencode": "npx rulesync import --targets opencode --features rules,commands,subagents",
"ai-setup:claudecode": "npm run ai-setup:import-from-opencode && npx rulesync generate --targets claudecode --features rules,commands,subagents",
Expand Down
Loading