1
0
mirror of synced 2026-01-05 12:07:35 -05:00

Minimal tests with Playwright (#35322)

This commit is contained in:
Peter Bengtsson
2023-03-10 16:22:51 -05:00
committed by GitHub
parent 9f30e13d06
commit 5cecf691c2
13 changed files with 387 additions and 46 deletions

View File

@@ -35,22 +35,11 @@ jobs:
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: Install a local Elasticsearch for testing
# For the sake of saving time, only run this step if the test-group
# is one that will run tests against an Elasticsearch on localhost.
uses: getong/elasticsearch-action@95b501ab0c83dee0aac7c39b7cea3723bef14954
with:
# Make sure this matches production and `sync-search-pr.yml`
elasticsearch version: '7.11.1'
host port: 9200
container port: 9200
host node port: 9300
node port: 9300
discovery type: 'single-node'
- name: Checkout
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8
- uses: ./.github/actions/setup-elasticsearch
- name: Setup Node.js
uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516
with:

53
.github/workflows/headless-tests.yml vendored Normal file
View File

@@ -0,0 +1,53 @@
name: Headless Tests
# **What it does**: This runs our browser tests to test things that depend
# on client-side JavaScript.
# **Why we have it**: Because most automated jest tests only test static
# input and outputs.
# **Who does it impact**: Docs engineering, open-source engineering contributors.
on:
workflow_dispatch:
merge_group:
pull_request:
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:
playwright-tests:
if: github.repository == 'github/docs-internal' || github.repository == 'github/docs'
runs-on: ${{ fromJSON('["ubuntu-latest", "ubuntu-20.04-xl"]')[github.repository == 'github/docs-internal'] }}
timeout-minutes: 60
steps:
- name: Check out repo
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8
- uses: ./.github/actions/setup-elasticsearch
- uses: ./.github/actions/node-npm-setup
- 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: Run Playwright tests
env:
PLAYWRIGHT_WORKERS: ${{ fromJSON('[1, 4]')[github.repository == 'github/docs-internal'] }}
run: npm run playwright-test -- --reporter list

View File

@@ -33,19 +33,11 @@ jobs:
runs-on: ${{ fromJSON('["ubuntu-latest", "ubuntu-20.04-xl"]')[github.repository == 'github/docs-internal'] }}
if: github.repository == 'github/docs-internal' || github.repository == 'github/docs'
steps:
- uses: getong/elasticsearch-action@95b501ab0c83dee0aac7c39b7cea3723bef14954
with:
# # Make sure this matches production and `test.yml`
elasticsearch version: '7.11.1'
host port: 9200
container port: 9200
host node port: 9300
node port: 9300
discovery type: 'single-node'
- name: Check out repo
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8
- uses: ./.github/actions/setup-elasticsearch
- uses: ./.github/actions/node-npm-setup
- name: Cache nextjs build

View File

@@ -67,25 +67,14 @@ jobs:
matrix:
test-group: ${{ fromJSON(needs.figureOutMatrix.outputs.matrix) }}
steps:
- name: Install a local Elasticsearch for testing
# For the sake of saving time, only run this step if the test-group
# is one that will run tests against an Elasticsearch on localhost.
if: ${{ matrix.test-group == 'content' || matrix.test-group == 'translations' }}
uses: getong/elasticsearch-action@95b501ab0c83dee0aac7c39b7cea3723bef14954
with:
# Make sure this matches production and `sync-search-pr.yml`
elasticsearch version: '7.11.1'
host port: 9200
container port: 9200
host node port: 9300
node port: 9300
discovery type: 'single-node'
# Each of these ifs needs to be repeated at each step to make sure the required check still runs
# Even if if doesn't do anything
- name: Check out repo
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8
- uses: ./.github/actions/setup-elasticsearch
if: ${{ matrix.test-group == 'content' || matrix.test-group == 'translations' }}
- uses: ./.github/actions/node-npm-setup
- uses: ./.github/actions/get-docs-early-access