Skip to content

feat(test): jest 29 support #5863

feat(test): jest 29 support

feat(test): jest 29 support #5863

name: BrowserStack Tests
on:
merge_group:
pull_request_target:
branches:
- 'main'
- 'v3.*-feature'
- 'stencil/v4-dev'
push:
branches:
- 'main'
- 'stencil/v4-dev'
env:
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSER_STACK_ACCESS_KEY }}
BROWSERSTACK_USERNAME: ${{ secrets.BROWSER_STACK_USERNAME }}
permissions: read-all
# this workflow splits running Browserstack tests into two jobs:
# - one to build stencil for Browserstack
# - one to build the test applications & invoke Browserstack
#
# doing so allows us to balance a few different considerations when running against Browserstack:
# 1. Rerunning Failed Jobs
# Creating a separate job for running Browserstack on its own allows us to 'rerun failed jobs' in the GitHub UI,
# only for the Browserstack tests themselves.
# This allows for a quicker feedback loop in the event of flaky jobs
# 2. Secret Security
# In order to authenticate against Browserstack, an access key and username are required
# In order to minimize their access/usage elsewhere, we contain them to the workflow that is this file
#
# These items do come at a cost of some repeated steps in the jobs below (checking out code, installing dependencies,
# etc.)
jobs:
build_core:
name: Build for Browserstack
uses: ./.github/workflows/build.yml
run_browserstack:
name: Run Browserstack
runs-on: ubuntu-22.04
needs: [build_core]
# The concurrency field allows us to block multiple invocations of this job across multiple workflow runs.
# Stencil is only able to run 5 parallel tests in Browserstack, which is exceeded when more than one run of this
# workflow occurs - e.g. more than one pull request is submitted in proximity, a pull request and a merge to a
# branch that runs this workflow, etc.
#
# At this time, Karma is unable to properly wait for the queued Browserstack tests to finish. Instead, use the
# GitHub Actions 'concurrency' field as means to block the job until no other tests are running.
concurrency: run_browserstack_queue
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
ref: ${{ github.event_name == 'pull_request_target' && format('refs/pull/{0}/merge', github.event.number) || '' }}
persist-credentials: false
- name: Use Node Version from Volta (Karma)
uses: actions/setup-node@1a4442cacd436585916779262731d5b162bc6ec7 # v3.8.2
with:
# pull the version to use from the volta key in package.json
node-version-file: './test/karma/package.json'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Download Build Archive
uses: ./.github/workflows/actions/download-archive
with:
name: stencil-core
path: .
filename: stencil-core-build.zip
- name: BrowserStack Env Setup
uses: 'browserstack/github-actions/setup-env@master'
with:
username: ${{ env.BROWSERSTACK_USERNAME }}
access-key: ${{ env.BROWSERSTACK_ACCESS_KEY }}
project-name: 'stencil_core'
- name: Start BrowserStack
uses: browserstack/github-actions/setup-local@master
with:
# local-testing must be one of two values: 'start' or 'stop' to start/stop Browserstack
local-testing: start
# generates a random identifier for the Browserstack connection.
# otherwise, an identifier collision could cause connections to fail.
local-identifier: random
- name: Run Karma Tests
uses: nick-fields/retry@14672906e672a08bd6eeb15720e9ed3ce869cdd4 # v2.9.0
with:
timeout_minutes: 15
max_attempts: 3
command: npm run test.karma.prod
- name: Stop BrowserStack
uses: browserstack/github-actions/setup-local@master
with:
# local-testing must be one of two values: 'start' or 'stop' to start/stop Browserstack
local-testing: stop
- name: Check Git Context
uses: ./.github/workflows/actions/check-git-context