Skip to content

Commit 60feaff

Browse files
authored
Streamline flaky local-dev test suite (#57716)
1 parent 7d18e60 commit 60feaff

File tree

5 files changed

+26
-314
lines changed

5 files changed

+26
-314
lines changed

.github/workflows/local-dev.yml

Lines changed: 18 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
name: Local development
22

3-
# **What it does**: Can you start the local server like a writer would do?
4-
# **Why we have it**: Our CI is often heavily geared on testing in "production"
5-
# that historically we've been known to break local
6-
# development sometimes.
3+
# **What it does**: Basic smoke test to ensure local dev server starts and serves content
4+
# **Why we have it**: Catch catastrophic "npm start is completely broken" scenarios
75
# **Who does it impact**: Engineers, Contributors.
86

97
on:
@@ -28,76 +26,25 @@ jobs:
2826
with:
2927
token: ${{ secrets.DOCS_BOT_PAT_BASE }}
3028

31-
# Note that we don't check out docs-early-access, Elasticsearch,
32-
# or any remote translations. Nothing fancy here!
33-
3429
- name: Disable Next.js telemetry
3530
run: npx next telemetry disable
3631

37-
- name: Install headless browser
38-
run: npx playwright install --no-shell
39-
40-
# The Playwright test, with the env vars we set here, takes care of
41-
# starting a server and shutting it down when it's done.
42-
# That's why it's important this step comes before the `npm start &`
43-
# step below.
44-
- name: Run Playwright tests
45-
env:
46-
# This is what local dev contributors are expected to do.
47-
PLAYWRIGHT_START_SERVER_COMMAND: 'npm start'
48-
# This is so that timeouts aren't retried, which can lead to
49-
# tests not exiting at the end with a non-zero. Otherwise,
50-
# by default failures are marked as "flaky" instead of "failed".
51-
PLAYWRIGHT_RETRIES: 0
52-
TEST_EARLY_ACCESS: ${{ github.repository == 'github/docs-internal' }}
53-
# workaround for https://github.com/nodejs/node/issues/59364 as of 22.18.0
54-
NODE_OPTIONS: '--no-experimental-strip-types --max-old-space-size=8192'
55-
run: npm run playwright-test -- playwright-local-dev
56-
57-
- name: Start server in the background
58-
run: npm start > /tmp/stdout.log 2> /tmp/stderr.log &
59-
60-
- name: View the home page
61-
run: |
62-
echo "Going to sleep a little to wait for the server to start"
63-
sleep 15
64-
curl --fail --retry-connrefused --retry 5 http://localhost:4000/
65-
66-
- name: Run basic tests
67-
run: npm run test-local-dev
68-
69-
- if: ${{ failure() }}
70-
name: Debug server outputs on errors
32+
- name: Start server and basic smoke test
7133
run: |
72-
echo "____STDOUT____"
73-
cat /tmp/stdout.log
74-
echo "____STDERR____"
75-
cat /tmp/stderr.log
76-
77-
- name: Pre-commit hooks should prevent bad Markdown edits
78-
run: |
79-
set -e
80-
81-
# This test assumes this one file always exists
82-
ls content/get-started/start-your-journey/hello-world.md
83-
84-
# Not sure if it matters but we're in a detached HEAD state
85-
# after the actions/checkout action.
86-
git checkout -b my-new-branch
87-
# Also, do this so you don't get errors from git about this
88-
# not being set up before your first commit attempt
89-
git config user.name github-actions
90-
git config user.email [email protected]
91-
92-
# To know what will fail the markdown lint, see src/content-linter/style/github-docs.js
93-
# Add some NOT valid Markdown to it
94-
# In this case an internal link with a hardcode /en/ prefix.
95-
echo "This *is** not valid [Markdown](/en/foo)" >> content/get-started/start-your-journey/hello-world.md
96-
git commit -a -m "this should fail"
97-
exit_code=$?
98-
if [ $exit_code != 0 ]; then
99-
echo "That SHOULD have failed, but it DIDN'T"
100-
exit 1
34+
# Start server in background
35+
npm start > /tmp/stdout.log 2> /tmp/stderr.log &
36+
SERVER_PID=$!
37+
38+
# Wait for server to be ready and test homepage
39+
if curl --fail --retry-connrefused --retry 10 --retry-delay 2 http://localhost:4000/; then
40+
echo "✅ Local dev server started successfully and serves homepage"
41+
kill $SERVER_PID 2>/dev/null || true
10142
else
102-
echo "As expected, it failed :)"
43+
echo "❌ Local dev server failed to start or serve content"
44+
echo "____STDOUT____"
45+
cat /tmp/stdout.log
46+
echo "____STDERR____"
47+
cat /tmp/stderr.log
48+
kill $SERVER_PID 2>/dev/null || true
49+
exit 1
10350
fi

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@
9191
"sync-secret-scanning": "tsx src/secret-scanning/scripts/sync.ts",
9292
"sync-webhooks": "npx tsx src/rest/scripts/update-files.ts -o webhooks",
9393
"test": "vitest",
94-
"test-local-dev": "tsx src/workflows/test-local-dev.ts",
9594
"test-moved-content": "tsx src/content-render/scripts/test-moved-content.ts",
9695
"tsc": "tsc --noEmit",
9796
"unallowed-contributions": "tsx src/workflows/unallowed-contributions.ts",

src/fixtures/tests/playwright-local-dev.spec.ts

Lines changed: 0 additions & 65 deletions
This file was deleted.

src/fixtures/tests/playwright-rendering.spec.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,14 @@ test('search from enterprise-cloud and filter by top-level Fooing', async ({ pag
199199
// for improvement!
200200
})
201201

202+
test('404 page renders correctly', async ({ page }) => {
203+
const response = await page.goto('/this-definitely-does-not-exist')
204+
expect(response?.status()).toBe(404)
205+
206+
// Check that the 404 page content is rendered
207+
await expect(page.getByText(/It looks like this page doesn't exist/)).toBeVisible()
208+
})
209+
202210
test.describe('platform picker', () => {
203211
test('switch operating systems', async ({ page }) => {
204212
await page.goto('/get-started/liquid/platform-specific')

src/workflows/test-local-dev.ts

Lines changed: 0 additions & 177 deletions
This file was deleted.

0 commit comments

Comments
 (0)