-
Notifications
You must be signed in to change notification settings - Fork 0
153 lines (128 loc) · 3.9 KB
/
test.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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
name: test
on: push
jobs:
backend:
name: 'Rails API Tests'
runs-on: ubuntu-latest
services:
postgres:
image: postgres:latest
env:
POSTGRES_USER: postgres_user
POSTGRES_PASSWORD: testpassword
POSTGRES_DB: monitoring_sys_test
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U postgres"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.3.4'
- name: Install dependencies
run: |
cd backend
gem install bundler
bundle install
- name: Set up environment variables
run: |
echo "DATABASE_HOST=localhost" >> $GITHUB_ENV
echo "DATABASE_USER=postgres_user" >> $GITHUB_ENV
echo "DATABASE_PASSWORD=testpassword" >> $GITHUB_ENV
- name: Set up database
run: |
cd backend
RAILS_ENV=test rails db:create
RAILS_ENV=test rails db:migrate
RAILS_ENV=test rails db:seed
- name: Run RSpec tests
run: |
cd backend
RAILS_ENV=test bundle exec rspec
frontend:
name: 'Vue Frontend Tests'
runs-on: ubuntu-latest
needs: backend # Ensure frontend tests run after backend tests
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '21'
- name: Install dependencies
run: |
cd frontend
yarn install
- name: Run Jest tests
run: |
cd frontend
yarn test:unit --ci --reporters=default --reporters=jest-junit
- name: Upload Jest Test Report
uses: actions/upload-artifact@v3
with:
name: jest-test-report
path: frontend/junit.xml
# - name: Display Jest Test Results
# uses: dorny/test-reporter@v1
# if: always() # Run this step even if previous steps fail
# with:
# name: Jest Tests
# path: frontend/junit.xml
# reporter: jest-junit
# - name: Start Rails server
# run: |
# cd backend
# bin/rails server -e test & # Run the server in the background
# - name: Wait for Rails server to be ready
# run: |
# until curl -s http://localhost:3000 > /dev/null; do
# echo "Waiting for Rails server..."
# sleep 2
# done
end-to-end:
name: 'End to End Tests'
runs-on: ubuntu-latest
container:
image: mcr.microsoft.com/playwright:v1.45.1-jammy
needs: [backend, frontend]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
- name: Install dependencies
run: |
cd frontend
yarn install
# - name: Install Playwright Browsers
# run: npx playwright install --with-deps
- name: Run Playwright tests
run: |
cd frontend
yarn test:e2e
- name: Upload Playwright HTML Test Report
uses: actions/upload-artifact@v3
with:
name: playwright-report
path: frontend/playwright-report
- name: Upload Playwright Test Report
uses: actions/upload-artifact@v3
with:
name: playwright-report
path: frontend/playwright-tests.xml
# - name: Display Playwright Test Results
# uses: dorny/test-reporter@v1
# if: always() # Run this step even if previous steps fail
# with:
# name: Playwright Tests
# path: frontend/playwright-tests.xml
# reporter: java-junit