-
Notifications
You must be signed in to change notification settings - Fork 1
102 lines (78 loc) · 3.21 KB
/
compile.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
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