Skip to content

Commit

Permalink
Switch to Github Actions
Browse files Browse the repository at this point in the history
Windows version in testing
  • Loading branch information
luislobo committed May 22, 2023
1 parent a1af638 commit 734b772
Show file tree
Hide file tree
Showing 6 changed files with 146 additions and 161 deletions.
142 changes: 142 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
name: Node CI

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:
lint-and-test-ubuntu:
runs-on: ubuntu-20.04
container: node:${{ matrix.node-version }}

# Service containers to run with `container-job`
services:
# Label used to access the service container
mongo:
# Docker Hub image
image: mongo:${{ matrix.mongodb-version }}
# Set health checks to wait until redis has started
options: >-
--health-cmd "mongo --eval 'db.runCommand({ ping: 1 })'"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 27027:27017

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

steps:

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

# - name: Cache node modules
# id: cache-npm
# uses: actions/cache@v3
# env:
# cache-name: cache-node-modules
# with:
# # npm cache files are stored in `~/.npm` on Linux/macOS
# path: ~/.npm
# key: build-${{ env.cache-name }}-${{ matrix.node-version }}-${{ hashFiles('**/package.json') }}
# restore-keys: |
# ${{ runner.os }}-build-${{ env.cache-name }}-
# ${{ runner.os }}-build-
# ${{ runner.os }}-
#
# - if: ${{ steps.cache-npm.outputs.cache-hit != 'true' }}
# name: List the state of node modules
# continue-on-error: true
# run: npm list

- name: Install dependencies
run: |
npm install --no-audit --no-fund
- name: Lint the code
run: |
npm run lint-test
if: matrix.node-version == '16'

- name: Test it out
run: |
npm run custom-tests
# lint-and-test-windows:
# runs-on: windows-2022
#
# strategy:
# matrix:
# node-version: [16.x] # , 18.x, 20.x]
# mongodb-version: [4.4]
#
# steps:
# - name: Use MongoDB ${{ matrix.mongodb-version }}
# run: |
# # Get versions
# $url = "https://raw.githubusercontent.com/mkevenaar/chocolatey-packages/master/automatic/mongodb.portable/mongodb.portable.json"
# $response = Invoke-WebRequest -Uri $url
# $content = $response.Content.TrimStart([Char]0xFEFF) # Remove BOM
# $global:versions = $content | ConvertFrom-Json
# $version = "${{ matrix.mongodb-version }}"
#
# $fullVersion = $global:versions.$version
# $url = "https://fastdl.mongodb.org/windows/mongodb-windows-x86_64-$fullVersion.zip"
# $zipfile = "mongodb.zip"
# Invoke-WebRequest -Uri $url -OutFile $zipfile
#
# $destination = "C:\mongodb"
# $mongodbPath = "$destination\$version"
# & Expand-Archive -LiteralPath $zipfile -DestinationPath $destination
# & Move-Item -Path "$destination\mongodb-win32-x86_64-windows-$fullVersion" -Destination "$mongodbPath"
# dir $destination
#
# $dataDir = Join-Path -Path $mongodbPath -ChildPath "\data\db"
# New-Item -ItemType Directory -Force -Path $dataDir
# $port = 27027
# & Start-Process -NoNewWindow "$mongodbPath\bin\mongod.exe" -ArgumentList '--quiet', '--dbpath', $dataDir, '--port', $port, '--nojournal', '--oplogSize', 1, '--bind_ip', '127.0.0.1'
#
# echo "Checking MongoDB $version instance..."
# $connected = $false
# $attempts = 0
# do {
# & "$mongodbPath\bin\mongo.exe" --port "$port" --eval "db.runCommand({ ping: 1 })"
# if ($LASTEXITCODE -eq 0) {
# $connected = $true
# } else {
# Write-Output "Unable to connect, retrying..."
# Start-Sleep -Seconds 1
# $attempts++
# }
# } while (!$connected -and $attempts -lt 10)
#
# if (!$connected) {
# Write-Output "Failed to connect to MongoDB $version instance after 10 attempts"
# exit 1
# }
#
# - name: Checkout repository
# uses: actions/checkout@v3
#
# - name: Use Node.js ${{ matrix.node-version }}
# uses: actions/setup-node@v3
# with:
# node-version: ${{ matrix.node-version }}
#
# - name: Install dependencies
# run: |
# npm install --no-audit --no-fund
#
# - name: Test code
# run: |
# npm run custom-tests

70 changes: 0 additions & 70 deletions .travis.yml

This file was deleted.

67 changes: 0 additions & 67 deletions appveyor.yml

This file was deleted.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
"description": "Mongo DB adapter for Sails.js/Waterline.",
"main": "./lib",
"scripts": {
"test": "npm run lint && npm run custom-tests",
"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",
"start-mongodb": "docker-compose up -d mongo",
"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",
Expand Down
20 changes: 0 additions & 20 deletions scripts/appveyor/install_mongodb.ps1

This file was deleted.

2 changes: 1 addition & 1 deletion scripts/travis/install_mongodb.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

MDB_TGZ=mongodb-linux-x86_64-ubuntu1604-${MONGODB}.tgz
MDB_TGZ=mongodb-linux-x86_64-ubuntu2004-${MONGODB}.tgz
MDB_ROOT=${TRAVIS_BUILD_DIR}/mongodb/${MONGODB}
MDB_DATA=${TRAVIS_BUILD_DIR}/mongodb-data

Expand Down

0 comments on commit 734b772

Please sign in to comment.