Skip to content

Commit

Permalink
Merge branch 'master' into remove-dev-dep-mkdirp
Browse files Browse the repository at this point in the history
  • Loading branch information
alxndrsn committed Jan 9, 2025
2 parents ffc94b7 + 8f38843 commit 688dc01
Show file tree
Hide file tree
Showing 165 changed files with 12,760 additions and 1,801 deletions.
2 changes: 1 addition & 1 deletion .github/actions/install-node-package/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ runs:
restore-keys: |
${{ runner.os }}-node-
- run: npm install
- run: npm clean-install
shell: bash
67 changes: 20 additions & 47 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@ on:
branches: [master]

env:
NODE_VERSION: 14
NODE_VERSION: 22
TEST_HOST: localhost

permissions:
contents: read # to fetch code (actions/checkout)

jobs:

# Check style compliance of JavaScript code.
Expand All @@ -43,6 +46,19 @@ jobs:
- run: sudo apt-get install shellcheck
- run: git ls-files '*.sh' | xargs shellcheck

# Check package-lock.json is up-to-date

package-lock:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: ./.github/actions/install-node-package
with:
node-version: ${{ env.NODE_VERSION }}
- run: ./bin/verify-package-lock.sh

# Run the integration, find and mapreduce tests against CouchDB on Node.js.
# This should be run against every version of CouchDB and every version of
# Node.js we support.
Expand All @@ -53,7 +69,7 @@ jobs:
fail-fast: false
matrix:
couchdb: ['2.3', '3.1']
node: [14, 16]
node: [18, 20]
cmd:
- npm test
- TYPE=find PLUGINS=pouchdb-find ADAPTERS=http npm test
Expand Down Expand Up @@ -142,7 +158,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node: [14, 16]
node: [18, 20]
adapter: ['leveldb', 'memory']
cmd:
- npm test
Expand Down Expand Up @@ -213,48 +229,6 @@ jobs:
if: steps.retry.outcome == 'failure'
run: ${{ matrix.cmd }}

# Run the integration, find and mapreduce tests using pouchdb-server as the
# remote adapter. This checks that pouchdb-server works with the current
# PouchDB source tree. We run this on Node.js and on every target browser.
# Running against different versions of Node.js might require splitting this
# out into a distinct job.

pouchdb-server:
needs: lint
strategy:
fail-fast: false
matrix:
client: ['node', 'firefox', 'chromium', 'webkit']
cmd:
- npm test
- TYPE=find PLUGINS=pouchdb-find ADAPTERS=http npm test
- TYPE=mapreduce ADAPTERS=http npm test
runs-on: ubuntu-latest
env:
CLIENT: ${{ matrix.client }}
SERVER: pouchdb-server
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: ./.github/actions/install-node-package
with:
node-version: ${{ env.NODE_VERSION }}
- if: ${{ matrix.client != 'node' }}
uses: ./.github/actions/install-playwright
- uses: ./.github/actions/build-pouchdb
- id: test
run: ${{ matrix.cmd }}
continue-on-error: true
- name: First retry
id: retry
if: steps.test.outcome == 'failure'
run: ${{ matrix.cmd }}
continue-on-error: true
- name: Second retry
if: steps.retry.outcome == 'failure'
run: ${{ matrix.cmd }}

# Run all the other testing tasks -- unit tests, and so on. These should be
# run on every version of Node.js that we support.

