80 lines
2.5 KiB
YAML
80 lines
2.5 KiB
YAML
name: Browser Tests
|
|
|
|
# **What it does**: This runs our browser tests on pull requests.
|
|
# **Why we have it**: This is the only way we currently test our browser JavaScript.
|
|
# **Who does it impact**: Docs engineering, open-source engineering contributors.
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
pull_request:
|
|
paths:
|
|
- '**.js'
|
|
- '**.mjs'
|
|
- '**.ts'
|
|
- '**.tsx'
|
|
- jest.config.js
|
|
- package.json
|
|
# In case something like eslint or tsc or prettier upgrades
|
|
- package-lock.json
|
|
# Ultimately, for debugging this workflow itself
|
|
- .github/workflows/browser-test.yml
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
# This allows a subsequently queued workflow run to interrupt previous runs
|
|
concurrency:
|
|
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
|
|
cancel-in-progress: true
|
|
|
|
env:
|
|
ELASTICSEARCH_URL: http://localhost:9200/
|
|
|
|
jobs:
|
|
build:
|
|
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: Checkout
|
|
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8
|
|
|
|
- uses: ./.github/actions/setup-elasticsearch
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516
|
|
with:
|
|
node-version-file: 'package.json'
|
|
cache: npm
|
|
|
|
- name: Install dependencies
|
|
env:
|
|
# This makes it so the puppeteer npm package doesn't bother
|
|
# to download a copy of chromium because it can use
|
|
# `$PUPPETEER_EXECUTABLE_PATH` from the ubuntu Action container.
|
|
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: true
|
|
run: npm ci --include=optional
|
|
|
|
- uses: ./.github/actions/get-docs-early-access
|
|
if: ${{ github.repository == 'github/docs-internal' }}
|
|
with:
|
|
token: ${{ secrets.DOCUBOT_REPO_PAT }}
|
|
|
|
- name: Cache nextjs build
|
|
uses: actions/cache@9b0c1fce7a93df8e3bb8926b0d6e9d89e92f20a7
|
|
with:
|
|
path: .next/cache
|
|
key: ${{ runner.os }}-nextjs-${{ hashFiles('package*.json') }}
|
|
|
|
- name: Run build script
|
|
run: npm run build
|
|
|
|
- name: Index fixtures into the local Elasticsearch
|
|
run: npm run index-test-fixtures
|
|
|
|
- name: Check that Elasticsearch is accessible
|
|
run: |
|
|
curl --fail --retry-connrefused --retry 5 -I ${{ env.ELASTICSEARCH_URL }}
|
|
|
|
- name: Run browser-test
|
|
run: npm run browser-test
|