Skip to content

Commit 3deef61

Browse files
SourceR85Steven-John Langegarethbowen
authored
Reduce ci overhead (#8866)
* reduce installation overhead * execute build before test * reduce pouchdb builds * rename install-deps to install-node-package * remove double-build in test-browser cases * update docs workflow * remove unnecessary pre-build in dev-server.js * remove extra pouchdb-server build step * Add descriptive comments to ci.yml * docs.yml: inline node version --------- Co-authored-by: Steven-John Lange <s.lange@hz-deutschland.de> Co-authored-by: Gareth Bowen <gareth@medic.org>
1 parent 6685203 commit 3deef61

File tree

9 files changed

+70
-37
lines changed

9 files changed

+70
-37
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
name: Build PouchDB
2+
description: Runs `npm run build`
3+
4+
runs:
5+
using: composite
6+
steps:
7+
- run: npm run build
8+
shell: bash
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Install CouchDB
2+
description: Intall CouchDB with the version specified in `inputs.couchdb-version`
3+
4+
inputs:
5+
couchdb-version:
6+
description: the version of CouchDB to install
7+
required: false
8+
default: '3.1'
9+
10+
runs:
11+
using: composite
12+
13+
steps:
14+
- uses: iamssen/couchdb-github-action@master
15+
with:
16+
couchdb-version: ${{ inputs.couchdb-version }}

.github/actions/install-deps/action.yml renamed to .github/actions/install-node-package/action.yml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
name: Install dependencies
2+
description: Install npm dependencies from package.json
23

34
inputs:
4-
node-version: { required: true }
5-
couchdb-version: { required: false, default: '3.1' }
5+
node-version:
6+
description: Specify the Node.js version to install
7+
required: true
68

79
runs:
810
using: composite
@@ -21,10 +23,3 @@ runs:
2123
2224
- run: npm install
2325
shell: bash
24-
25-
- uses: iamssen/couchdb-github-action@master
26-
with:
27-
couchdb-version: ${{ inputs.couchdb-version }}
28-
29-
- run: sudo npx playwright install-deps
30-
shell: bash
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name: Install Playwright
2+
description: Installs Playwright with system dependencies
3+
4+
runs:
5+
using: composite
6+
7+
steps:
8+
- run: sudo npx playwright install-deps
9+
shell: bash

.github/workflows/ci.yml

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,19 @@ env:
1919

2020
jobs:
2121

22+
# Check style compliance of JavaScript code.
23+
2224
lint:
2325
runs-on: ubuntu-latest
2426
steps:
2527
- uses: actions/checkout@v4
26-
- uses: ./.github/actions/install-deps
28+
- uses: ./.github/actions/install-node-package
2729
with:
2830
node-version: ${{ env.NODE_VERSION }}
2931
- run: npm run eslint
3032

33+
# Check shell scripts.
34+
3135
shellcheck:
3236
runs-on: ubuntu-latest
3337
steps:
@@ -58,10 +62,13 @@ jobs:
5862
SKIP_MIGRATION: 1
5963
steps:
6064
- uses: actions/checkout@v4
61-
- uses: ./.github/actions/install-deps
65+
- uses: ./.github/actions/install-node-package
6266
with:
6367
node-version: ${{ matrix.node }}
68+
- uses: ./.github/actions/install-couchdb
69+
with:
6470
couchdb-version: ${{ matrix.couchdb }}
71+
- uses: ./.github/actions/build-pouchdb
6572
- id: test
6673
run: ${{ matrix.cmd }}
6774
continue-on-error: true
@@ -98,10 +105,14 @@ jobs:
98105
SKIP_MIGRATION: 1
99106
steps:
100107
- uses: actions/checkout@v4
101-
- uses: ./.github/actions/install-deps
108+
- uses: ./.github/actions/install-node-package
102109
with:
103110
node-version: ${{ env.NODE_VERSION }}
111+
- uses: ./.github/actions/install-playwright
112+
- uses: ./.github/actions/install-couchdb
113+
with:
104114
couchdb-version: ${{ matrix.couchdb }}
115+
- uses: ./.github/actions/build-pouchdb
105116
- id: test
106117
run: ${{ matrix.cmd }}
107118
continue-on-error: true
@@ -135,9 +146,10 @@ jobs:
135146
ADAPTERS: ${{ matrix.adapter }}
136147
steps:
137148
- uses: actions/checkout@v4
138-
- uses: ./.github/actions/install-deps
149+
- uses: ./.github/actions/install-node-package
139150
with:
140151
node-version: ${{ matrix.node }}
152+
- uses: ./.github/actions/build-pouchdb
141153
- id: test
142154
run: ${{ matrix.cmd }}
143155
continue-on-error: true
@@ -172,9 +184,11 @@ jobs:
172184
ADAPTERS: ${{ matrix.adapter }}
173185
steps:
174186
- uses: actions/checkout@v4
175-
- uses: ./.github/actions/install-deps
187+
- uses: ./.github/actions/install-node-package
176188
with:
177189
node-version: ${{ env.NODE_VERSION }}
190+
- uses: ./.github/actions/install-playwright
191+
- uses: ./.github/actions/build-pouchdb
178192
- id: test
179193
run: ${{ matrix.cmd }}
180194
continue-on-error: true
@@ -209,9 +223,12 @@ jobs:
209223
SERVER: pouchdb-server
210224
steps:
211225
- uses: actions/checkout@v4
212-
- uses: ./.github/actions/install-deps
226+
- uses: ./.github/actions/install-node-package
213227
with:
214228
node-version: ${{ env.NODE_VERSION }}
229+
- if: ${{ matrix.client != 'node' }}
230+
uses: ./.github/actions/install-playwright
231+
- uses: ./.github/actions/build-pouchdb
215232
- id: test
216233
run: ${{ matrix.cmd }}
217234
continue-on-error: true
@@ -245,9 +262,10 @@ jobs:
245262
runs-on: ubuntu-latest
246263
steps:
247264
- uses: actions/checkout@v4
248-
- uses: ./.github/actions/install-deps
265+
- uses: ./.github/actions/install-node-package
249266
with:
250267
node-version: ${{ matrix.node }}
268+
- uses: ./.github/actions/build-pouchdb
251269
- id: test
252270
run: ${{ matrix.cmd }}
253271
continue-on-error: true

.github/workflows/docs.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ jobs:
2020
steps:
2121
- name: Checkout
2222
uses: actions/checkout@v4
23-
- uses: ./.github/actions/install-deps
23+
- uses: ./.github/actions/install-node-package
24+
with:
25+
node-version: 14
2426
- uses: ruby/setup-ruby@v1
2527
with:
2628
ruby-version: 2.7

bin/dev-server.js

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -85,23 +85,6 @@ function watchAll() {
8585
debounce(rebuildPerf, 700, {leading: true}));
8686
}
8787