Expand All @@ -263,15 +237,14 @@ jobs:
strategy:
fail-fast: false
matrix:
node: [14, 16]
node: [18, 20]
cmd:
- CLIENT=firefox npm run test-webpack
- AUTO_COMPACTION=true npm test
- PERF=1 npm test
- npm run test-unit
- npm run test-component
- npm run test-fuzzy
# - SERVER=pouchdb-server POUCHDB_SERVER_FLAGS=--in-memory PLUGINS=pouchdb-find npm run report-coverage
- npm run verify-build
runs-on: ubuntu-latest
steps:
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@ name: PouchDB Docs
on:
push:
paths:
- '.github/actions/**'
- '.github/workflows/docs.yml'
- 'package.json'
- 'bin/**'
- 'docs/**'
pull_request:
branches: [master]
paths:
- '.github/actions/**'
- '.github/workflows/docs.yml'
- 'package.json'
- 'bin/**'
- 'docs/**'
Expand All @@ -24,7 +28,7 @@ jobs:
persist-credentials: false
- uses: ./.github/actions/install-node-package
with:
node-version: 14
node-version: 22
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ src_browser/
tests/integration/utils-bundle.js
*.heapsnapshot
/pouchdb-server-install
package-lock.json
yarn.lock
/.eslintcache
release-todo.txt
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[PouchDB](https://pouchdb.com/) – The Database that Syncs!
=========

[![Build Status](https://github.com/pouchdb/pouchdb/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/pouchdb/pouchdb/actions/workflows/ci.yml?query=branch%3Amaster) [![Coverage Status](https://s3.amazonaws.com/assets.coveralls.io/badges/coveralls_100.svg)](https://coveralls.io/github/pouchdb/pouchdb?branch=master) [![Greenkeeper badge](https://badges.greenkeeper.io/pouchdb/pouchdb.svg)](https://greenkeeper.io/) [![npm version](https://img.shields.io/npm/v/pouchdb.svg)](https://www.npmjs.com/package/pouchdb) [![jsDelivr Hits](https://data.jsdelivr.com/v1/package/npm/pouchdb/badge?style=rounded)](https://www.jsdelivr.com/package/npm/pouchdb)
[![Build Status](https://github.com/pouchdb/pouchdb/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/pouchdb/pouchdb/actions/workflows/ci.yml?query=branch%3Amaster) [![npm version](https://img.shields.io/npm/v/pouchdb.svg)](https://www.npmjs.com/package/pouchdb) [![jsDelivr Hits](https://data.jsdelivr.com/v1/package/npm/pouchdb/badge?style=rounded)](https://www.jsdelivr.com/package/npm/pouchdb)

PouchDB is an open-source JavaScript database inspired by [Apache CouchDB](http://couchdb.apache.org/) that is designed to run well within the browser.

Expand Down
17 changes: 14 additions & 3 deletions TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,20 @@ Sets the number of iterations each test uses by default.

### Running tests in the browser

Normally we use `CLIENT=firefox` to run a set of tests in the browser
automatically. This opens a browser window, automatically runs the requested
tests in it, and reports the results back to the shell.
To run tests in the browser, you first have to install playwright:

```shell
npx playwright install
```

This will download the `firefox`, `chromium` and `webkit` `CLIENT`s onto
your system.

PouchDB is tested with `CLIENT=firefox`, `CLIENT=chromium` and `CLIENT=webkit`
to run a set of tests in the browser automatically. This runs these browsers
in a “headless” mode and prints the test results back into the terminal.

$ CLIENT=firefox npm test

You can also run browser tests in a more "manual" fashion by running the dev
server and opening a browser window yourself. To run the server:
Expand Down
2 changes: 1 addition & 1 deletion bin/build-node.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash -e
#!/usr/bin/env -S bash -e

# don't bother doing this in GHA because it's already been built
if [ -z "$GITHUB_REPOSITORY" ]; then
Expand Down
4 changes: 2 additions & 2 deletions bin/build-site.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ function buildEverything() {

if (!process.env.BUILD) {
const http_server = require('http-server');
const watchGlob = require('watch-glob');
const watchGlob = require('glob-watcher');

watchGlob('**', buildJekyll);
watchGlob('docs/static/less/*/*.less', buildCSS);
watchGlob('static/less/*/*.less', buildCSS);
http_server.createServer({root: '_site', cache: '-1'}).listen(4000);
console.log('Server address: http://localhost:4000');
}
Expand Down
4 changes: 2 additions & 2 deletions bin/dev-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

'use strict';

var watch = require('watch-glob');
var watch = require('glob-watcher');
var http_server = require('http-server');
var debounce = require('lodash.debounce');
const { debounce } = require('lodash');
var browserify = require('browserify');
var fs = require('fs');

Expand Down
2 changes: 1 addition & 1 deletion bin/install-jekyll.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash -e
#!/usr/bin/env -S bash -e

if ! command -v bundler >/dev/null 2>&1; then
echo "bundler is not installed. You need to do: gem install bundler"
Expand Down
2 changes: 1 addition & 1 deletion bin/publish-packages.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash -e
#!/usr/bin/env -S bash -e

publish_packages () {
local root_dir="$PWD"
Expand Down
2 changes: 1 addition & 1 deletion bin/publish-site.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash -e
#!/usr/bin/env -S bash -e

# Build the website
BUILD=1 npm run build-site
Expand Down
6 changes: 3 additions & 3 deletions bin/release.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash -e
#!/usr/bin/env -S bash -e

if [ -n "$DRY_RUN" ]; then
echo "Doing a dry run release..."
Expand All @@ -10,7 +10,7 @@ fi

#make sure deps are up to date
rm -fr node_modules
npm install
npm clean-install

# get current version
VERSION=$(node --eval "console.log(require('./packages/node_modules/pouchdb/package.json').version);")
Expand All @@ -31,7 +31,7 @@ ls packages/node_modules > release-todo.txt
rm -fr lib src dist bower.json component.json package.json
cp -r packages/node_modules/pouchdb/{src,lib,dist,bower.json,component.json,package.json} .
git add -f -- lib src dist *.json
git rm -fr packages bin docs scripts tests
git rm -fr packages bin docs tests

git commit -m "build $VERSION"

Expand Down
18 changes: 12 additions & 6 deletions bin/repeat-perf-test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash -eu
#!/usr/bin/env -S bash -eu

scriptName="$(basename "$0")"
log() { echo "[$scriptName] $*"; }
Expand Down Expand Up @@ -37,7 +37,7 @@ if [[ "$#" -lt 1 ]]; then
Repeatedly run the performance test suite against one or more versions of the codebase.
USAGE
[PERF_REPEATS=<N>] $0 ...tree-ish
[PERF_REPEATS=<N>] $0 ...tree-ish:adapter
EOF
exit 1
Expand All @@ -52,10 +52,13 @@ fi
log
declare -a commits
i=0
for treeish in "$@"; do
for treeish_adapter in "$@"; do
adapter="${treeish_adapter#*:}"
treeish="${treeish_adapter%:*}"
adapters[i]="$adapter"
commits[i]="$(git rev-parse "$treeish")"
description="$(git show --oneline --no-patch "$treeish")"
log " $((i=i+1)). $description ($treeish)"
log " $((i=i+1)). $adapter: $description ($treeish)"
done
log
log "!!! This may cause strange issues if you have uncomitted changes. !!!"
Expand Down Expand Up @@ -91,13 +94,16 @@ npm_install # in case of different deps on different branches
npm run build-test

iterate_tests() {
for commit in "${commits[@]}"; do
log "Running perf tests on $commit..."
for i in "${!commits[@]}"; do
commit="${commits[$i]}"
adapter="${adapters[$i]}"
log "Running perf tests on $commit with adapter-$adapter..."
SRC_ROOT="../../dist-bundles/$commit" \
JSON_REPORTER=1 \
PERF=1 \
USE_MINIFIED=1 \
MANUAL_DEV_SERVER=1 \
ADAPTERS="$adapter" \
node ./bin/test-browser.js

sleep 1
Expand Down
8 changes: 0 additions & 8 deletions bin/rollupPlugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

var nodeResolve = require('rollup-plugin-node-resolve');
var replace = require('rollup-plugin-replace');
var inject = require('rollup-plugin-inject');

function rollupPlugins(nodeResolveConfig) {
return [
Expand All @@ -12,13 +11,6 @@ function rollupPlugins(nodeResolveConfig) {
'process.env.COVERAGE': JSON.stringify(!!process.env.COVERAGE),
// test for fetch vs xhr
'process.env.FETCH': JSON.stringify(!!process.env.FETCH)
}),
inject({
exclude: [
'**/pouchdb-collections/src/**'
],
Map: ['pouchdb-collections', 'Map'],
Set: ['pouchdb-collections', 'Set'],
})
];
}
Expand Down
2 changes: 1 addition & 1 deletion bin/run-dev.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash -e
#!/usr/bin/env -S bash -e

node ./bin/build-pouchdb.js
npm run build-test
Expand Down
6 changes: 3 additions & 3 deletions bin/run-test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash -e
#!/usr/bin/env -S bash -e
shopt -s nullglob

cleanup() {
Expand Down Expand Up @@ -95,7 +95,7 @@ if [[ -n $SERVER ]]; then
echo -e "pouchdb-server should be running on $COUCH_HOST\n"
fi
elif [ "$SERVER" == "couchdb-master" ]; then
if [ -z $COUCH_HOST ]; then
if [ -z "$COUCH_HOST" ]; then
export COUCH_HOST="http://127.0.0.1:5984"
fi
elif [ "$SERVER" == "pouchdb-express-router" ]; then
Expand All @@ -120,7 +120,7 @@ fi

if [ "$SERVER" == "couchdb-master" ]; then
printf '\nEnabling CORS...'
./node_modules/.bin/add-cors-to-couchdb $COUCH_HOST
./node_modules/.bin/add-cors-to-couchdb "$COUCH_HOST"
fi

if [ "$CLIENT" == "unit" ]; then
Expand Down
2 changes: 1 addition & 1 deletion bin/test-coverage.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash -e
#!/usr/bin/env -S bash -e

COVERAGE=1 npm test
Loading

0 comments on commit 688dc01

Please sign in to comment.