Skip to content

update sse tests

update sse tests #166

# This file configure a GitHub workflow responsible to perform
# various checks related to the codebase.
#
# For that reason it's runned on every pull request and push to main.
#
# It does the following:
# - Check linting passes (no eslint error on files)
# - Run tests and ensure none is failing
name: workspace_tests
on:
push:
branches:
- main
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#patterns-to-match-file-paths
paths-ignore:
- "docs/**"
- "www/**"
- "**/readme.md"
pull_request:
branches:
- "**"
paths-ignore:
- "docs/**"
- "www/**"
- "./readme.md"
jobs:
test:
strategy:
matrix:
# https://github.com/actions/runner-images
os:
- ubuntu-22.04
- macos-12 # until https://github.com/microsoft/playwright/issues/30585
- windows-2022
node: [22.11.0]
runs-on: ${{ matrix.os }}
name: test on ${{ matrix.os }} and node ${{ matrix.node }}
env:
CI: true
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
## --- NPM INSTALL START --- ##
# sudo ulimit should prevent npm link failure
- name: set linux fs limits
if: runner.os == 'Linux'
run: |
sudo sysctl fs.inotify.max_user_watches=524288
sudo sysctl -p
sudo sh -c "ulimit -n 65536 && exec su $LOGNAME"
ulimit -n
- name: Install node modules
run: npm install
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
# Figures out the version of playwright that's installed.
# 1. Because we don't know what version npm will resolve it to
# 2. Because we're in a workspace, we need to make sure we get the version
# for the root and not any children, hence the `grep`. If not using
# workspaces, this can be skipped.
# The result is stored in $PLAYWRIGHT_VERSION
# https://github.com/microsoft/playwright/issues/7249#issuecomment-2299065930
# https://stackoverflow.com/a/33426237/24573072
# https://github.com/actions/runner/issues/1636#issuecomment-1024531638
- name: Detect Playwright version (Windows)
if: runner.os == 'windows'
run: echo "PLAYWRIGHT_VERSION=$(npm ll -p --depth=0 playwright | grep -o '@.*')" | Out-File -FilePath $env:GITHUB_ENV -Append
- name: Detect Playwright version (Linux and Mac)
if: runner.os != 'windows'
run: echo "PLAYWRIGHT_VERSION=$(npm ll -p --depth=0 playwright | grep -o '@.*')" >> $GITHUB_ENV
- name: Put $HOME in env
if: runner.os == 'windows'
run: echo "HOME=$HOME" | Out-File -FilePath $env:GITHUB_ENV -Append
# Attempt to restore the correct Playwright browser binaries based on the
# currently installed version of Playwright (The browser binary versions
# may change with Playwright versions).
# Note: Playwright's cache directory is hard coded because that's what it
# says to do in the docs. There doesn't appear to be a command that prints
# it out for us.
- name: Cache playwright binaries
uses: actions/cache@v4
id: playwright-cache
with:
# see https://playwright.dev/docs/browsers#managing-browser-binaries
path: ${{ runner.os == 'Windows' && format('{0}{1}', env.HOME, '\AppData\Local\ms-playwright') || runner.os == 'Linux' && '~/.cache/ms-playwright' || '~/Library/Caches/ms-playwright' }}
key: ${{ runner.os }}-playwright-${{ env.PLAYWRIGHT_VERSION }}
# As a fallback, if the Playwright version has changed, try use the
# most recently cached version. There's a good chance that at least one
# of the browser binary versions haven't been updated, so Playwright can
# skip installing that in the next step.
# Note: When falling back to an old cache, `cache-hit` (used below)
# will be `false`. This allows us to restore the potentially out of
# date cache, but still let Playwright decide if it needs to download
# new binaries or not.
restore-keys: |
${{ runner.os }}-playwright-
# If the Playwright browser binaries weren't able to be restored, we tell
# paywright to install everything for us.
- name: Install Playwright with dependencies
if: steps.playwright-cache.outputs.cache-hit != 'true'
run: npx playwright install --with-deps
# If browser binaries are available we ask playwright to install os specific deps
# For example on linux it will install ffmpeg, xvfb, and many more libs
- name: Install Playwright's dependencies
if: steps.playwright-cache.outputs.cache-hit == 'true'
run: npx playwright install-deps
- name: Fix lightningcss windows
if: runner.os == 'Windows'
run: npm install lightningcss-win32-x64-msvc
## --- NPM INSTALL END --- ##
- name: Install certificate # needed for @jsenv/service-worker tests
if: runner.os == 'Linux' # https://docs.github.com/en/actions/learn-github-actions/contexts#runner-context
run: npm run https:setup
- name: Run package tests
run: npm run test:packages
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}