Skip to content

Commit

Permalink
Merge pull request #6 from mrhenry/more-cleanup--generous-lionfish-37…
Browse files Browse the repository at this point in the history
…a13114d8

more cleanup
  • Loading branch information
romainmenke authored Feb 27, 2024
2 parents 812ee5e + 29732f6 commit 2d8913a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 166 deletions.
61 changes: 0 additions & 61 deletions .github/workflows/test-from-fork.yml

This file was deleted.

100 changes: 2 additions & 98 deletions .github/workflows/test-polyfills.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
name: Test Polyfills
on:
pull_request:
repository_dispatch:
types: [ok-to-test-command]
workflow_dispatch:

concurrency:
group: browserstack
cancel-in-progress: false

jobs:
# Branch-based pull request
integration-trusted:
test:
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
Expand Down Expand Up @@ -59,97 +57,3 @@ jobs:
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;
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@

# Polyfill-library &middot; [![license][license-badge]][license] [![PRs Welcome][pull-requests-badge]][contributing-guide]
# @mhrenry/polyfill-library &middot; [![license][license-badge]][license] [![PRs Welcome][pull-requests-badge]][contributing-guide]

> NodeJS module to create polyfill bundles tailored to individual user-agents
## Install

```bash
npm install polyfill-library --save
npm install @mrhenry/polyfill-library --save
```

## Usage

```javascript
const polyfillLibrary = require('polyfill-library');
const polyfillLibrary = require('@mrhenry/polyfill-library');

const polyfillBundle = polyfillLibrary.getPolyfillString({
uaString: 'Mozilla/5.0 (Windows; U; MSIE 7.0; Windows NT 6.0; en-US)',
Expand Down Expand Up @@ -86,7 +86,7 @@ Returns a polyfill bundle as either a utf-8 ReadStream or as a Promise of a utf-

## AWS Lambda

To use this package in an AWS Lambda function, you need to include the distribution Polyfills located in `./node_modules/polyfill-library/polyfills/__dist` in the root directory of your Lambda. In AWS, Lambdas are executed in the `/var/task/...` directory. Therefore, during execution, the directory where the polyfills will be located will be `/var/task/polyfill-library/__dist`.
To use this package in an AWS Lambda function, you need to include the distribution Polyfills located in `./node_modules/@mrhenry/polyfill-library/polyfills/__dist` in the root directory of your Lambda. In AWS, Lambdas are executed in the `/var/task/...` directory. Therefore, during execution, the directory where the polyfills will be located will be `/var/task/@mrhenry/polyfill-library/__dist`.

### Example of a script to copy files

Expand All @@ -104,7 +104,7 @@ In the example, we will use the directory `./.serverless_nextjs/api-lambda`, whi
import { copySync } from 'fs-extra/esm';
import makeDir from 'make-dir';

const DIR_POLYFILLS = './node_modules/polyfill-library/polyfills/__dist';
const DIR_POLYFILLS = './node_modules/@mrhenry/polyfill-library/polyfills/__dist';
// const DIR_SERVERLESS = 'YOUR_BUNDELED_LAMBDA_DIRECTORY/polyfills/__dist';
const DIR_SERVERLESS = './.serverless_nextjs/api-lambda/polyfills/__dist';

Expand All @@ -128,7 +128,7 @@ node ./scripts/polyfills-serverless.mjs

## Contributing

Development of polyfill-library happens on GitHub. Read below to learn how you can take part in contributing.
Development of @mrhenry/polyfill-library happens on GitHub. Read below to learn how you can take part in contributing.

### [Contributing Guide][contributing-guide]

Expand All @@ -144,7 +144,7 @@ npm run test-polyfills -- --features=Array.from --browserstack # Run the tests f

### License

Polyfill-library is [MIT licensed][license].
@mrhenry/polyfill-library is [MIT licensed][license].

[contributing-guide]: https://github.com/mrhenry/polyfill-library/blob/main/.github/contributing.md
[license]: https://github.com/mrhenry/polyfill-library/blob/main/LICENSE.md
Expand Down

0 comments on commit 2d8913a

Please sign in to comment.