From db499253e5cc98006c3e64c597270dc14e0eeafc Mon Sep 17 00:00:00 2001 From: Agnes Lin Date: Sat, 10 Apr 2021 23:07:56 -0400 Subject: [PATCH] ci: try mirror Signed-off-by: Agnes Lin --- .github/workflows/continuous-integration.yaml | 92 +++++++++++++++++-- pretest.js | 6 +- test/init.js | 8 +- 3 files changed, 91 insertions(+), 15 deletions(-) diff --git a/.github/workflows/continuous-integration.yaml b/.github/workflows/continuous-integration.yaml index 420e627..cbcb0fa 100644 --- a/.github/workflows/continuous-integration.yaml +++ b/.github/workflows/continuous-integration.yaml @@ -13,19 +13,41 @@ jobs: matrix: # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ node-version: [10, 12, 14, 15] +<<<<<<< HEAD + + # services: + # mysql: + # image: mysql:5.7 + # env: + # MYSQL_USER: user + # MYSQL_PASSWORD: pass + # MYSQL_ALLOW_EMPTY_PASSWORD: yes + # MYSQL_DATABASE: 'testdb' + # MYSQL_ROOT_PASSWORD: root + # MYSQL_HOST: localhost + # ports: + # - 3306:3306 + # options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 +======= services: mysql: - image: mysql:5.7.22 + image: mysql:5.7 env: MYSQL_USER: user MYSQL_PASSWORD: pass MYSQL_ALLOW_EMPTY_PASSWORD: yes - MYSQL_DATABASE: 'testdb' + MYSQL_DATABASE: testdb MYSQL_ROOT_PASSWORD: root + MYSQL_HOST: localhost + MYSQL_PORT: 3307 + ports: + - 3307:3307 + options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 +>>>>>>> f50d049... ci: port 3307 steps: - - name: Set Up MySQL - run: sudo /etc/init.d/mysql start + - name: Shutdown Ubuntu MySQL (SUDO) + run: sudo service mysql stop - uses: actions/checkout@v2 - name: Use Node.js ${{ matrix.node-version }} @@ -33,11 +55,65 @@ jobs: with: node-version: ${{ matrix.node-version }} + + # - uses: docker://library/mysql:5.7 + # - name: Set up MySQL 5.7 + # uses: mirromutth/mysql-action@master + # with: + # mysql version: 5.7 + # mysql database: testdb + # mysql root password: root + # - name: npm install, build, and test + # run: | + # npm install + # npm test + # env: + # CI: true + + - name: Create DB and User + # # # the first line is crucial 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" + sudo /etc/init.d/mysql start + sudo systemctl enable mysql.service + sudo systemctl start mysql.service + docker container ls + docker container run -e MYSQL_ROOT_PASSWORD=root -e MYSQL_PORT=3307 -e MYSQL_HOST=localhost -d mysql:5.7 + mysql -V + # sudo service mysql stop + # mysql -V + # docker run -it mysql + # docker exec `docker ps -q` mysqld --version --mount "type=bind,src=/run/mysqld,dst=/var/run/mysqld" + # npm install + # npm test + # sudo /etc/init.d/mysql start + # mysql -V + # mysql --host 127.0.0.1 --port ${{ job.services.mysql.ports['3306'] }} -uroot -proot -e "SHOW DATABASES" + # docker image ls + # docker container ls + # sudo systemctl enable mysql.service + # docker exec `docker ps -q` mysqld --version + # mysql -V + # mysql -e 'CREATE DATABASE testdb;' -uroot -proot + # mysql -e 'SHOW DATABASES;' -uroot -proot + # 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: | + # sudo /etc/init.d/mysql start + # /usr/bin/docker + # docker.io/library/mysql:5.7 + # sudo netstat -ln | grep mysql + # mysqladmin -proot -uroot root variables + # 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 + env: + DB_PORT: ${{ job.services.mysql.ports[3307] }} + # env: + # host: 127.0.0.1 + # sudo ls -a /var/run/mysqld/ + diff --git a/pretest.js b/pretest.js index b68d509..5b3e857 100644 --- a/pretest.js +++ b/pretest.js @@ -12,11 +12,11 @@ if (!process.env.CI) { process.env.MYSQL_HOST = process.env.MYSQL_HOST || process.env.MYSQL_HOST || 'localhost'; process.env.MYSQL_PORT = - process.env.MYSQL_PORT || process.env.MYSQL_PORT || 3306; + process.env.MYSQL_PORT || process.env.MYSQL_PORT || 3307; process.env.MYSQL_USER = - process.env.MYSQL_USER || process.env.MYSQL_USER || 'user'; + process.env.MYSQL_USER || process.env.MYSQL_USER || 'root'; process.env.MYSQL_PASSWORD = - process.env.MYSQL_PASSWORD || process.env.MYSQL_PASSWORD || 'pass'; + process.env.MYSQL_PASSWORD || process.env.MYSQL_PASSWORD || 'root'; const fs = require('fs'); const cp = require('child_process'); diff --git a/test/init.js b/test/init.js index d729a57..6bba46c 100644 --- a/test/init.js +++ b/test/init.js @@ -12,11 +12,11 @@ let DataSource = juggler.DataSource; const config = require('rc')('loopback', {test: {mysql: {}}}).test.mysql; global.getConfig = function(options) { const dbConf = { - host: process.env.MYSQL_HOST || config.host || '127.0.0.1', - port: process.env.MYSQL_PORT || config.port || 3306, + host: process.env.MYSQL_HOST || config.host || 'localhost', + port: process.env.MYSQL_PORT || config.port || 3307, database: process.env.MYSQL_DATABASE || 'testdb', - username: process.env.MYSQL_USER || config.username || 'user', - password: process.env.MYSQL_PASSWORD || config.password || 'pass', + username: process.env.MYSQL_USER || config.username || 'root', + password: process.env.MYSQL_PASSWORD || config.password || 'root', createDatabase: true, };