Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ jobs:
steps:
- uses: actions/checkout@v6
- name: Build the Docker image
run: "echo 'module.exports = { usersDbConnection: { url: \"http://localhost:5984\" }};' > config/local.js && docker build . --file Dockerfile --tag fielddb-auth:$(date +%s)"
run: "echo 'module.exports = { usersDbConnection: { url: \"http://couchdb:5984\" }};' > config/localhost.js && docker build . --file Dockerfile --tag fielddb-auth:$(date +%s)"
71 changes: 31 additions & 40 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,25 @@ on:
branches: [ main ]

jobs:
integration-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v6
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci
- name: Run Integration tests
run: DEBUG=replay* npm run coverage
# FIXME 'Test run failed replay no longer is working with latest nano which uses node fetch'

deploy:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [24.x]
node-version: [25.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
Expand All @@ -29,50 +43,40 @@ jobs:

- name: Create local config for the app to connect to couchdb service in the container
run: |
echo 'module.exports = { usersDbConnection: { url: "http://couchdb:5984" }};' > config/local.js
echo 'module.exports = { usersDbConnection: { url: "http://couchdb:5984" }};' > config/localhost.js

- name: Start docker compose services
run: docker compose up -d && sleep 5

- name: Show docker compose logs
- name: Show docker compose logs after creating services
run: docker compose logs --no-color --timestamps || true

- name: Run setup
- name: Run setup databases in the couchdb inside the container
run: npm run setup
env:
SOURCE_URL: ${{ secrets.SOURCE_URL }}
DEBUG: 'none'

- name: Run E2E tests against the container app
run: REPLAY=bloody URL=https://localhost:3183 npm run test:deprecated || echo 'Test run failed when trying to use the deployed auth app'
run: DEBUG=test:deprecated npm run test:deprecated:e2e
env:
SOURCE_URL: ${{ secrets.SOURCE_URL }}
DEBUG: 'none'

- name: Show docker compose logs
if: success() || failure()
run: docker compose logs --no-color --timestamps || true
- name: Show app logs after running tests
if: failure()
run: docker compose logs --no-color --timestamps | grep -v "couchdb" || true

integration-tests:
runs-on: ubuntu-latest
needs: [deploy]
steps:
- uses: actions/checkout@v6
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v6
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: Create local config for tests to use the couchdb from the container
- name: Create local config for tests to use the couchdb outside the container
run: |
echo 'module.exports = { usersDbConnection: { url: "http://localhost:5984" }};' > config/local.js
- name: Run Integration tests
run: DEBUG=replay* npm run coverage || echo 'Test run failed replay no longer is working with latest nano which uses node fetch'
- name: Run integration tests using the app with local couchdb
run: REPLAY=bloody npm run test:deprecated
echo 'module.exports = { usersDbConnection: { url: "http://localhost:5984" }};' > config/localhost.js

- name: Run integration tests using the app against the couchdb in the contianer
run: npm run test:deprecated:coverage
env:
SOURCE_URL: ${{ secrets.SOURCE_URL }}
DEBUG: 'none'
DEBUG: 'none' # 'test:deprecated'

- name: Upload coverage report
uses: actions/upload-artifact@v5
if: success() || failure()
Expand All @@ -86,30 +90,17 @@ jobs:
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

ui-tests:
runs-on: ubuntu-latest
needs: [deploy]
steps:
- uses: actions/checkout@v6
with:
sparse-checkout:: |
package.json
- name: Use Node.js 24.x
uses: actions/setup-node@v6
with:
node-version: 24.x
cache: 'npm'
- name: Run UI tests
run: npm run test:ui
timeout-minutes: 5
env:
BASE_URL: https://localhost:6984
BASE_PATH: /prototype/_design/prototype
BASE_PATH: /prototypedev/_design/prototype

- name: Upload Playwright report and traces for trace.playwright.dev
uses: actions/upload-artifact@v5
if: ${{ !cancelled() }} # Upload even if the previous step failed
with:
name: test-results # Name of the artifact
name: ui-test-results # Name of the artifact
path: FieldDB/test-e2e/test-results/ # Path to the directory containing reports and traces
retention-days: 30
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ compiled_handlebars.js
*_production*
config/production.*
config/local.*
config/localhost.*
etc
Dockerfile-couchdb
db
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ COPY . .
RUN NODE_ENV=production npm ci

RUN ls -alt; \
ls config/local.js || echo " config/local.js is required to be able to run the tests against deployed couchdb"
ls config/localhost.js || echo " config/localhost.js is required to be able to run the tests against deployed couchdb"

ENV DEBUG="*,-express*"
ENV NODE_ENV=localhost
Expand Down
2 changes: 1 addition & 1 deletion auth_service.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const bunyan = require('express-bunyan-logger');
* $ NODE_ENV=production # uses config/production.js
* $ NODE_ENV=test # uses config/test.js
* $ NODE_ENV=development # uses config/development.js
* $ NODE_ENV=local # uses config/local.js
* $ NODE_ENV=localhost # uses config/localhost.js
* $ NODE_ENV=yoursecretconfig # uses config/yoursecretconfig.js
*/
const config = require('config');
Expand Down
3 changes: 2 additions & 1 deletion config/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const path = require('path');
const { Connection } = require('fielddb/api/corpus/Connection');

let deployTarget = process.env.NODE_ENV || 'localhost';
const PORT = process.env.PORT || process.env.HTTPS_PORT || null;
// backward compatible
if (deployTarget === 'test') {
deployTarget = 'beta';
Expand Down Expand Up @@ -36,7 +37,7 @@ module.exports = {
httpsOptions: {
key: fs.readFileSync(path.join(__dirname, '/fielddb_debug.key'), 'utf8'),
cert: fs.readFileSync(path.join(__dirname, '/fielddb_debug.crt'), 'utf8'),
port: '3183',
port: PORT || '3183',
protocol: 'https://',
},
url: 'https://localhost:3183',
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ services:
environment:
- COUCHDB_USER=admin
- COUCHDB_PASSWORD=none
auth_app:
app:
depends_on:
- couchdb
build:
Expand Down
2 changes: 1 addition & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,5 @@ module.exports = defineConfig([
"semi": ["error", "always"],
},
},
globalIgnores(["**/public", "lib/About.js", "lib/FieldDB.js"]),
globalIgnores(["**/public", "lib/About.js", "lib/FieldDB.js", "FieldDB"]),
]);
4 changes: 2 additions & 2 deletions lib/corpusmanagement.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { NODE_ENV } = process.env;
const { couchKeys } = require('config');
const { couchKeys, usersDbConnection } = require('config');
const { Connection } = require('fielddb/api/corpus/Connection');
const debug = require('debug')('lib:corpus:management');
const url = require('url');
Expand All @@ -11,7 +11,7 @@ if (!Connection || !Connection.knownConnections || !Connection.knownConnections.
throw new Error(`The app config for ${NODE_ENV} is missing app types to support. `);
}

const parsed = url.parse('http://localhost:5984');
const parsed = url.parse(usersDbConnection.url);
const couchConnectUrl = `${parsed.protocol}//${couchKeys.username}:${couchKeys.password}@${parsed.host}`;
// console.log('Using couchKeys url: ', couchKeys);
debug('Using corpus url: ', couchConnectUrl);
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,17 @@
},
"scripts": {
"docker:build": "docker build -t fielddb-auth .",
"test:e2e": "echo 'module.exports = { usersDbConnection: { url: \"http://couchdb:5984\" } };' > config/local.js && docker compose up -d && sleep 3 && docker compose logs && npm run setup && npm run test:deprecated",
"docker:test:no-cache": "echo 'module.exports = { usersDbConnection: { url: \"http://couchdb:5984\" } };' > config/local.js && docker compose build --no-cache && docker compose up -d && sleep 15 && docker compose logs && npm run setup && npm run test:deprecated",
"test:docker": "echo 'module.exports = { usersDbConnection: { url: \"http://couchdb:5984\" } };' > config/localhost.js && docker compose up -d && sleep 3 && docker compose logs && npm run setup && npm run test:deprecated:e2e",
"test:docker:no-cache": "echo 'module.exports = { usersDbConnection: { url: \"http://couchdb:5984\" } };' > config/localhost.js && docker compose build --no-cache && docker compose up -d && sleep 15 && docker compose logs && npm run setup && npm run test:deprecated:e2e",
"coverage": "NODE_ENV=test BUNYAN_LOG_LEVEL=FATAL nyc npm test",
"lint": "eslint ",
"lint:ci": "eslint .",
"setup": "REPLAY=bloody NODE_TLS_REJECT_UNAUTHORIZED=0 SOURCE_URL=${SOURCE_URL:-https://public:none@corpusdev.example.org} mocha --timeout 20000 test/integration/install.js",
"start": "node ./bin/www.js",
"test": "SOURCE_URL=${SOURCE_URL:-https://public:none@corpusdev.example.org} NODE_ENV=test NODE_TLS_REJECT_UNAUTHORIZED=0 mocha --timeout 100000 --recursive test",
"test:debug": "node-debug _mocha test/integration/oauth.js",
"test:deprecated": "DEBUG=${DEBUG:-lib:user} REPLAY=bloody NODE_TLS_REJECT_UNAUTHORIZED=0 nyc mocha --timeout 25000 test/routes/deprecated-spec.js",
"test:deprecated:e2e": "DEBUG=${DEBUG:-test:deprecated} REPLAY=bloody NODE_TLS_REJECT_UNAUTHORIZED=0 URL=https://localhost:3183 mocha --timeout 25000 test/routes/deprecated-spec.js",
"test:deprecated:coverage": "DEBUG=${DEBUG:-lib:user} REPLAY=bloody NODE_TLS_REJECT_UNAUTHORIZED=0 nyc mocha --timeout 25000 test/routes/deprecated-spec.js",
"test:fielddb": "NODE_ENV=localhost jasmine-node node_modules/fielddb/tests",
"test:production": "ls config/production.js",
"test:ui": "git clone --filter=blob:none --no-checkout https://github.com/FieldDB/FieldDB.git; cd FieldDB; git sparse-checkout set test-e2e; git checkout HEAD; cd test-e2e && npm install && npx playwright install chromium && BASE_URL=${BASE_URL:-https://localhost:6984} BASE_PATH=${BASE_PATH:-/prototypedev/_design/prototype} DEBUG=${DEBUG:-none} npm run test -- --retries=0 --project=Chromium register",
Expand Down
Loading