-
Notifications
You must be signed in to change notification settings - Fork 60
39 lines (28 loc) · 1.01 KB
/
test.yaml
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
name: Test
on:
workflow_dispatch:
pull_request:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14.x]
steps:
- uses: actions/checkout@v2
- name: Spin-up the database for tests
run: docker run --name mysql -e MYSQL_ROOT_PASSWORD=P@ssw0rd -v $(pwd):/scripts -d mysql:latest
- name: Wait for the database service to start
run: sleep 15
- name: Populate the database schema for tests
run: docker exec mysql sh -c 'mysql -u root -pP@ssw0rd < /scripts/create-database.sql'
- name: Run the task code
run: docker exec mysql sh -c 'mysql -u root -pP@ssw0rd < /scripts/task.sql'
- name: Run the tests
run: docker exec mysql sh -c 'mysql -u root -pP@ssw0rd < /scripts/test.sql' > log.txt
- name: Check the test results
run: |
echo "checking the test log:"
errors=$(cat log.txt | grep "^Error" || true)
if [ -n "$errors" ]; then echo $errors && exit 1; fi