From 48ccc987ba05645280ec85ab14170e0d912573aa Mon Sep 17 00:00:00 2001 From: Matthew Petrie Date: Tue, 16 Mar 2021 11:18:25 +0000 Subject: [PATCH 1/7] feat: add github PR actions --- .github/workflows/pull-request.yml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .github/workflows/pull-request.yml diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml new file mode 100644 index 0000000..e1f2551 --- /dev/null +++ b/.github/workflows/pull-request.yml @@ -0,0 +1,29 @@ +name: pull-request +on: [pull_request] +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + # Make sure the actual branch is checked out when running on pull requests + ref: ${{ github.head_ref }} + # This is important to fetch the changes to the previous commit + fetch-depth: 0 + - uses: actions/setup-node@v1 + with: + node-version: '14' + - run: npm lint + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + # Make sure the actual branch is checked out when running on pull requests + ref: ${{ github.head_ref }} + # This is important to fetch the changes to the previous commit + fetch-depth: 0 + - uses: actions/setup-node@v1 + with: + node-version: '14' + - run: npm test From c34e8f34d61f2f4435738f7085f864d9b1378bd3 Mon Sep 17 00:00:00 2001 From: Matthew Petrie Date: Tue, 16 Mar 2021 11:21:26 +0000 Subject: [PATCH 2/7] fix: install dependancies --- .github/workflows/pull-request.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index e1f2551..f36cd6e 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -13,7 +13,8 @@ jobs: - uses: actions/setup-node@v1 with: node-version: '14' - - run: npm lint + - run: npm i + - run: npm run lint test: runs-on: ubuntu-latest steps: @@ -26,4 +27,5 @@ jobs: - uses: actions/setup-node@v1 with: node-version: '14' + - run: npm i - run: npm test From b4202f45350601c032bc1932c0e72ba153c910b4 Mon Sep 17 00:00:00 2001 From: Matthew Petrie Date: Tue, 16 Mar 2021 15:34:10 +0000 Subject: [PATCH 3/7] fix(ci start DB before tests): --- .github/workflows/pull-request.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index f36cd6e..b0f9c7b 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -28,4 +28,9 @@ jobs: with: node-version: '14' - run: npm i - - run: npm test + - name: Start MongoDB + uses: supercharge/mongodb-github-action@1.3.0 + with: + mongodb-version: 4.4 + - name: Test + run: npm test From a7a890ba0b97d9b67171101290fb2298632cf5d3 Mon Sep 17 00:00:00 2001 From: Matthew Petrie Date: Tue, 16 Mar 2021 15:36:58 +0000 Subject: [PATCH 4/7] test --- spec/validate.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/validate.spec.js b/spec/validate.spec.js index 11def88..49843e0 100755 --- a/spec/validate.spec.js +++ b/spec/validate.spec.js @@ -252,7 +252,7 @@ describe('Mongo Explain Validate Errors', () => { let errorsReported = 0; db.onValidationError = (errors) => { expect(errors.length).toBe(1); - expect(errors[0].keyword).toBe('bsonType'); + expect(errors[0].keyword).toBe('bsonTypeasdfsd'); expect(errors[0].dataPath).toBe('.created'); errorsReported += 1; if (errorsReported === 2) { From 7b412e49e5ec2fabaac3a1b6b69bbf61562c3265 Mon Sep 17 00:00:00 2001 From: Matthew Petrie Date: Tue, 16 Mar 2021 15:38:46 +0000 Subject: [PATCH 5/7] Revert "test" This reverts commit a7a890ba0b97d9b67171101290fb2298632cf5d3. --- spec/validate.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/validate.spec.js b/spec/validate.spec.js index 49843e0..11def88 100755 --- a/spec/validate.spec.js +++ b/spec/validate.spec.js @@ -252,7 +252,7 @@ describe('Mongo Explain Validate Errors', () => { let errorsReported = 0; db.onValidationError = (errors) => { expect(errors.length).toBe(1); - expect(errors[0].keyword).toBe('bsonTypeasdfsd'); + expect(errors[0].keyword).toBe('bsonType'); expect(errors[0].dataPath).toBe('.created'); errorsReported += 1; if (errorsReported === 2) { From bf6fe0c1cc4c2963c4169ecfa19dd965e79e313d Mon Sep 17 00:00:00 2001 From: Matthew Petrie Date: Tue, 16 Mar 2021 15:39:16 +0000 Subject: [PATCH 6/7] lint error --- index.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/index.js b/index.js index 51163e7..c138c4e 100755 --- a/index.js +++ b/index.js @@ -40,6 +40,11 @@ const explainSchemaErrors = (incomingDb, options = {}) => { }; const originalCollection = db.collection; db.collection = function replacementCollection(...args) { + + + + + const collectionName = args[0]; const col = originalCollection.call(this, ...args); const originalInsertOne = col.insertOne; From a152f1054a3c8506550006cc9f7920afd1f21005 Mon Sep 17 00:00:00 2001 From: Matthew Petrie Date: Tue, 16 Mar 2021 15:41:38 +0000 Subject: [PATCH 7/7] Revert "lint error" This reverts commit bf6fe0c1cc4c2963c4169ecfa19dd965e79e313d. --- index.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/index.js b/index.js index c138c4e..51163e7 100755 --- a/index.js +++ b/index.js @@ -40,11 +40,6 @@ const explainSchemaErrors = (incomingDb, options = {}) => { }; const originalCollection = db.collection; db.collection = function replacementCollection(...args) { - - - - - const collectionName = args[0]; const col = originalCollection.call(this, ...args); const originalInsertOne = col.insertOne;