1
0
mirror of synced 2025-12-19 09:57:42 -05:00

Streamline flaky local-dev test suite (#57716)

This commit is contained in:
Kevin Heis
2025-09-26 10:51:26 -07:00
committed by GitHub
parent 7d18e60d01
commit 60feaffa9a
5 changed files with 25 additions and 313 deletions

View File

@@ -1,9 +1,7 @@
name: Local development
# **What it does**: Can you start the local server like a writer would do?
# **Why we have it**: Our CI is often heavily geared on testing in "production"
# that historically we've been known to break local
# development sometimes.
# **What it does**: Basic smoke test to ensure local dev server starts and serves content
# **Why we have it**: Catch catastrophic "npm start is completely broken" scenarios
# **Who does it impact**: Engineers, Contributors.
on:
@@ -28,76 +26,25 @@ jobs:
with:
token: ${{ secrets.DOCS_BOT_PAT_BASE }}
# Note that we don't check out docs-early-access, Elasticsearch,
# or any remote translations. Nothing fancy here!
- name: Disable Next.js telemetry
run: npx next telemetry disable
- name: Install headless browser
run: npx playwright install --no-shell
# The Playwright test, with the env vars we set here, takes care of
# starting a server and shutting it down when it's done.
# That's why it's important this step comes before the `npm start &`
# step below.
- name: Run Playwright tests
env:
# This is what local dev contributors are expected to do.
PLAYWRIGHT_START_SERVER_COMMAND: 'npm start'
# This is so that timeouts aren't retried, which can lead to
# tests not exiting at the end with a non-zero. Otherwise,
# by default failures are marked as "flaky" instead of "failed".
PLAYWRIGHT_RETRIES: 0
TEST_EARLY_ACCESS: ${{ github.repository == 'github/docs-internal' }}
# workaround for https://github.com/nodejs/node/issues/59364 as of 22.18.0
NODE_OPTIONS: '--no-experimental-strip-types --max-old-space-size=8192'
run: npm run playwright-test -- playwright-local-dev
- name: Start server in the background
run: npm start > /tmp/stdout.log 2> /tmp/stderr.log &
- name: View the home page
- name: Start server and basic smoke test
run: |
echo "Going to sleep a little to wait for the server to start"
sleep 15
curl --fail --retry-connrefused --retry 5 http://localhost:4000/
# Start server in background
npm start > /tmp/stdout.log 2> /tmp/stderr.log &
SERVER_PID=$!
- name: Run basic tests
run: npm run test-local-dev
- if: ${{ failure() }}
name: Debug server outputs on errors
run: |
echo "____STDOUT____"
cat /tmp/stdout.log
echo "____STDERR____"
cat /tmp/stderr.log
- name: Pre-commit hooks should prevent bad Markdown edits
run: |
set -e
# This test assumes this one file always exists
ls content/get-started/start-your-journey/hello-world.md
# Not sure if it matters but we're in a detached HEAD state
# after the actions/checkout action.
git checkout -b my-new-branch
# Also, do this so you don't get errors from git about this
# not being set up before your first commit attempt
git config user.name github-actions
git config user.email github-actions@github.com
# To know what will fail the markdown lint, see src/content-linter/style/github-docs.js
# Add some NOT valid Markdown to it
# In this case an internal link with a hardcode /en/ prefix.
echo "This *is** not valid [Markdown](/en/foo)" >> content/get-started/start-your-journey/hello-world.md
git commit -a -m "this should fail"
exit_code=$?
if [ $exit_code != 0 ]; then
echo "That SHOULD have failed, but it DIDN'T"
exit 1
# Wait for server to be ready and test homepage
if curl --fail --retry-connrefused --retry 10 --retry-delay 2 http://localhost:4000/; then
echo "✅ Local dev server started successfully and serves homepage"
kill $SERVER_PID 2>/dev/null || true
else
echo "As expected, it failed :)"
echo "❌ Local dev server failed to start or serve content"
echo "____STDOUT____"
cat /tmp/stdout.log
echo "____STDERR____"
cat /tmp/stderr.log
kill $SERVER_PID 2>/dev/null || true
exit 1
fi