forked from CISC375/Sage
-
Notifications
You must be signed in to change notification settings - Fork 1
98 lines (81 loc) · 2.67 KB
/
automaticTesting.yml
File metadata and controls
98 lines (81 loc) · 2.67 KB
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
name: Run Jest Tests
on:
workflow_call:
# push:
# branches:
# - mizuho-githubaction # Run on push to `mizuho-githubaction` branch
# - 'feature/*' # Or you can specify any feature branches you want to test
# pull_request:
# branches:
# - mizuho-githubaction # Run on pull request targeting `mizuho-githubaction` branch
jobs:
unit_tests:
if: github.event_name == 'push' || github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.sha }}
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
- name: Install required system dependencies
run: |
sudo apt-get update
sudo apt-get install -y libcairo2-dev libjpeg-dev libpango1.0-dev libgif-dev build-essential g++
- name: Clean npm cache and install deps
run: |
npm cache clean --force
npm ci
- name: Set config file
run: cp config.example.ts config.ts
- name: Show Jest config
run: npx jest --showConfig | sed -n '1,120p'
- name: Run Unit Tests
run: npx jest -c jest.config.js --no-cache --testPathIgnorePatterns=".*integration.*"
integration_tests:
if: github.event_name == 'push' || github.event_name == 'pull_request'
runs-on: ubuntu-latest
needs: unit_tests
services:
mongodb:
image: mongo:5.0
env:
MONGO_INITDB_ROOT_USERNAME: test
MONGO_INITDB_ROOT_PASSWORD: test
ports:
- 27017:27017
options: >-
--health-cmd mongosh
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.sha }}
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
- name: Install required system dependencies
run: |
sudo apt-get update
sudo apt-get install -y libcairo2-dev libjpeg-dev libpango1.0-dev libgif-dev build-essential g++
- name: Clean npm cache and install deps
run: |
npm cache clean --force
npm ci
- name: Set config file
run: cp config.example.ts config.ts
- name: Run Integration Tests
run: npx jest -c jest.config.js --no-cache --testMatch="**/*integration*.test.ts"
env:
MONGODB_URI: mongodb://test:test@localhost:27017/sage_test?authSource=admin