Skip to content

Commit 9757c0b

Browse files
authored
ci: use minified plugins if using minified core (#8870)
Co-authored-by: alxndrsn <alxndrsn>
1 parent 04e8271 commit 9757c0b

File tree

5 files changed

+27
-4
lines changed

5 files changed

+27
-4
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ jobs:
9191
- TYPE=mapreduce ADAPTERS=http npm test
9292
runs-on: ubuntu-latest
9393
env:
94-
POUCHDB_SRC: ../../packages/node_modules/pouchdb/dist/pouchdb.min.js
94+
USE_MINIFIED: 1
9595
CLIENT: ${{ matrix.client }}
9696
SERVER: couchdb-master
9797
COUCH_HOST: http://admin:password@127.0.0.1:5984
@@ -167,7 +167,7 @@ jobs:
167167
- TYPE=mapreduce npm test
168168
runs-on: ubuntu-latest
169169
env:
170-
POUCHDB_SRC: ../../packages/node_modules/pouchdb/dist/pouchdb.min.js
170+
USE_MINIFIED: 1
171171
CLIENT: ${{ matrix.client }}
172172
ADAPTERS: ${{ matrix.adapter }}
173173
steps:

TESTING.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,12 @@ This overrides the path used to load PouchDB in the browser. We use this in CI
122122
to select different builds of the PouchDB library, for example to test the
123123
minified version, the Webpack version, etc.
124124

125+
#### `USE_MINIFIED`
126+
127+
This changes the file extension used for loading PouchDB files in the browser.
128+
This can be used in CI and performance testing to select the minified version of
129+
PouchDB and its adapters, plugins, etc.
130+
125131
#### `SERVER` (default: `pouchdb-express-router`)
126132

127133
To support remote replication tests, we start a server in the background that
@@ -246,6 +252,7 @@ command-line options and their query string equivalents are:
246252
| `ITERATIONS` | `iterations` |
247253
| `PLUGINS` | `plugins` |
248254
| `POUCHDB_SRC` | `src` |
255+
| `USE_MINIFIED` | `useMinified` |
249256
| `VIEW_ADAPTERS` | `viewAdapters` |
250257

251258

bin/dev-server.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ if (process.env.COUCH_HOST) {
3232
if (process.env.ITERATIONS) {
3333
queryParams.iterations = process.env.ITERATIONS;
3434
}
35+
if (process.env.USE_MINIFIED) {
36+
queryParams.useMinified = process.env.USE_MINIFIED;
37+
}
3538

3639
var rebuildPromise = Promise.resolve();
3740

bin/test-browser.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ const qs = {
5252
SERVER: process.env.SERVER,
5353
SKIP_MIGRATION: process.env.SKIP_MIGRATION,
5454
src: process.env.POUCHDB_SRC,
55+
useMinified: process.env.USE_MINIFIED,
5556
plugins: process.env.PLUGINS,
5657
couchHost: process.env.COUCH_HOST,
5758
iterations: process.env.ITERATIONS,

tests/common-utils.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@ commonUtils.loadPouchDB = function (opts) {
8383

8484
commonUtils.loadPouchDBForNode = function (plugins) {
8585
var params = commonUtils.params();
86+
if (params.src || params.useMinified) {
87+
throw new Error('POUCHDB_SRC & USE_MINIFIED options cannot be used for node tests.');
88+
}
89+
8690
var scriptPath = '../packages/node_modules';
8791

8892
var pouchdbSrc = params.COVERAGE
@@ -99,18 +103,26 @@ commonUtils.loadPouchDBForNode = function (plugins) {
99103
return PouchDB;
100104
};
101105

106+
const srcExtension = () => {
107+
const params = commonUtils.params();
108+
return params.useMinified ? 'min.js' : 'js';
109+
};
110+
102111
commonUtils.pouchdbSrc = function () {
103112
const scriptPath = '../../packages/node_modules/pouchdb/dist';
104113
const params = commonUtils.params();
105-
return params.src || `${scriptPath}/pouchdb.js`;
114+
if (params.src && params.useMinified) {
115+
throw new Error('Cannot use POUCHDB_SRC and USE_MINIFIED options together.');
116+
}
117+
return params.src || `${scriptPath}/pouchdb.${srcExtension()}`;
106118
};
107119

108120
commonUtils.loadPouchDBForBrowser = function (plugins) {
109121
var scriptPath = '../../packages/node_modules/pouchdb/dist';
110122

111123
plugins = plugins.map((plugin) => {
112124
plugin = plugin.replace(/^pouchdb-(adapter-)?/, '');
113-
return `${scriptPath}/pouchdb.${plugin}.js`;
125+
return `${scriptPath}/pouchdb.${plugin}.${srcExtension()}`;
114126
});
115127

116128
var scripts = [commonUtils.pouchdbSrc()].concat(plugins);

0 commit comments

Comments
 (0)