1
1
name : Local development
2
2
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
7
5
# **Who does it impact**: Engineers, Contributors.
8
6
9
7
on :
@@ -28,76 +26,25 @@ jobs:
28
26
with :
29
27
token : ${{ secrets.DOCS_BOT_PAT_BASE }}
30
28
31
- # Note that we don't check out docs-early-access, Elasticsearch,
32
- # or any remote translations. Nothing fancy here!
33
-
34
29
- name : Disable Next.js telemetry
35
30
run : npx next telemetry disable
36
31
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
71
33
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
101
42
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
103
50
fi
0 commit comments