-
Notifications
You must be signed in to change notification settings - Fork 0
docs: add Astro Starlight documentation site deployed to Cloudflare Pages #20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
7eadcf7
docs: add Astro Starlight documentation site deployed to Cloudflare P…
amondnet 1a6b359
fix: make website pass root eslint
amondnet a7dea74
chore: address review feedback on docs workflow and sync script
amondnet e72a13f
chore: fix Codacy warnings
amondnet f9e73b1
docs: add HTTPS with portless guide
amondnet 405734f
feat: port --portless flag and base URL fallback chain from upstream
amondnet a432f1b
docs: apply starlight-theme-black to the docs site
amondnet abe5c5f
chore: fix Codacy warnings in portless port
amondnet bae3bb0
test: cover portless integration and reduce start command complexity
amondnet eded955
ci: add docs PR preview deployments with sticky comment; finish Sonar…
amondnet 700cde5
docs: link the documentation site (emulate.pleaseai.dev)
amondnet 0330900
chore: apply AI code review suggestions
amondnet ecf88b8
chore: apply second-round review feedback
amondnet e115254
chore: fix remaining Codacy nits
amondnet b645fdb
chore: move EMULATE_PORT/PORT fallback into startCommand
amondnet File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| name: Docs | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| paths: ['website/**', 'skills/**', 'docs/**'] | ||
| pull_request: | ||
| paths: ['website/**', 'skills/**', 'docs/**'] | ||
| workflow_dispatch: | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: ${{ github.event_name == 'pull_request' }} | ||
|
|
||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| env: | ||
| # Secrets are unavailable on fork PRs and may not be configured yet — | ||
| # skip deployment (and the preview comment) instead of failing the build. | ||
| HAS_CLOUDFLARE_SECRETS: ${{ secrets.CLOUDFLARE_API_TOKEN != '' && secrets.CLOUDFLARE_ACCOUNT_ID != '' }} | ||
| permissions: | ||
| contents: read | ||
| deployments: write | ||
| pull-requests: write | ||
| defaults: | ||
| run: | ||
| working-directory: website | ||
| steps: | ||
| - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 | ||
| with: | ||
| persist-credentials: false | ||
| - uses: jdx/mise-action@1648a7812b9aeae629881980618f079932869151 # v4.0.1 | ||
| - run: bun install --frozen-lockfile | ||
| - run: bun scripts/sync-services.ts | ||
| - name: Check generated service pages are up to date | ||
| # git status --porcelain also catches untracked pages generated for | ||
| # newly added skills, which git diff alone would miss. | ||
| run: | | ||
| if [ -n "$(git status --porcelain -- src/content/docs/services)" ]; then | ||
| git status --short -- src/content/docs/services | ||
| echo "::error::services/*.md is stale — run 'bun run sync:services' in website/ and commit" | ||
| exit 1 | ||
| fi | ||
| - run: bun run build | ||
| # Pushes to main deploy to production; PR branches get a preview | ||
| # deployment. Fork PRs are skipped (no access to secrets). | ||
| - name: Deploy to Cloudflare Pages | ||
| id: deploy | ||
| if: env.HAS_CLOUDFLARE_SECRETS == 'true' | ||
| uses: cloudflare/wrangler-action@ebbaa1584979971c8614a24965b4405ff95890e0 # v4.0.0 | ||
| with: | ||
| apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | ||
| accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | ||
| gitHubToken: ${{ secrets.GITHUB_TOKEN }} | ||
| workingDirectory: website | ||
| command: pages deploy dist --project-name=emulate-docs --branch=${{ github.head_ref || github.ref_name }} | ||
| - name: Comment preview URL on PR | ||
| if: github.event_name == 'pull_request' && steps.deploy.outcome == 'success' | ||
| uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 | ||
| env: | ||
| DEPLOYMENT_URL: ${{ steps.deploy.outputs.deployment-url }} | ||
| ALIAS_URL: ${{ steps.deploy.outputs.pages-deployment-alias-url }} | ||
| with: | ||
| script: | | ||
| const marker = '<!-- docs-preview -->' | ||
| const url = process.env.DEPLOYMENT_URL | ||
| const alias = process.env.ALIAS_URL | ||
| const lines = [ | ||
| marker, | ||
| '### 📖 Docs preview deployed', | ||
| '', | ||
| `| | URL |`, | ||
| `| --- | --- |`, | ||
| `| Preview | ${url} |`, | ||
| ] | ||
| if (alias && alias !== url) { | ||
| lines.push(`| Branch alias | ${alias} |`) | ||
| } | ||
| lines.push('', `_Commit: ${context.payload.pull_request.head.sha}_`) | ||
| const body = lines.join('\n') | ||
|
|
||
| const { data: comments } = await github.rest.issues.listComments({ | ||
| ...context.repo, | ||
| issue_number: context.issue.number, | ||
| per_page: 100, | ||
| }) | ||
| const existing = comments.find(c => c.body.includes(marker)) | ||
| if (existing) { | ||
| await github.rest.issues.updateComment({ ...context.repo, comment_id: existing.id, body }) | ||
| } | ||
| else { | ||
| await github.rest.issues.createComment({ ...context.repo, issue_number: context.issue.number, body }) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| import process from 'node:process' | ||
| import { afterAll, beforeEach, describe, expect, it } from 'bun:test' | ||
| import { resolveBaseUrl } from '../base-url.js' | ||
| import { defaultBasePort, validateBaseUrlOptions } from '../start-options.js' | ||
|
|
||
| const savedEnv = { | ||
| EMULATE_BASE_URL: process.env.EMULATE_BASE_URL, | ||
| PORTLESS_URL: process.env.PORTLESS_URL, | ||
| EMULATE_PORT: process.env.EMULATE_PORT, | ||
| PORT: process.env.PORT, | ||
| } | ||
|
|
||
| // Clear before each test (not just after) so ambient shell/CI env vars | ||
| // cannot leak into the first test case. | ||
| beforeEach(() => { | ||
| delete process.env.EMULATE_BASE_URL | ||
| delete process.env.PORTLESS_URL | ||
| delete process.env.EMULATE_PORT | ||
| delete process.env.PORT | ||
| }) | ||
|
|
||
| afterAll(() => { | ||
| for (const [name, value] of Object.entries(savedEnv)) { | ||
| if (value !== undefined) { | ||
| Object.assign(process.env, { [name]: value }) | ||
| } | ||
| } | ||
| }) | ||
|
|
||
| describe('resolveBaseUrl', () => { | ||
| it('defaults to localhost with the port', () => { | ||
| expect(resolveBaseUrl({ service: 'kakao', port: 4000 })).toBe('http://localhost:4000') | ||
| }) | ||
|
|
||
| it('prefers seed baseUrl over everything else', () => { | ||
| process.env.EMULATE_BASE_URL = 'https://env.test' | ||
| expect( | ||
| resolveBaseUrl({ service: 'kakao', port: 4000, baseUrl: 'https://flag.test', seedBaseUrl: 'https://seed.test/' }), | ||
| ).toBe('https://seed.test') | ||
| }) | ||
|
|
||
| it('uses the explicit baseUrl over env vars', () => { | ||
| process.env.EMULATE_BASE_URL = 'https://env.test' | ||
| expect(resolveBaseUrl({ service: 'kakao', port: 4000, baseUrl: 'https://flag.test' })).toBe('https://flag.test') | ||
| }) | ||
|
|
||
| it('falls back to EMULATE_BASE_URL, then PORTLESS_URL', () => { | ||
| process.env.PORTLESS_URL = 'https://{service}.emulate.localhost' | ||
| expect(resolveBaseUrl({ service: 'naver', port: 4001 })).toBe('https://naver.emulate.localhost') | ||
|
|
||
| process.env.EMULATE_BASE_URL = 'https://{service}.myproxy.test' | ||
| expect(resolveBaseUrl({ service: 'naver', port: 4001 })).toBe('https://naver.myproxy.test') | ||
| }) | ||
|
|
||
| it('interpolates {service} in explicit baseUrl', () => { | ||
| expect(resolveBaseUrl({ service: 'supabase', port: 4004, baseUrl: 'https://{service}.proxy.test' })).toBe( | ||
| 'https://supabase.proxy.test', | ||
| ) | ||
| }) | ||
| }) | ||
|
|
||
| describe('validateBaseUrlOptions', () => { | ||
| it('rejects --portless together with --base-url', () => { | ||
| expect(validateBaseUrlOptions({ portless: true, baseUrl: 'https://x.test' }, 1)).toContain('mutually exclusive') | ||
| }) | ||
|
|
||
| it('requires {service} for multi-service --base-url', () => { | ||
| expect(validateBaseUrlOptions({ baseUrl: 'https://x.test' }, 2)).toContain('{service} placeholder') | ||
| expect(validateBaseUrlOptions({ baseUrl: 'https://{service}.x.test' }, 2)).toBeNull() | ||
| }) | ||
|
|
||
| it('accepts a literal --base-url for a single service', () => { | ||
| expect(validateBaseUrlOptions({ baseUrl: 'https://x.test' }, 1)).toBeNull() | ||
| }) | ||
| }) | ||
|
|
||
| describe('defaultBasePort', () => { | ||
| it('defaults to 4000 without env vars', () => { | ||
| expect(defaultBasePort()).toBe(4000) | ||
| }) | ||
|
|
||
| it('prefers EMULATE_PORT over PORT and ignores non-numeric values', () => { | ||
| process.env.PORT = '5000' | ||
| expect(defaultBasePort()).toBe(5000) | ||
|
|
||
| process.env.EMULATE_PORT = '6000' | ||
| expect(defaultBasePort()).toBe(6000) | ||
|
|
||
| process.env.EMULATE_PORT = 'not-a-port' | ||
| expect(defaultBasePort()).toBe(5000) | ||
| }) | ||
| }) | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
afterAlldoesn't clear env vars that were originally unset.Only vars with an original defined value get restored; vars that started
undefined(e.g.EMULATE_PORT/PORTin most shells) are left with whatever the last test set them to, since nothing callsdeletefor theundefinedcase. This can leak strayPORT/EMULATE_PORTvalues into other test files sharing the same worker process.💚 Proposed fix
afterAll(() => { for (const [name, value] of Object.entries(savedEnv)) { if (value !== undefined) { Object.assign(process.env, { [name]: value }) } + else { + delete process.env[name] + } } })📝 Committable suggestion
🤖 Prompt for AI Agents