Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

partial tests in ci #997

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions .github/workflows/test-polyfills-weekly.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Test Polyfills
on:
schedule:
- cron: '0 23 * * 0' # TODO : set convenient weekly retest time
workflow_dispatch:

jobs:
check-for-other-pull-requests-running-this-workflow:
runs-on: ubuntu-latest
if: ${{ github.pull_request.head.repo.fork == false}}
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@3d86a7cc43670094ac248017207be0295edbc31d # pin@0.8.0
with:
access_token: ${{ github.token }}
- name: Turnstyle
uses: softprops/turnstyle@a714535c65d622af7010e609960ccf0ea5001e3f # pin@v1
with:
same-branch-only: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
test:
runs-on: ubuntu-latest
needs: [ check-for-other-pull-requests-running-this-workflow ]
strategy:
max-parallel: 1
fail-fast: false
matrix:
browser: [ ie, android, chrome, edge, firefox, ios, safari ]

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 1


- uses: actions/setup-node@v2.1.4
with:
node-version: 12.x

- 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.4
with:
path: polyfills/__dist
key: cache--dist--${{ env.commit-sha }}

- run: npm run build
if: steps.cache-dist.outputs.cache-hit != 'true'

- run: echo "${{ matrix.browser }}" > $GITHUB_WORKSPACE/witness-${{ matrix.browser }}
- name: record ${{ matrix.browser }} witness
id: witness
uses: actions/cache@v2.1.4
with:
path: $GITHUB_WORKSPACE/witness-${{ matrix.browser }}
key: witness--weekly-tests--${{ matrix.browser }}--${{ env.commit-sha }}

- name: Test ${{ matrix.browser }}
run: node ./test/polyfills/server.js & node ./test/polyfills/remotetest.js
test-polyfill-combinations targeted director browser=${{ matrix.browser }}
if: steps.witness.outputs.cache-hit != 'true'
timeout-minutes: 30
env:
BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }}
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
8 changes: 7 additions & 1 deletion .github/workflows/test-polyfills.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ jobs:

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- run: git remote add upstream https://github.com/Financial-Times/polyfill-library.git
- run: git fetch upstream master

- uses: actions/setup-node@v2.1.4
with:
node-version: 12.x
Expand Down Expand Up @@ -61,7 +67,7 @@ jobs:

- name: Test ${{ matrix.browser }}
run: node ./test/polyfills/server.js & node ./test/polyfills/remotetest.js
targeted director browser=${{ matrix.browser }}
test-modified-only targeted director browser=${{ matrix.browser }}
if: steps.witness.outputs.cache-hit != 'true'
timeout-minutes: 30
env:
Expand Down
179 changes: 179 additions & 0 deletions test/node/utils/test-modified-polyfills-with-tests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@

'use strict';
const assert = require('proclaim');
const { polyfillsWithTestsFrom } = require('../../utils/modified-polyfills-with-tests');


describe("polyfills subset for tests based on git changes", function () {
it("should test everything on non-polyfill changes", async () => {
const modified = await polyfillsWithTestsFrom(['foo'], ['a.polyfill'], { 'a.polyfill': {} });
assert.ok(modified.testEverything);
});

it("should test everything on non-polyfill changes in the polyfill directory", async () => {
const modified = await polyfillsWithTestsFrom(['polyfills/foo'], ['a.polyfill'], { 'a.polyfill': {} });
assert.ok(modified.testEverything);
});

it("should test everything if a polyfill was deleted", async () => {
const modified = await polyfillsWithTestsFrom(['polyfills/a/polyfill'], ['b.polyfill'], { 'b.polyfill': {} });
assert.ok(modified.testEverything);
});

it("should test a subset on a small change in polyfills directory", async () => {
const modified = await polyfillsWithTestsFrom(
['polyfills/a/polyfill/polyfill.js'],
['a.polyfill', 'b.polyfill'],
{
'a.polyfill': {
hasTests: true,
},
'b.polyfill': {
hasTests: true,
}
}
);

assert.ok(!modified.testEverything);

assert.deepEqual(modified.polyfills, {
'a.polyfill': {
hasTests: true,
}
});

assert.deepEqual(modified.affectedPolyfills, {
'a.polyfill': {
hasTests: true,
}
});
});

it("should include polyfill dependants", async () => {
const modified = await polyfillsWithTestsFrom(
['polyfills/a/polyfill/polyfill.js'],
['a.polyfill', 'b.polyfill'],
{
'a.polyfill': {
hasTests: true
},
'b.polyfill': {
hasTests: true,
dependencies: ['a.polyfill']
}
}
);

assert.ok(!modified.testEverything);

assert.deepEqual(modified.polyfills, {
'a.polyfill': {
hasTests: true,
}
});

assert.deepEqual(modified.affectedPolyfills, {
'a.polyfill': {
hasTests: true
},
'b.polyfill': {
hasTests: true,
dependencies: ['a.polyfill']
}
});
});

it("should include polyfill dependants, even when the graph has gaps in tests", async () => {
const modified = await polyfillsWithTestsFrom(
['polyfills/a/polyfill/polyfill.js'],
['a.polyfill', 'b.polyfill', 'c.polyfill'],
{
'a.polyfill': {
hasTests: true
},
'b.polyfill': {
hasTests: false,
dependencies: ['a.polyfill']
},
'c.polyfill': {
hasTests: true,
dependencies: ['b.polyfill']
}
}
);

assert.ok(!modified.testEverything);

assert.deepEqual(modified.polyfills, {
'a.polyfill': {
hasTests: true,
}
});

assert.deepEqual(modified.affectedPolyfills, {
'a.polyfill': {
hasTests: true
},
'c.polyfill': {
hasTests: true,
dependencies: ['b.polyfill']
}
});
});

it("should skip polyfills without tests", async () => {
const modified = await polyfillsWithTestsFrom(
['polyfills/a/polyfill/polyfill.js'],
['a.polyfill', 'b.polyfill'],
{
'a.polyfill': {
hasTests: false,
},
'b.polyfill': {
hasTests: true,
}
}
);

assert.ok(modified.testEverything);

assert.deepEqual(modified.polyfills, {
'a.polyfill': {
hasTests: false,
}
});

assert.deepEqual(modified.affectedPolyfills, {});
});

it("should skip polyfills without tests but include it's dependants", async () => {
const modified = await polyfillsWithTestsFrom(
['polyfills/a/polyfill/polyfill.js'],
['a.polyfill', 'b.polyfill'],
{
'a.polyfill': {
hasTests: false
},
'b.polyfill': {
hasTests: true,
dependencies: ['a.polyfill']
}
}
);

assert.ok(!modified.testEverything);

assert.deepEqual(modified.polyfills, {
'a.polyfill': {
hasTests: false,
}
});

assert.deepEqual(modified.affectedPolyfills, {
'b.polyfill': {
hasTests: true,
dependencies: ['a.polyfill']
}
});
});
});
Loading