ci: switch from travis to gh actions

Signed-off-by: Agnes Lin <agneslin.lin@ibm.com>
This commit is contained in:
Agnes Lin 2021-02-18 11:02:59 -05:00
parent c681b2dbe7
commit aa409be420
4 changed files with 49 additions and 27 deletions

View File

@ -0,0 +1,43 @@
name: CI
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
node-version: [10, 12, 14, 15]
services:
mysql:
image: mysql:5.7.22
env:
MYSQL_USER: user
MYSQL_PASSWORD: pass
MYSQL_ALLOW_EMPTY_PASSWORD: yes
MYSQL_DATABASE: 'testdb'
MYSQL_ROOT_PASSWORD: root
steps:
- name: Set Up MySQL
run: sudo /etc/init.d/mysql start
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- name: Create DB and User
run: |
mysql -uroot -proot -e 'CREATE DATABASE testdb;'
mysql -uroot -proot -e "CREATE USER 'user'@'localhost' IDENTIFIED WITH mysql_native_password BY 'pass';"
mysql -uroot -proot -e "GRANT ALL PRIVILEGES ON * . * TO 'user'@'localhost';"
mysql -uroot -proot -e "FLUSH PRIVILEGES"
- run: npm install
- run: npm test

View File

@ -1,21 +0,0 @@
language: node_js
node_js:
- "10"
- "12"
- "14"
# Xenial build environment comes with MySQL 5.7
dist: xenial
services:
- mysql
env:
global:
- MYSQL_HOST=localhost
- MYSQL_PORT=3306
- MYSQL_USER=test
- MYSQL_PASSWORD=test
before_install:
- mysql -u root -e "CREATE USER 'test'@'localhost' IDENTIFIED BY 'test';"
- mysql -e "use mysql; update user set authentication_string=PASSWORD('test') where User='test'; update user set plugin='mysql_native_password';FLUSH PRIVILEGES;"
- mysql -e "GRANT ALL PRIVILEGES ON *.* TO 'test'@'localhost' WITH GRANT OPTION;FLUSH PRIVILEGES;"
- mysql -e "GRANT SUPER ON *.* TO 'test'@'localhost' IDENTIFIED BY 'test';FLUSH PRIVILEGES;"

View File

@ -14,9 +14,9 @@ process.env.MYSQL_HOST =
process.env.MYSQL_PORT = process.env.MYSQL_PORT =
process.env.MYSQL_PORT || process.env.MYSQL_PORT || 3306; process.env.MYSQL_PORT || process.env.MYSQL_PORT || 3306;
process.env.MYSQL_USER = process.env.MYSQL_USER =
process.env.MYSQL_USER || process.env.MYSQL_USER || 'test'; process.env.MYSQL_USER || process.env.MYSQL_USER || 'user';
process.env.MYSQL_PASSWORD = process.env.MYSQL_PASSWORD =
process.env.MYSQL_PASSWORD || process.env.MYSQL_PASSWORD || 'test'; process.env.MYSQL_PASSWORD || process.env.MYSQL_PASSWORD || 'pass';
const fs = require('fs'); const fs = require('fs');
const cp = require('child_process'); const cp = require('child_process');

View File

@ -12,11 +12,11 @@ let DataSource = juggler.DataSource;
const config = require('rc')('loopback', {test: {mysql: {}}}).test.mysql; const config = require('rc')('loopback', {test: {mysql: {}}}).test.mysql;
global.getConfig = function(options) { global.getConfig = function(options) {
const dbConf = { const dbConf = {
host: process.env.MYSQL_HOST || config.host || 'localhost', host: process.env.MYSQL_HOST || config.host || '127.0.0.1',
port: process.env.MYSQL_PORT || config.port || 3306, port: process.env.MYSQL_PORT || config.port || 3306,
database: process.env.MYSQL_DATABASE || 'myapp_test', database: process.env.MYSQL_DATABASE || 'testdb',
username: process.env.MYSQL_USER || config.username, username: process.env.MYSQL_USER || config.username || 'user',
password: process.env.MYSQL_PASSWORD || config.password, password: process.env.MYSQL_PASSWORD || config.password || 'pass',
createDatabase: true, createDatabase: true,
}; };