From 934c77cee907bf1c6cff26950641857b20e4cc0d Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Tue, 22 Mar 2022 11:12:52 +1300 Subject: [PATCH 01/23] Test CircleCI config changes --- .circleci/config.yml | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 3bf986cca..9e95deea5 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -2,7 +2,7 @@ # # Check https://circleci.com/docs/2.0/language-javascript/ for more details # -version: 2 +version: 2.1 jobs: build: docker: @@ -21,12 +21,33 @@ jobs: # fallback to using the latest cache if no exact match is found - v1-dependencies- - - run: npm install + - node/install-npm + - node/install-packages - save_cache: paths: - node_modules key: v1-dependencies-{{ checksum "package.json" }} + - persist_to_workspace: + root: . + paths: + - . + + test: + steps: + - attach_workspace: + at: . + # run tests! - - run: npm run circleci + - run: + name: Tests + command: npm run circleci + +workflows: + build_and_test: + jobs: + - build + - test: + requires: + - build \ No newline at end of file From 9178d061ff0e5029d2de4f5dcae92252bd8ad1c3 Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Tue, 22 Mar 2022 11:14:41 +1300 Subject: [PATCH 02/23] Fix config --- .circleci/config.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 9e95deea5..b29198936 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -35,6 +35,12 @@ jobs: - . test: + docker: + - image: circleci/node:16.10.0 + - image: circleci/mongo:4.4 + + working_directory: ~/repo + steps: - attach_workspace: at: . From 27530053867f963055de786bb62e289d4315ed4d Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Tue, 22 Mar 2022 11:16:16 +1300 Subject: [PATCH 03/23] Add orb to CircleCI config --- .circleci/config.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index b29198936..7becf4cce 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -3,6 +3,10 @@ # Check https://circleci.com/docs/2.0/language-javascript/ for more details # version: 2.1 + +orbs: + node: circleci/node@3.0.0 + jobs: build: docker: From 8533240407fa84f98f73c57dbc50449acda7ffa0 Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Tue, 22 Mar 2022 11:18:59 +1300 Subject: [PATCH 04/23] Add executor to config --- .circleci/config.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 7becf4cce..8190dccda 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -14,6 +14,7 @@ jobs: - image: circleci/mongo:4.4 working_directory: ~/repo + executor: node/default steps: - checkout From 03e5d86b735fed82554d63eee51cca9c135cf3dc Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Tue, 22 Mar 2022 11:20:49 +1300 Subject: [PATCH 05/23] Add NPM settings --- .circleci/config.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 8190dccda..67fb6261e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -27,7 +27,10 @@ jobs: - v1-dependencies- - node/install-npm - - node/install-packages + - node/install-packages: + app-dir: ~/homebrewery + cache-path: node_modules + overrise-ci-command: npm i - save_cache: paths: From 06598e0665a9e0b50d501fe6c2a1c9a532579e5d Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Tue, 22 Mar 2022 11:21:51 +1300 Subject: [PATCH 06/23] Fix typo --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 67fb6261e..e1e316fe9 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -30,7 +30,7 @@ jobs: - node/install-packages: app-dir: ~/homebrewery cache-path: node_modules - overrise-ci-command: npm i + override-ci-command: npm i - save_cache: paths: From 0a90218d2aa1333d48472164abbc8721497ab49e Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Tue, 22 Mar 2022 11:27:08 +1300 Subject: [PATCH 07/23] Fix for missing package.json --- .circleci/config.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index e1e316fe9..45cde9c41 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -17,7 +17,8 @@ jobs: executor: node/default steps: - - checkout + - checkout: + path: ~/repo/homebrewery # Download and cache dependencies - restore_cache: @@ -28,7 +29,7 @@ jobs: - node/install-npm - node/install-packages: - app-dir: ~/homebrewery + app-dir: ~/repo/homebrewery cache-path: node_modules override-ci-command: npm i From 8800397ba4ca8d0eb565765d510c2ed410c101d9 Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Tue, 22 Mar 2022 11:31:26 +1300 Subject: [PATCH 08/23] Working directory changes --- .circleci/config.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 45cde9c41..62151d5b4 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -13,12 +13,12 @@ jobs: - image: circleci/node:16.10.0 - image: circleci/mongo:4.4 - working_directory: ~/repo + working_directory: ~/homebrewery executor: node/default steps: - checkout: - path: ~/repo/homebrewery + path: ~/homebrewery # Download and cache dependencies - restore_cache: @@ -29,7 +29,7 @@ jobs: - node/install-npm - node/install-packages: - app-dir: ~/repo/homebrewery + app-dir: ~/homebrewery cache-path: node_modules override-ci-command: npm i @@ -48,7 +48,7 @@ jobs: - image: circleci/node:16.10.0 - image: circleci/mongo:4.4 - working_directory: ~/repo + working_directory: ~/homebrewery steps: - attach_workspace: From 274b3bcb7e43cdaa66f0b7ddc057e06a0779f0ef Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Tue, 22 Mar 2022 11:34:32 +1300 Subject: [PATCH 09/23] Add parallelism parameter --- .circleci/config.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 62151d5b4..377c6bcb7 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -49,6 +49,7 @@ jobs: - image: circleci/mongo:4.4 working_directory: ~/homebrewery + parallelism: 4 steps: - attach_workspace: From 4134e43f6e4b9bd47c33b639ff1077305e0f0ad8 Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Tue, 22 Mar 2022 11:58:19 +1300 Subject: [PATCH 10/23] Change test to verbose mode --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 377c6bcb7..6b12ab3e5 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -58,7 +58,7 @@ jobs: # run tests! - run: name: Tests - command: npm run circleci + command: npm run circleci --verbose workflows: build_and_test: From 9535fea96486f31fd3b93d7f95afc1c7dc5e89fd Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Tue, 22 Mar 2022 12:03:26 +1300 Subject: [PATCH 11/23] Revert change to verbose --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 6b12ab3e5..377c6bcb7 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -58,7 +58,7 @@ jobs: # run tests! - run: name: Tests - command: npm run circleci --verbose + command: npm run circleci workflows: build_and_test: From 7aa0aed7c945b564244a010443269f9b4d592a8b Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Fri, 25 Mar 2022 14:38:19 +1300 Subject: [PATCH 12/23] Add individual tests to package.json --- package.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/package.json b/package.json index 477cd5b65..b03bee513 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,9 @@ "verify": "npm run lint && npm test", "test": "jest", "test:dev": "jest --verbose --watch", + "test:basic": "jest tests/markdown/basic.test.js --verbose", + "test:mustache-span": "jest tests/markdown/mustache-span.test.js --verbose", + "test:route": "jest tests/routes/static-pages.test.js --verbose", "phb": "node scripts/phb.js", "prod": "set NODE_ENV=production && npm run build", "postinstall": "npm run buildall", From eaf8b02aa9d541f7f4b8db2f68c3c8f24306192b Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Fri, 25 Mar 2022 14:38:50 +1300 Subject: [PATCH 13/23] Update circleCi config to use new tests --- .circleci/config.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 377c6bcb7..ddfb08d96 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -57,8 +57,14 @@ jobs: # run tests! - run: - name: Tests - command: npm run circleci + name: Test - Basic + command: npm run test:basic + - run: + name: Test - Mustache Spans + command: npm run test:mustache-span + - run: + name: Test - Routes + command: npm run test:route workflows: build_and_test: From 5ed6e9842c66b96ddba8e686310e136e5b92b8f2 Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Fri, 25 Mar 2022 14:39:14 +1300 Subject: [PATCH 14/23] Add 10s delay to route test start --- tests/routes/static-pages.test.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/routes/static-pages.test.js b/tests/routes/static-pages.test.js index e69706f56..1202ac8f6 100644 --- a/tests/routes/static-pages.test.js +++ b/tests/routes/static-pages.test.js @@ -1,5 +1,10 @@ const supertest = require('supertest'); +const start = Date.now(); +console.log(`START DELAY ${Date.now().toString()}`); +while (Date.now() < start + 10000){}; +console.log(`END DELAY ${Date.now().toString()}`); + // Mimic https responses to avoid being redirected all the time const app = supertest.agent(require('app.js').app) .set('X-Forwarded-Proto', 'https'); From aa7b3d985f42024feec3b22713d71c1b16bb11c4 Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Fri, 25 Mar 2022 14:50:30 +1300 Subject: [PATCH 15/23] Move test setup to BEFORE delay --- tests/routes/static-pages.test.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tests/routes/static-pages.test.js b/tests/routes/static-pages.test.js index 1202ac8f6..769cffbb9 100644 --- a/tests/routes/static-pages.test.js +++ b/tests/routes/static-pages.test.js @@ -1,14 +1,13 @@ const supertest = require('supertest'); -const start = Date.now(); -console.log(`START DELAY ${Date.now().toString()}`); -while (Date.now() < start + 10000){}; -console.log(`END DELAY ${Date.now().toString()}`); - // Mimic https responses to avoid being redirected all the time const app = supertest.agent(require('app.js').app) .set('X-Forwarded-Proto', 'https'); +const timeout = 10000; //ms +const start = Date.now(); +while (Date.now() < start + timeout){}; + describe('Tests for static pages', ()=>{ it('Home page works', ()=>{ return app.get('/').expect(200); From f246c96b2855b762c74486c401185aee102ef9c6 Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Fri, 25 Mar 2022 15:00:33 +1300 Subject: [PATCH 16/23] Remove 10s delay for diagnostics --- tests/routes/static-pages.test.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/routes/static-pages.test.js b/tests/routes/static-pages.test.js index 769cffbb9..cb4ce6953 100644 --- a/tests/routes/static-pages.test.js +++ b/tests/routes/static-pages.test.js @@ -4,9 +4,9 @@ const supertest = require('supertest'); const app = supertest.agent(require('app.js').app) .set('X-Forwarded-Proto', 'https'); -const timeout = 10000; //ms -const start = Date.now(); -while (Date.now() < start + timeout){}; +// const timeout = 10000; //ms +// const start = Date.now(); +// while (Date.now() < start + timeout){}; describe('Tests for static pages', ()=>{ it('Home page works', ()=>{ From b0d8462a604521a5424a9a60afd7142e0fc35e57 Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Fri, 25 Mar 2022 15:06:26 +1300 Subject: [PATCH 17/23] Remove MongoDB from testing, update Node image --- .circleci/config.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index ddfb08d96..057cf9cb4 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -10,7 +10,7 @@ orbs: jobs: build: docker: - - image: circleci/node:16.10.0 + - image: circleci/node:16.11.0 - image: circleci/mongo:4.4 working_directory: ~/homebrewery @@ -45,8 +45,7 @@ jobs: test: docker: - - image: circleci/node:16.10.0 - - image: circleci/mongo:4.4 + - image: circleci/node:16.11.0 working_directory: ~/homebrewery parallelism: 4 From c0c08b33548b51d109c25f380586ff8c097e4abc Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Fri, 25 Mar 2022 15:08:37 +1300 Subject: [PATCH 18/23] Fix new Node image location --- .circleci/config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 057cf9cb4..04fefade1 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -10,7 +10,7 @@ orbs: jobs: build: docker: - - image: circleci/node:16.11.0 + - image: cimg/node:16.11.0 - image: circleci/mongo:4.4 working_directory: ~/homebrewery @@ -45,7 +45,7 @@ jobs: test: docker: - - image: circleci/node:16.11.0 + - image: cimg/node:16.11.0 working_directory: ~/homebrewery parallelism: 4 From 2be365c83945a78ff92cd95cc7b3c4fe4d3a8d8b Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Fri, 25 Mar 2022 16:12:33 +1300 Subject: [PATCH 19/23] Shift global declarations to `componentDidMount` --- client/homebrew/homebrew.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/homebrew/homebrew.jsx b/client/homebrew/homebrew.jsx index 54dcf2206..c0b4fe4b4 100644 --- a/client/homebrew/homebrew.jsx +++ b/client/homebrew/homebrew.jsx @@ -32,7 +32,7 @@ const Homebrew = createClass({ } }; }, - componentWillMount : function() { + componentDidMount : function() { global.account = this.props.account; global.version = this.props.version; global.enable_v3 = this.props.enable_v3; From 77e8952e8a55bd0b5880d329587648f7df4b5d60 Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Fri, 25 Mar 2022 16:40:41 +1300 Subject: [PATCH 20/23] Shift componentWillMount call to getInitialState --- client/homebrew/homebrew.jsx | 7 +++++-- client/homebrew/navbar/navbar.jsx | 10 ++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/client/homebrew/homebrew.jsx b/client/homebrew/homebrew.jsx index c0b4fe4b4..094b96744 100644 --- a/client/homebrew/homebrew.jsx +++ b/client/homebrew/homebrew.jsx @@ -32,11 +32,14 @@ const Homebrew = createClass({ } }; }, - componentDidMount : function() { - global.account = this.props.account; + + getInitialState : function(){ global.version = this.props.version; + global.account = this.props.account; global.enable_v3 = this.props.enable_v3; + return {}; }, + render : function (){ return ( diff --git a/client/homebrew/navbar/navbar.jsx b/client/homebrew/navbar/navbar.jsx index b3255db45..7929bb5e2 100644 --- a/client/homebrew/navbar/navbar.jsx +++ b/client/homebrew/navbar/navbar.jsx @@ -14,12 +14,10 @@ const Navbar = createClass({ }; }, - componentDidMount : function() { - //const isChrome = /Chrome/.test(navigator.userAgent) && /Google Inc/.test(navigator.vendor); - this.setState({ - //showNonChromeWarning : !isChrome, - ver : window.version - }); + getInitialState : function() { + return { + ver : global.version + }; }, /* From 42ee461f56da1f73a5aaeff090d950f7ef952602 Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Sat, 26 Mar 2022 20:55:50 +1300 Subject: [PATCH 21/23] Remove commented out delay --- tests/routes/static-pages.test.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tests/routes/static-pages.test.js b/tests/routes/static-pages.test.js index cb4ce6953..e69706f56 100644 --- a/tests/routes/static-pages.test.js +++ b/tests/routes/static-pages.test.js @@ -4,10 +4,6 @@ const supertest = require('supertest'); const app = supertest.agent(require('app.js').app) .set('X-Forwarded-Proto', 'https'); -// const timeout = 10000; //ms -// const start = Date.now(); -// while (Date.now() < start + timeout){}; - describe('Tests for static pages', ()=>{ it('Home page works', ()=>{ return app.get('/').expect(200); From 7403ef60c13427f53e5a3d43491d499a3cbcc96c Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Sat, 26 Mar 2022 20:56:04 +1300 Subject: [PATCH 22/23] Increase test timeout via Jest config --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index b03bee513..b207ceb2e 100644 --- a/package.json +++ b/package.json @@ -34,6 +34,7 @@ "build/*" ], "jest": { + "testTimeout" : 15000, "modulePaths": [ "mode_modules", "shared", From 57d0e8eea3746875e08931f053107d55dfd0c850 Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Sat, 26 Mar 2022 21:13:06 +1300 Subject: [PATCH 23/23] Test standard Docker MongoDB image --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 04fefade1..13d339892 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -11,7 +11,7 @@ jobs: build: docker: - image: cimg/node:16.11.0 - - image: circleci/mongo:4.4 + - image: mongo:4.4 working_directory: ~/homebrewery executor: node/default