Skip to content

move

move #1

Workflow file for this run

name: Test Polyfills
on:
pull_request:
repository_dispatch:
types: [ok-to-test-command]
concurrency:
group: browserstack
cancel-in-progress: false
jobs:
# Branch-based pull request
integration-trusted:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
strategy:
max-parallel: 1
fail-fast: false
matrix:
browser: [ ie, android, chrome, edge, firefox, ios, safari ]
steps:
- name: Branch based PR checkout
uses: actions/checkout@v2
with:
fetch-depth: 50
# Fetch master branch to determine which polyfills have changed and need testing.
- name: Fetch upstream to determine diff
run: |
git remote add upstream https://github.com/mrhenry/polyfill-library.git
git fetch --depth=50 upstream master
# <insert integration tests needing secrets>
- uses: actions/setup-node@v2.2.0
with:
node-version: 16.x
cache: 'npm'
- name: env
run: echo "commit-sha=$(echo ${GITHUB_SHA})" >> $GITHUB_ENV
- run: npm ci
- name: cache __dist
id: cache-dist
uses: actions/cache@v2.1.5
with:
path: polyfills/__dist
key: cache--dist--${{ env.commit-sha }}
- run: npm run build
if: steps.cache-dist.outputs.cache-hit != 'true'
- name: Test ${{ matrix.browser }}
run: node ./test/polyfills/server.js & node ./test/polyfills/remotetest.js
test-modified-only targeted director browser=${{ matrix.browser }}
timeout-minutes: 30
env:
BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }}
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
# Repo owner has commented /ok-to-test on a (fork-based) pull request
integration-fork:
runs-on: ubuntu-latest
if:
github.event_name == 'repository_dispatch' &&
github.event.client_payload.slash_command.sha != '' &&
contains(github.event.client_payload.pull_request.head.sha, github.event.client_payload.slash_command.sha)
strategy:
max-parallel: 1
fail-fast: false
matrix:
browser: [ ie, android, chrome, edge, firefox, ios, safari ]
steps:
# Check out merge commit
- name: Fork based /ok-to-test checkout
uses: actions/checkout@v2
with:
ref: 'refs/pull/${{ github.event.client_payload.pull_request.number }}/merge'
fetch-depth: 50
# Fetch master branch to determine which polyfills have changed and need testing.
- name: Fetch upstream to determine diff
run: |
git remote add upstream https://github.com/mrhenry/polyfill-library.git
git fetch --depth=50 upstream master
# <insert integration tests needing secrets>
- uses: actions/setup-node@v2.2.0
with:
node-version: 16.x
cache: 'npm'
- name: env
run: echo "commit-sha=${{github.event.client_payload.slash_command.sha}}" >> $GITHUB_ENV
- run: npm ci
- name: cache __dist
id: cache-dist
uses: actions/cache@v2.1.5
with:
path: polyfills/__dist
key: cache--dist--${{ env.commit-sha }}
- run: npm run build
if: steps.cache-dist.outputs.cache-hit != 'true'
- name: Test ${{ matrix.browser }}
run: node ./test/polyfills/server.js & node ./test/polyfills/remotetest.js
test-modified-only targeted director browser=${{ matrix.browser }}
timeout-minutes: 30
env:
BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }}
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
update-check-fork:
needs: [integration-fork]
runs-on: ubuntu-latest
if: ${{ always() }}
steps:
# Update check run called "test-polyfills"
- uses: actions/github-script@v1
id: update-check-run
if: needs.integration-fork.result != 'skipped'
env:
number: ${{ github.event.client_payload.pull_request.number }}
job: ${{ github.job }}
# Conveniently, job.status maps to https://developer.github.com/v3/checks/runs/#update-a-check-run
conclusion: ${{ needs.integration-fork.result }}
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { data: pull } = await github.pulls.get({
...context.repo,
pull_number: process.env.number
});
const ref = pull.head.sha;
const { data: checks } = await github.checks.listForRef({
...context.repo,
ref
});
const check = checks.check_runs.filter(c => c.name === process.env.job);
const { data: result } = await github.checks.update({
...context.repo,
check_run_id: check[0].id,
status: 'completed',
conclusion: process.env.conclusion
});
return result;