Skip to content

Commit 734b772

Browse files
committed
Switch to Github Actions
Windows version in testing
1 parent a1af638 commit 734b772

File tree

6 files changed

+146
-161
lines changed

6 files changed

+146
-161
lines changed

.github/workflows/ci.yaml

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
name: Node CI
2+
3+
on:
4+
push
5+
6+
env:
7+
WATERLINE_ADAPTER_TESTS_URL: mongo/testdb:27027
8+
WATERLINE_ADAPTER_TESTS_HOST: mongo
9+
WATERLINE_ADAPTER_TESTS_DATABASE: sails-mongo
10+
NODE_ENV: test
11+
12+
jobs:
13+
lint-and-test-ubuntu:
14+
runs-on: ubuntu-20.04
15+
container: node:${{ matrix.node-version }}
16+
17+
# Service containers to run with `container-job`
18+
services:
19+
# Label used to access the service container
20+
mongo:
21+
# Docker Hub image
22+
image: mongo:${{ matrix.mongodb-version }}
23+
# Set health checks to wait until redis has started
24+
options: >-
25+
--health-cmd "mongo --eval 'db.runCommand({ ping: 1 })'"
26+
--health-interval 10s
27+
--health-timeout 5s
28+
--health-retries 5
29+
ports:
30+
- 27027:27017
31+
32+
strategy:
33+
matrix:
34+
node-version: [16, 18, 20]
35+
mongodb-version: ['4.4', '5.0']
36+
37+
steps:
38+
39+
- name: Checkout repository
40+
uses: actions/checkout@v3
41+
42+
# - name: Cache node modules
43+
# id: cache-npm
44+
# uses: actions/cache@v3
45+
# env:
46+
# cache-name: cache-node-modules
47+
# with:
48+
# # npm cache files are stored in `~/.npm` on Linux/macOS
49+
# path: ~/.npm
50+
# key: build-${{ env.cache-name }}-${{ matrix.node-version }}-${{ hashFiles('**/package.json') }}
51+
# restore-keys: |
52+
# ${{ runner.os }}-build-${{ env.cache-name }}-
53+
# ${{ runner.os }}-build-
54+
# ${{ runner.os }}-
55+
#
56+
# - if: ${{ steps.cache-npm.outputs.cache-hit != 'true' }}
57+
# name: List the state of node modules
58+
# continue-on-error: true
59+
# run: npm list
60+
61+
- name: Install dependencies
62+
run: |
63+
npm install --no-audit --no-fund
64+
65+
- name: Lint the code
66+
run: |
67+
npm run lint-test
68+
if: matrix.node-version == '16'
69+
70+
- name: Test it out
71+
run: |
72+
npm run custom-tests
73+
74+
# lint-and-test-windows:
75+
# runs-on: windows-2022
76+
#
77+
# strategy:
78+
# matrix:
79+
# node-version: [16.x] # , 18.x, 20.x]
80+
# mongodb-version: [4.4]
81+
#
82+
# steps:
83+
# - name: Use MongoDB ${{ matrix.mongodb-version }}
84+
# run: |
85+
# # Get versions
86+
# $url = "https://raw.githubusercontent.com/mkevenaar/chocolatey-packages/master/automatic/mongodb.portable/mongodb.portable.json"
87+
# $response = Invoke-WebRequest -Uri $url
88+
# $content = $response.Content.TrimStart([Char]0xFEFF) # Remove BOM
89+
# $global:versions = $content | ConvertFrom-Json
90+
# $version = "${{ matrix.mongodb-version }}"
91+
#
92+
# $fullVersion = $global:versions.$version
93+
# $url = "https://fastdl.mongodb.org/windows/mongodb-windows-x86_64-$fullVersion.zip"
94+
# $zipfile = "mongodb.zip"
95+
# Invoke-WebRequest -Uri $url -OutFile $zipfile
96+
#
97+
# $destination = "C:\mongodb"
98+
# $mongodbPath = "$destination\$version"
99+
# & Expand-Archive -LiteralPath $zipfile -DestinationPath $destination
100+
# & Move-Item -Path "$destination\mongodb-win32-x86_64-windows-$fullVersion" -Destination "$mongodbPath"
101+
# dir $destination
102+
#
103+
# $dataDir = Join-Path -Path $mongodbPath -ChildPath "\data\db"
104+
# New-Item -ItemType Directory -Force -Path $dataDir
105+
# $port = 27027
106+
# & Start-Process -NoNewWindow "$mongodbPath\bin\mongod.exe" -ArgumentList '--quiet', '--dbpath', $dataDir, '--port', $port, '--nojournal', '--oplogSize', 1, '--bind_ip', '127.0.0.1'
107+
#
108+
# echo "Checking MongoDB $version instance..."
109+
# $connected = $false
110+
# $attempts = 0
111+
# do {
112+
# & "$mongodbPath\bin\mongo.exe" --port "$port" --eval "db.runCommand({ ping: 1 })"
113+
# if ($LASTEXITCODE -eq 0) {
114+
# $connected = $true
115+
# } else {
116+
# Write-Output "Unable to connect, retrying..."
117+
# Start-Sleep -Seconds 1
118+
# $attempts++
119+
# }
120+
# } while (!$connected -and $attempts -lt 10)
121+
#
122+
# if (!$connected) {
123+
# Write-Output "Failed to connect to MongoDB $version instance after 10 attempts"
124+
# exit 1
125+
# }
126+
#
127+
# - name: Checkout repository
128+
# uses: actions/checkout@v3
129+
#
130+
# - name: Use Node.js ${{ matrix.node-version }}
131+
# uses: actions/setup-node@v3
132+
# with:
133+
# node-version: ${{ matrix.node-version }}
134+
#
135+
# - name: Install dependencies
136+
# run: |
137+
# npm install --no-audit --no-fund
138+
#
139+
# - name: Test code
140+
# run: |
141+
# npm run custom-tests
142+

.travis.yml

Lines changed: 0 additions & 70 deletions
This file was deleted.

appveyor.yml

Lines changed: 0 additions & 67 deletions
This file was deleted.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
"description": "Mongo DB adapter for Sails.js/Waterline.",
55
"main": "./lib",
66
"scripts": {
7-
"test": "npm run lint && npm run custom-tests",
7+
"test": "npm run lint-test && npm run custom-tests",
88
"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",
9-
"lint": "node node_modules/eslint/bin/eslint . --max-warnings=0",
10-
"start-mongodb": "docker-compose up -d mongo",
9+
"lint": "node node_modules/eslint/bin/eslint . --max-warnings=0 ",
10+
"lint-test": "node node_modules/eslint/bin/eslint --rule \"linebreak-style: 0\" --max-warnings=0 . ", "start-mongodb": "docker-compose up -d mongo",
1111
"stop-mongodb": "docker-compose down",
1212
"docker": "docker-compose run adapter bash",
1313
"mongodb-shell": "docker-compose exec mongo mongo",

scripts/appveyor/install_mongodb.ps1

Lines changed: 0 additions & 20 deletions
This file was deleted.

scripts/travis/install_mongodb.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
22

3-
MDB_TGZ=mongodb-linux-x86_64-ubuntu1604-${MONGODB}.tgz
3+
MDB_TGZ=mongodb-linux-x86_64-ubuntu2004-${MONGODB}.tgz
44
MDB_ROOT=${TRAVIS_BUILD_DIR}/mongodb/${MONGODB}
55
MDB_DATA=${TRAVIS_BUILD_DIR}/mongodb-data
66

0 commit comments

Comments
 (0)