Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: compile workflow | |
on: | |
pull_request: | |
branches: | |
- main | |
jobs: | |
build: | |
name: Complie check | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 14 | |
- name: Cache dependencies | |
uses: actions/cache@v3 | |
with: | |
path: ~/.npm | |
key: npm-deps-${{ hashFiles('**/package-lock.json') }} | |
- name: Install dependencies | |
run: npm install | |
- name: Setup .env file | |
run: | | |
echo "DB_USER=${{ secrets.DB_USER }}" >> .env | |
echo "DB_PASSWORD=${{ secrets.DB_PASSWORD }}" >> .env | |
echo "DB_NAME=${{ secrets.DB_NAME }}" >> .env | |
echo "DB_HOST=${{ secrets.DB_HOST }}" >> .env | |
echo "PORT=${{ secrets.PORT }}" >> .env | |
echo "TOKEN_SECRET=${{ secrets.TOKEN_SECRET}}" >> .env | |
- name: MySQL Setup | |
run: | | |
sudo apt-get update | |
sudo systemctl start mysql | |
sudo systemctl status mysql | |
sudo mysql --user=root --password=root -e "CREATE DATABASE IF NOT EXISTS restapi;" | |
sudo mysql --user=root --password=root -e "SHOW DATABASES;" | |
sudo mysql --user=root --password=root -e "USE restapi; CREATE TABLE IF NOT EXISTS Users (id CHAR(36) BINARY PRIMARY KEY, firstName VARCHAR(255) NOT NULL, lastName VARCHAR(255) NOT NULL, userName VARCHAR(255) NOT NULL UNIQUE, password VARCHAR(255) NOT NULL, createdAt DATETIME NOT NULL, updatedAt DATETIME NOT NULL);" | |
- name: Test App | |
run: npm test healthz.test.js | |
# - name: Test failure | |
# run: exit 1 | |
test: | |
name: integration test | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 14 | |
- name: Cache dependencies | |
uses: actions/cache@v3 | |
with: | |
path: ~/.npm | |
key: npm-deps-${{ hashFiles('**/package-lock.json') }} | |
- name: Install dependencies | |
run: npm install | |
- name: Setup .env file | |
run: | | |
echo "DB_USER=${{ secrets.DB_USER }}" >> .env | |
echo "DB_PASSWORD=${{ secrets.DB_PASSWORD }}" >> .env | |
echo "DB_NAME=${{ secrets.DB_NAME }}" >> .env | |
echo "DB_HOST=${{ secrets.DB_HOST }}" >> .env | |
echo "PORT=${{ secrets.PORT }}" >> .env | |
echo "TOKEN_SECRET=${{ secrets.TOKEN_SECRET}}" >> .env | |
- name: Configure MySQL | |
run: | | |
sudo apt-get update | |
sudo systemctl start mysql | |
sudo systemctl status mysql | |
sudo mysql --user=root --password=root -e "CREATE DATABASE IF NOT EXISTS restapi;" | |
sudo mysql --user=root --password=root -e "SHOW DATABASES;" | |
sudo mysql --user=root --password=root -e "USE restapi; CREATE TABLE IF NOT EXISTS Users (id CHAR(36) BINARY PRIMARY KEY, firstName VARCHAR(255) NOT NULL, lastName VARCHAR(255) NOT NULL, userName VARCHAR(255) NOT NULL UNIQUE, password VARCHAR(255) NOT NULL, createdAt DATETIME NOT NULL, updatedAt DATETIME NOT NULL);" | |
- name: Test App | |
run: npm test user.test.js |