Skip to content

Commit

Permalink
Tests working
Browse files Browse the repository at this point in the history
  • Loading branch information
luislobo committed Oct 1, 2023
1 parent cd09abf commit 89a4799
Show file tree
Hide file tree
Showing 7 changed files with 165 additions and 175 deletions.
142 changes: 0 additions & 142 deletions .github/workflows/ci.yaml

This file was deleted.

25 changes: 25 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: sails-mongo lint

on:
push

jobs:
lint:
runs-on: ubuntu-22.04

strategy:
matrix:
node-version: [20]

steps:

- name: Checkout repository
uses: actions/checkout@v3

- name: Install dependencies
run: |
npm install --no-audit --no-fund
- name: Lint the code
run: |
npm run lint-test
42 changes: 42 additions & 0 deletions .github/workflows/test-ubuntu.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: sails-mongo test (Ubuntu)

on:
push

env:
WATERLINE_ADAPTER_TESTS_URL: mongo/testdb:27027
WATERLINE_ADAPTER_TESTS_HOST: mongo
WATERLINE_ADAPTER_TESTS_DATABASE: sails-mongo
NODE_ENV: test

jobs:
test-ubuntu:
runs-on: ubuntu-22.04
container: node:${{ matrix.node-version }}

strategy:
matrix:
node-version: [16, 18, 20]
mongodb-version: ['4.4', '5', '6', '7']

services:
mongo:
image: mongo:${{ matrix.mongodb-version }}
ports:
- 27027:27017

steps:

- name: Checkout repository
uses: actions/checkout@v3

- name: Install dependencies
run: |
node --eval "console.log('Running Node.js: ' + process.version)"
node --eval "console.log('Current directory: ' + process.cwd())"
node --eval "console.log('Files in directory: ' + require('fs').readdirSync(process.cwd()))"
npm install --no-audit --no-fund
- name: Test it out
run: |
npm run custom-tests
62 changes: 62 additions & 0 deletions .github/workflows/test-windows.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: sails-mongo test (Windows)

on:
push

env:
WATERLINE_ADAPTER_TESTS_URL: 127.0.0.1/testdb
WATERLINE_ADAPTER_TESTS_HOST: 127.0.0.1
WATERLINE_ADAPTER_TESTS_DATABASE: sails-mongo
NODE_ENV: test

jobs:
test-windows:
runs-on: windows-2022

strategy:
matrix:
node-version: [16.x, 18.x, 20.x]
mongodb-version: ['5.0']

steps:
- uses: ankane/setup-mongodb@ce30d9041565cb469945895d5bde3384a254dd2e # use commit ID until action is versioned, see https://github.com/ankane/setup-mongodb/issues/2
with:
mongodb-version: ${{ matrix.mongodb-version }}

- name: Wait for MongoDB to start
run: |
while ($true) {
$status = Get-Service MongoDB | Select-Object -ExpandProperty Status
if ($status -eq "Running") {
Write-Host "MongoDB is running."
break
}
Write-Host "Waiting for MongoDB to start..."
Start-Sleep -Seconds 5
}
shell: pwsh

- name: Install Mongodb Shell
run: |
choco install mongodb-shell -y
shell: pwsh

- name: Check connection to Mongodb using mongodb shell
run: |
mongosh --eval "db.adminCommand('listDatabases')"
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

- name: Checkout repository
uses: actions/checkout@v3

- name: Install dependencies
run: |
npm install --no-audit --no-fund
- name: Test code
run: |
npm run custom-tests
44 changes: 23 additions & 21 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
adapter:
image: node:12
volumes:
- $PWD:/home/node/sails-mongo
links:
- mongo
environment:
- WATERLINE_ADAPTER_TESTS_DATABASE=sails-mongo
- WATERLINE_ADAPTER_TESTS_URL=mongo/testdb
- WATERLINE_ADAPTER_TESTS_HOST=mongo
- NODE_ENV=test
user: node
working_dir: /home/node/sails-mongo
command:
- bash -c "npm test"
version: "3.8"
services:
adapter:
image: node:20
volumes:
- $PWD:/home/node/sails-mongo
links:
- mongo
environment:
- WATERLINE_ADAPTER_TESTS_DATABASE=sails-mongo
- WATERLINE_ADAPTER_TESTS_URL=mongo/testdb
- WATERLINE_ADAPTER_TESTS_HOST=mongo
- NODE_ENV=test
user: node
working_dir: /home/node/sails-mongo
command:
- bash -c "npm test"

mongo:
image: mongo:4.2
restart: always
command: "--logpath=/dev/null"
ports:
- "27017:27017"
mongo:
image: mongo:7
restart: always
command: "--logpath=/dev/null"
ports:
- "27017:27017"
24 changes: 13 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
"test": "npm run lint-test && npm run custom-tests",
"custom-tests": "node node_modules/mocha/bin/mocha test/run-adapter-specific-tests && node node_modules/mocha/bin/mocha test/connectable/ && node test/run-standard-tests",
"lint": "node node_modules/eslint/bin/eslint . --max-warnings=0 ",
"lint-test": "node node_modules/eslint/bin/eslint --rule \"linebreak-style: 0\" --max-warnings=0 . ", "start-mongodb": "docker-compose up -d mongo",
"stop-mongodb": "docker-compose down",
"docker": "docker-compose run adapter bash",
"mongodb-shell": "docker-compose exec mongo mongo",
"docker-test": "docker-compose run adapter bash -c \"npm test\" && docker-compose down"
"lint-test": "node node_modules/eslint/bin/eslint --rule \"linebreak-style: 0\" --max-warnings=0 . ",
"start-mongodb": "docker compose up -d mongo",
"stop-mongodb": "docker compose down",
"docker": "docker compose run adapter bash",
"mongodb-shell": "docker compose exec mongo mongosh",
"docker-test": "docker compose run adapter bash -c \"npm test\" && docker compose down"
},
"keywords": [
"mongo",
Expand All @@ -30,7 +31,7 @@
"url": "git://github.com/balderdashy/sails-mongo.git"
},
"dependencies": {
"@sailshq/lodash": "^3.10.4",
"@sailshq/lodash": "3.10.4",
"async": "3.2.4",
"flaverr": "^1.10.0",
"machine": "^15.2.2",
Expand All @@ -39,12 +40,13 @@
},
"devDependencies": {
"benchmark": "2.1.4",
"eslint": "8.41.0",
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint": "8.50.0",
"eslint-plugin-eslint-comments": "3.2.0",
"mocha": "3.0.2",
"waterline": "^0.13.6",
"waterline-adapter-tests": "^1.0.1",
"waterline-utils": "^1.4.2"
"debug": "4.3.4",
"waterline": "0.15.2",
"waterline-adapter-tests": "1.0.1",
"waterline-utils": "1.4.5"
},
"waterlineAdapter": {
"interfaces": [
Expand Down
1 change: 0 additions & 1 deletion test/run-adapter-specific-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -775,4 +775,3 @@ function createModel(identity, options) {
return model;

}

0 comments on commit 89a4799

Please sign in to comment.