88-
var filesWritten = false;
89-
90-
Promise.resolve().then(function () {
91-
if (process.env.CI || process.env.NO_REBUILD) {
92-
return; // don't bother rebuilding in CI; we already built
93-
}
94-
return Promise.all([
95-
rebuildPouch(),
96-
rebuildTestUtils(),
97-
rebuildPerf()
98-
]);
99-
}).then(function () {
100-
console.log('Rebuilt PouchDB/test/perf JS bundles');
101-
filesWritten = true;
102-
checkReady();
103-
});
104-
10588
var HTTP_PORT = 8000;
10689

10790
var serversStarted;
@@ -122,7 +105,7 @@ function startServers(callback) {
122105
}
123106

124107
function checkReady() {
125-
if (filesWritten && serversStarted && readyCallback) {
108+
if (serversStarted && readyCallback) {
126109
readyCallback();
127110
}
128111
}

bin/run-dev.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
#!/bin/bash -e
22

3+
node ./bin/build-pouchdb.js
4+
npm run build-test
35
CLIENT=dev ./bin/run-test.sh

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212
"test-node": "./bin/test-node.sh",
1313
"test-component": "mocha --exit tests/component # --exit for #8839",
1414
"test-fuzzy": "TYPE=fuzzy npm run test",
15-
"test-browser": "npm run build-test && node ./bin/test-browser.js",
15+
"test-browser": "node ./bin/test-browser.js",
1616
"test-memleak": "mocha -gc tests/memleak",
1717
"eslint": "eslint --cache bin/ packages/node_modules/**/src tests/",
1818
"dev": "./bin/run-dev.sh",
1919
"launch-dev-server": "node ./bin/dev-server.js",
2020
"test": "./bin/run-test.sh",
21-
"prepublish": "npm run build",
21+
"prepublishOnly": "npm run build",
2222
"release": "./bin/release.sh",
2323
"install-jekyll": "./bin/install-jekyll.sh",
2424
"publish-site": "./bin/publish-site.sh",

0 commit comments

Comments
 (0)