Skip to content

Repo sync

Repo sync #5564

Workflow file for this run

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.
# **Who does it impact**: Engineers, Contributors.
on:
merge_group:
pull_request:
permissions:
contents: read
jobs:
local-dev:
if: github.repository == 'github/docs-internal' || github.repository == 'github/docs'
runs-on: ${{ fromJSON('["ubuntu-latest", "ubuntu-20.04-xl"]')[github.repository == 'github/docs-internal'] }}
steps:
- name: Check out repo
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
# - uses: ./.github/actions/node-npm-setup
- name: Install dependencies
run: npm install
# Note that we don't check out docs-early-access, Elasticsearch,
# or any remote translations. Nothing fancy here!
- name: Start server in the background
run: npm start > /tmp/stdout.log 2> /tmp/stderr.log &
- name: View the home page
run: |
echo "Going to sleep a little to wait for the server to start"
sleep 10
curl --fail --retry-connrefused --retry 5 http://localhost:4000/
- name: Run basic tests
run: node src/workflows/test-local-dev.js
- 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/quickstart/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 [email protected]
# 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/quickstart/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
else
echo "As expected, it failed :)"
fi