From 25ce82fa4bb71c6215e7200200867122d68bad73 Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Sat, 24 Sep 2022 13:17:21 +0100 Subject: [PATCH 1/4] using real couch in integration tests --- .github/workflows/budibase_ci.yml | 16 +++++++++------- packages/builder/cypress/setup.js | 8 +++----- packages/server/src/db/index.js | 10 +++++----- packages/worker/src/db/index.js | 10 +++++----- qa-core/.env | 1 + qa-core/src/tests/public-api/tables/rows.spec.ts | 1 + 6 files changed, 24 insertions(+), 22 deletions(-) diff --git a/.github/workflows/budibase_ci.yml b/.github/workflows/budibase_ci.yml index 42a0c0a273..06a21c5348 100644 --- a/.github/workflows/budibase_ci.yml +++ b/.github/workflows/budibase_ci.yml @@ -23,6 +23,15 @@ jobs: build: runs-on: ubuntu-latest + services: + couchdb: + image: ibmcom/couchdb3 + env: + COUCHDB_PASSWORD: budibase + COUCHDB_USER: budibase + ports: + - 4567:5984 + strategy: matrix: node-version: [14.x] @@ -53,13 +62,6 @@ jobs: name: codecov-umbrella verbose: true - # TODO: parallelise this - - name: Cypress run - uses: cypress-io/github-action@v2 - with: - install: false - command: yarn test:e2e:ci - - name: QA Core Integration Tests run: | cd qa-core diff --git a/packages/builder/cypress/setup.js b/packages/builder/cypress/setup.js index d858801990..0e2f25b028 100644 --- a/packages/builder/cypress/setup.js +++ b/packages/builder/cypress/setup.js @@ -1,16 +1,14 @@ const cypressConfig = require("../cypress.json") -const path = require("path") - -const tmpdir = path.join(require("os").tmpdir(), ".budibase") // normal development system const SERVER_PORT = cypressConfig.env.PORT const WORKER_PORT = cypressConfig.env.WORKER_PORT -process.env.NODE_ENV = "cypress" +if (!process.env.NODE_ENV) { + process.env.NODE_ENV = "cypress" +} process.env.ENABLE_ANALYTICS = "0" process.env.JWT_SECRET = cypressConfig.env.JWT_SECRET -process.env.COUCH_URL = `leveldb://${tmpdir}/.data/` process.env.SELF_HOSTED = 1 process.env.WORKER_URL = `http://localhost:${WORKER_PORT}/` process.env.APPS_URL = `http://localhost:${SERVER_PORT}/` diff --git a/packages/server/src/db/index.js b/packages/server/src/db/index.js index 75ad19b87f..e8ec2c720e 100644 --- a/packages/server/src/db/index.js +++ b/packages/server/src/db/index.js @@ -1,5 +1,5 @@ const core = require("@budibase/backend-core") -const env = require("../environment") +// const env = require("../environment") exports.init = () => { const dbConfig = { @@ -7,10 +7,10 @@ exports.init = () => { find: true, } - if (env.isTest()) { - dbConfig.inMemory = true - dbConfig.allDbs = true - } + // if (env.isTest()) { + // dbConfig.inMemory = true + // dbConfig.allDbs = true + // } core.init({ db: dbConfig }) } diff --git a/packages/worker/src/db/index.js b/packages/worker/src/db/index.js index 25dc02962b..bdfc55a22a 100644 --- a/packages/worker/src/db/index.js +++ b/packages/worker/src/db/index.js @@ -1,11 +1,11 @@ const core = require("@budibase/backend-core") -const env = require("../environment") +// const env = require("../environment") exports.init = () => { const dbConfig = {} - if (env.isTest()) { - dbConfig.inMemory = true - dbConfig.allDbs = true - } + // if (env.isTest()) { + // dbConfig.inMemory = true + // dbConfig.allDbs = true + // } core.init({ db: dbConfig }) } diff --git a/qa-core/.env b/qa-core/.env index 740b1b2b2a..7f39785f33 100644 --- a/qa-core/.env +++ b/qa-core/.env @@ -1,3 +1,4 @@ BB_ADMIN_USER_EMAIL=qa@budibase.com BB_ADMIN_USER_PASSWORD=budibase ENCRYPTED_TEST_PUBLIC_API_KEY=a65722f06bee5caeadc5d7ca2f543a43-d610e627344210c643bb726f +COUCH_DB_URL=http://budibase:budibase@localhost:4567 \ No newline at end of file diff --git a/qa-core/src/tests/public-api/tables/rows.spec.ts b/qa-core/src/tests/public-api/tables/rows.spec.ts index 91df85e65c..89149159ab 100644 --- a/qa-core/src/tests/public-api/tables/rows.spec.ts +++ b/qa-core/src/tests/public-api/tables/rows.spec.ts @@ -41,6 +41,7 @@ describe("Public API - /rows endpoints", () => { }, }) expect(response).toHaveStatusCode(200) + expect(rows.length).toEqual(1) expect(rows[0]._id).toEqual(config.context._id) expect(rows[0].tableId).toEqual(config.context.tableId) expect(rows[0].testColumn).toEqual(config.context.testColumn) From e06afeb19482eaa2480028a89035aab71c17a00b Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Sun, 25 Sep 2022 23:43:37 +0100 Subject: [PATCH 2/4] adding startup script for local --- .github/workflows/budibase_ci.yml | 2 +- qa-core/.env | 4 +++- qa-core/docker-compose.yaml | 12 ++++++++++++ qa-core/package.json | 4 +++- 4 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 qa-core/docker-compose.yaml diff --git a/.github/workflows/budibase_ci.yml b/.github/workflows/budibase_ci.yml index 06a21c5348..475bd4f66a 100644 --- a/.github/workflows/budibase_ci.yml +++ b/.github/workflows/budibase_ci.yml @@ -27,7 +27,7 @@ jobs: couchdb: image: ibmcom/couchdb3 env: - COUCHDB_PASSWORD: budibase + COUCHDB_PASSWORD: budibase COUCHDB_USER: budibase ports: - 4567:5984 diff --git a/qa-core/.env b/qa-core/.env index 7f39785f33..36dd0a3656 100644 --- a/qa-core/.env +++ b/qa-core/.env @@ -1,4 +1,6 @@ BB_ADMIN_USER_EMAIL=qa@budibase.com BB_ADMIN_USER_PASSWORD=budibase ENCRYPTED_TEST_PUBLIC_API_KEY=a65722f06bee5caeadc5d7ca2f543a43-d610e627344210c643bb726f -COUCH_DB_URL=http://budibase:budibase@localhost:4567 \ No newline at end of file +COUCH_DB_URL=http://budibase:budibase@localhost:4567 +COUCH_DB_USER=budibase +COUCH_DB_PASSWORD=budibase \ No newline at end of file diff --git a/qa-core/docker-compose.yaml b/qa-core/docker-compose.yaml new file mode 100644 index 0000000000..abd8e4818e --- /dev/null +++ b/qa-core/docker-compose.yaml @@ -0,0 +1,12 @@ +version: "3.8" +services: + qa-core-couchdb: + # platform: linux/amd64 + container_name: budi-couchdb-qa + restart: on-failure + image: ibmcom/couchdb3 + environment: + - COUCHDB_PASSWORD=${COUCH_DB_PASSWORD} + - COUCHDB_USER=${COUCH_DB_USER} + ports: + - "4567:5984" diff --git a/qa-core/package.json b/qa-core/package.json index b2c3f464d7..529827bc9f 100644 --- a/qa-core/package.json +++ b/qa-core/package.json @@ -12,7 +12,9 @@ "test": "jest --runInBand", "test:watch": "jest --watch", "test:debug": "DEBUG=1 jest", - "api:server:setup": "env-cmd ts-node ../packages/builder/cypress/ts/setup.ts", + "docker:up": "docker-compose up -d", + "docker:down": "docker-compose down", + "api:server:setup": "npm run docker:up && env-cmd ts-node ../packages/builder/cypress/ts/setup.ts", "api:server:setup:ci": "env-cmd node ../packages/builder/cypress/setup.js", "api:test:ci": "start-server-and-test api:server:setup:ci http://localhost:4100/builder test", "api:test": "start-server-and-test api:server:setup http://localhost:4100/builder test" From f0bcf606bcd0b4c2d06c8c8b7369e13fd5bcc6a6 Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Mon, 26 Sep 2022 09:41:49 +0100 Subject: [PATCH 3/4] turn off unit tests --- .github/workflows/budibase_ci.yml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/budibase_ci.yml b/.github/workflows/budibase_ci.yml index 475bd4f66a..fa99a3d89b 100644 --- a/.github/workflows/budibase_ci.yml +++ b/.github/workflows/budibase_ci.yml @@ -51,16 +51,16 @@ jobs: - run: yarn bootstrap - run: yarn lint - run: yarn build - - run: yarn test - env: - CI: true - name: Budibase CI - - uses: codecov/codecov-action@v1 - with: - token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos - files: ./packages/server/coverage/clover.xml - name: codecov-umbrella - verbose: true + # - run: yarn test + # env: + # CI: true + # name: Budibase CI + # - uses: codecov/codecov-action@v1 + # with: + # token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos + # files: ./packages/server/coverage/clover.xml + # name: codecov-umbrella + # verbose: true - name: QA Core Integration Tests run: | From 886a90d1fdfac42747c9e79eb955bc9775d62905 Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Mon, 26 Sep 2022 10:40:37 +0100 Subject: [PATCH 4/4] only run in test mode if couch url is not passed --- .github/workflows/budibase_ci.yml | 20 ++++++++++---------- packages/server/src/db/index.js | 10 +++++----- packages/worker/src/db/index.js | 10 +++++----- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/.github/workflows/budibase_ci.yml b/.github/workflows/budibase_ci.yml index fa99a3d89b..475bd4f66a 100644 --- a/.github/workflows/budibase_ci.yml +++ b/.github/workflows/budibase_ci.yml @@ -51,16 +51,16 @@ jobs: - run: yarn bootstrap - run: yarn lint - run: yarn build - # - run: yarn test - # env: - # CI: true - # name: Budibase CI - # - uses: codecov/codecov-action@v1 - # with: - # token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos - # files: ./packages/server/coverage/clover.xml - # name: codecov-umbrella - # verbose: true + - run: yarn test + env: + CI: true + name: Budibase CI + - uses: codecov/codecov-action@v1 + with: + token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos + files: ./packages/server/coverage/clover.xml + name: codecov-umbrella + verbose: true - name: QA Core Integration Tests run: | diff --git a/packages/server/src/db/index.js b/packages/server/src/db/index.js index e8ec2c720e..381c295d18 100644 --- a/packages/server/src/db/index.js +++ b/packages/server/src/db/index.js @@ -1,5 +1,5 @@ const core = require("@budibase/backend-core") -// const env = require("../environment") +const env = require("../environment") exports.init = () => { const dbConfig = { @@ -7,10 +7,10 @@ exports.init = () => { find: true, } - // if (env.isTest()) { - // dbConfig.inMemory = true - // dbConfig.allDbs = true - // } + if (env.isTest() && !env.COUCH_DB_URL) { + dbConfig.inMemory = true + dbConfig.allDbs = true + } core.init({ db: dbConfig }) } diff --git a/packages/worker/src/db/index.js b/packages/worker/src/db/index.js index bdfc55a22a..58fd8484ff 100644 --- a/packages/worker/src/db/index.js +++ b/packages/worker/src/db/index.js @@ -1,11 +1,11 @@ const core = require("@budibase/backend-core") -// const env = require("../environment") +const env = require("../environment") exports.init = () => { const dbConfig = {} - // if (env.isTest()) { - // dbConfig.inMemory = true - // dbConfig.allDbs = true - // } + if (env.isTest() && !env.COUCH_DB_URL) { + dbConfig.inMemory = true + dbConfig.allDbs = true + } core.init({ db: dbConfig }) }