Skip to content

Commit

Permalink
Merge branch 'v6' into workbox-webpack-plugin-ts
Browse files Browse the repository at this point in the history
  • Loading branch information
tropicadri committed Dec 23, 2021
2 parents e4f9032 + 48f53f7 commit 8a5ee86
Show file tree
Hide file tree
Showing 248 changed files with 5,952 additions and 3,820 deletions.
5 changes: 1 addition & 4 deletions .github/PULL_REQUEST_TEMPLATE.md
@@ -1,7 +1,4 @@
**Prior to filing a PR, please:**

- [open an issue](https://github.com/GoogleChrome/workbox/issues/new) to discuss your proposed change.
- ensure that `gulp build && gulp lint test` passes locally.
**Prior to creating a pull request, please follow all the steps in the [contributing guide](https://github.com/GoogleChrome/workbox/blob/v6/CONTRIBUTING.md).**

R: @jeffposnick @tropicadri

Expand Down
28 changes: 16 additions & 12 deletions .github/workflows/pull-request.yml
Expand Up @@ -9,17 +9,21 @@ jobs:
steps:
- uses: actions/checkout@v2

- uses: actions/cache@v1
- uses: actions/setup-node@v1
with:
path: ~/.npm
node-version: 10.x

- name: Get npm cache directory
id: npm-cache
run: |
echo "::set-output name=dir::$(npm config get cache)"
- uses: actions/cache@v2
with:
path: ${{ steps.npm-cache.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- uses: actions/setup-node@v1
with:
node-version: 10.x

- name: Setup
run: |
npm ci
Expand All @@ -33,22 +37,22 @@ jobs:
steps:
- uses: actions/checkout@v2

- uses: actions/cache@v1
- uses: actions/setup-node@v1
with:
node-version: 12.x

- uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- uses: actions/cache@v1
- uses: actions/cache@v2
with:
path: ~/.selenium-assistant
key: ${{ runner.os }}

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

- name: Setup
run: |
sudo safaridriver --enable
Expand Down
1 change: 1 addition & 0 deletions .husky/.gitignore
@@ -0,0 +1 @@
_
6 changes: 5 additions & 1 deletion .husky/pre-commit
@@ -1,4 +1,8 @@
#!/bin/sh

# Please see https://typicode.github.io/husky/#/?id=command-not-found
# if you have trouble running this command.

. "$(dirname "$0")/_/husky.sh"

npm run format-staged
npm run lint-staged
4 changes: 4 additions & 0 deletions .husky/pre-push
@@ -1,4 +1,8 @@
#!/bin/sh

# Please see https://typicode.github.io/husky/#/?id=command-not-found
# if you have trouble running this command.

. "$(dirname "$0")/_/husky.sh"

npm run lint
8 changes: 6 additions & 2 deletions .prettierignore
@@ -1,3 +1,4 @@
_version.ts
.nyc_output
.vscode
*.hbs
Expand All @@ -7,7 +8,10 @@ coverage
docs
generated-release-files
node_modules
packages/**
!packages/*/src/**
package-lock.json
packages/**/*.d.ts
packages/**/*.js
packages/**/*.mjs
packages/workbox-build/src/schema/*.json
temp
test/workbox-webpack-plugin/static/injected-manifest.json
44 changes: 34 additions & 10 deletions CONTRIBUTING.md
Expand Up @@ -17,30 +17,54 @@ accept your pull requests.
1. Submit an issue describing your proposed change to the repo in question.
1. The repo owner will respond to your issue promptly.
1. If your proposed change is accepted, and you haven't already done so, sign a Contributor License Agreement (see details above).
1. Fork the repo, develop and test your code changes.
1. Fork the repo, develop and test your code changes (see details below).
1. Ensure that your code adheres to the existing style in the sample to which you are contributing.
1. Submit a pull request.

## Running the Test Suite
## Setting up your environment

Workbox's test suite is split in two parts, one for the Node-based tooling (workbox-cli, workbox-webpack-plugin, etc.) and one for the browser-based ServiceWorker code.
Workbox uses [`node`](https://nodejs.org/) and its related toolchain (`npm`, etc.) to install dependencies and run the build and test processes. Please ensure that you have a working `node` installation before proceeding.

To run the tests for the Node-based tooling:
Workbox uses `git` hooks via [`husky`](https://typicode.github.io/husky/#/) to automatically run code formatters and linters when committing and pushing code to GitHub. If you're running into issues with the `git` hooks, you may need to [create a `~/.huskyrc` file](https://typicode.github.io/husky/#/?id=command-not-found) to set up your `$PATH` correctly.

It's expected that the Workbox development environment should work on Windows, macOS, and Linux. If you encounter any platform-specific issues, please [open a bug](https://github.com/GoogleChrome/workbox/issues/new).

## Testing your contribution

When making local changes, you'll probably want to ensure that your code builds and passes our test suite. To do this, run the following in your local clone of the repo:

```sh
$ npm ci

$ npm run gulp build

$ npm run gulp test
```

Note that on Windows, `npm run gulp test` will only run a subset of our test suite. The full test suite will always be run as part of the GitHub continuous integration environment against your pull request.

When you add a new feature or fix a bug, please check the test suite to see if its appropriate to add or modify an existing test to cover the updated functionality.

## Running a subset of the tests

Workbox's test suite is split in two parts: one for the `node`-based tooling (`workbox-cli`, `workbox-build`, `workbox-webpack-plugin`) and one for the browser-based code.

To run the tests for just the `node`-based tooling:

```sh
npm run gulp test_node
```

To interactively run tests for the browser-based code, launch the test server:

```
```sh
npm run gulp test_server
```

Then open your web browser to http://localhost:3004/ and browser for the test suite for the workbox package you're interested in. For example, to run the tests for workbox-strategies, go o http://localhost:3004/test/workbox-streams/sw/.
Then open a web browser to http://localhost:3004/ and navigate to the test suite for the package you're interested in. For example, to run the tests for `workbox-strategies`, go to http://localhost:3004/test/workbox-streams/sw/

To do an automated run of the full test suite for the browser-based code against the full set of supported browsers:
To do an automated run of the browser-based test suite against the full set of supported browsers, run:

```
npm run gulp test_integration
```
````sh
npm run gulp test_integration ```
````
3 changes: 2 additions & 1 deletion README.md
Expand Up @@ -16,7 +16,8 @@ Workbox is a collection of JavaScript libraries for
Development happens in the open on GitHub. We're thankful to the community for
contributing any improvements.

Please read the [guide to contributing](CONTRIBUTING.md) prior to filing any
Please read the [guide to contributing](CONTRIBUTING.md) for information about
setting up your environment and other requirements prior to filing any
pull requests.

## License
Expand Down
21 changes: 15 additions & 6 deletions gulp-tasks/publish-cdn.js
Expand Up @@ -57,12 +57,21 @@ async function handleCDNUpload(tagName, gitBranch) {
}

async function publish_cdn() {
// Get all of the tags in the repo.
const tags = await githubHelper.getTags();
const missingTags = await findMissingCDNTags(tags);

if (missingTags.length === 0) {
logHelper.log('No tags missing from CDN.');
let missingTags = [];

// Usage: npx gulp publish_cdn --cdnTag=vX.Y.Z
// See https://github.com/GoogleChrome/workbox/issues/2479
if (global.cliOptions.cdnTag) {
const tags = [{name: global.cliOptions.cdnTag}];
missingTags = await findMissingCDNTags(tags);
} else {
// Get all of the tags in the repo.
const tags = await githubHelper.getTags();
missingTags = await findMissingCDNTags(tags);

if (missingTags.length === 0) {
logHelper.log('No tags missing from CDN.');
}
}

for (const missingTag of missingTags) {
Expand Down
2 changes: 2 additions & 0 deletions gulp-tasks/publish.js
Expand Up @@ -11,6 +11,7 @@ const execa = require('execa');
const fse = require('fs-extra');
const ol = require('common-tags').oneLine;

const {build} = require('./build');
const {build_packages_clean} = require('./build-packages');
const {publish_cdn} = require('./publish-cdn');
const {publish_github} = require('./publish-github');
Expand Down Expand Up @@ -39,6 +40,7 @@ module.exports = {
publish_sign_in_check,
build_packages_clean,
publish_clean,
build,
test,
publish_lerna,
publish_github,
Expand Down
46 changes: 46 additions & 0 deletions infra/testing/server/cross-origin-server.js
@@ -0,0 +1,46 @@
/*
Copyright 2021 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/

const express = require('express');

const PORT = 3010;

let app;
let server;

function initApp(staticDir) {
app = express();
app.use(express.static(staticDir));
}

function start(staticDir) {
if (!app) {
initApp(staticDir);
}

return new Promise((resolve, reject) => {
server = app.listen(PORT, (error) => {
if (error) {
reject(error);
} else {
resolve(`http://localhost:${PORT}`);
}
});
});
}

function stop() {
if (server) {
server.close();
}
}

module.exports = {
start,
stop,
};
2 changes: 1 addition & 1 deletion infra/testing/validator/service-worker-runtime.js
Expand Up @@ -136,7 +136,7 @@ function setupSpiesAndContextForGenerateSW() {
const context = Object.assign(
{
importScripts,
define: (_, scripts, callback) => {
define: (scripts, callback) => {
importScripts(...scripts);
callback(workboxContext);
},
Expand Down
6 changes: 4 additions & 2 deletions lerna.json
@@ -1,5 +1,7 @@
{
"lerna": "3.4.0",
"packages": ["packages/*"],
"version": "6.2.4"
"packages": [
"packages/*"
],
"version": "6.4.2"
}

0 comments on commit 8a5ee86

Please sign in to comment.