|
| 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 | + |
0 commit comments