Skip to content

Commit

Permalink
Enable Windows tests on GH Actions (#2391)
Browse files Browse the repository at this point in the history
* Enable Windows CI

* WIP

* Move to chaiMatchPattern

* Linting

* More Windows tweaks

* globby changes

* Just run test-node

* gulp build
  • Loading branch information
jeffposnick authored Mar 3, 2020
1 parent ce30f36 commit 880d64d
Show file tree
Hide file tree
Showing 9 changed files with 555 additions and 494 deletions.
34 changes: 19 additions & 15 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,29 @@ name: Test Suite
on: [pull_request]

jobs:
# Node_Tests_Windows:
# runs-on: windows-latest
Node_Tests_Windows:
runs-on: windows-latest

# steps:
# - uses: actions/checkout@v2
steps:
- uses: actions/checkout@v2

# - uses: actions/cache@v1
# with:
# path: ~/.npm
# key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
# restore-keys: |
# ${{ runner.os }}-node-
- uses: actions/cache@v1
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
# - uses: actions/setup-node@v1
# with:
# node-version: 13.x
- uses: actions/setup-node@v1
with:
node-version: 13.x

- name: Setup
run: |
npm ci
gulp build
# - run: npm ci
# - run: npx gulp test
- run: npx gulp test-node

Full_Suite_Mac:
runs-on: macos-latest
Expand Down
46 changes: 6 additions & 40 deletions infra/testing/validator/service-worker-runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,42 +7,21 @@
*/

const assert = require('assert');
const expect = require('chai').expect;
const chai = require('chai');
const chaiMatchPattern = require('chai-match-pattern');
const fse = require('fs-extra');
const makeServiceWorkerEnv = require('service-worker-mock');
const sinon = require('sinon');
const vm = require('vm');

chai.use(chaiMatchPattern);
const {expect} = chai;

// See https://github.com/chaijs/chai/issues/697
function stringifyFunctionsInArray(arr) {
return arr.map((item) => typeof item === 'function' ? item.toString() : item);
}

function validatePrecacheAndRoute({actual, expected}) {
for (const call of actual) {
for (const manifestEntry of call[0]) {
if (/[0-9a-f]{32}/.test(manifestEntry.revision)) {
manifestEntry.revision = '32_CHARACTER_HASH';
}

if (manifestEntry.url) {
manifestEntry.url = manifestEntry.url.replace(/[0-9a-f]{20}/, '20_CHARACTER_HASH');
}
}
}

expect(actual).to.deep.equal(expected);
}

function validateImportScripts({actual, expected}) {
for (let i = 0; i < actual.length; i++) {
actual[i] = actual[i].map((script) => script.replace(/[0-9a-f]{20}/, '20_CHARACTER_HASH'));
actual[i] = actual[i].map((script) => script.replace(/[0-9a-f]{8}/, '8_CHARACTER_HASH'));
}

expect(actual).to.deep.equal(expected);
}

function setupSpiesAndContextForInjectManifest() {
const cacheableResponsePluginSpy = sinon.spy();
class CacheableResponsePlugin {
Expand Down Expand Up @@ -166,20 +145,7 @@ function validateMethodCalls({methodsToSpies, expectedMethodCalls, context}) {
const args = spy.args.map(
(arg) => Array.isArray(arg) ? stringifyFunctionsInArray(arg) : arg);

if (method === 'precacheAndRoute') {
validatePrecacheAndRoute({
actual: args,
expected: expectedMethodCalls.precacheAndRoute,
});
} else if (method === 'importScripts') {
validateImportScripts({
actual: args,
expected: expectedMethodCalls.importScripts,
});
} else {
expect(args).to.deep.equal(expectedMethodCalls[method],
`while testing method calls for ${method}`);
}
expect(args).to.matchPattern(expectedMethodCalls[method]);
} else {
expect(expectedMethodCalls[method],
`while testing method calls for ${method}`).to.be.undefined;
Expand Down
53 changes: 53 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
"bytes": "^3.1.0",
"camelcase": "^5.3.1",
"chai": "^4.2.0",
"chai-match-pattern": "^1.1.0",
"chalk": "^3.0.0",
"clear-require": "^3.0.0",
"comlinkjs": "^3.2.0",
Expand Down
Loading

0 comments on commit 880d64d

Please sign in to comment.