chore: build churn #311
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: BrowserStack Tests | |
on: | |
pull_request_target: | |
branches: | |
- 'main' | |
- 'v3.0.0-dev' | |
push: | |
branches: | |
- 'main' | |
- 'v3.0.0-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-20.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@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 | |
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@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0 | |
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 | |
run: 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 |