-
Notifications
You must be signed in to change notification settings - Fork 125
174 lines (162 loc) · 5.39 KB
/
build-app.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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
on:
- push
jobs:
petclinic-graphiql:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./petclinic-graphiql
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 18
- uses: pnpm/[email protected]
name: Install pnpm
id: pnpm-install
with:
version: 8
run_install: false
- name: Install dependencies
run: pnpm install
- name: Build application
run: pnpm build
- name: Archive artifacts
uses: actions/upload-artifact@v3
with:
name: graphiql-dist
path: ./petclinic-graphiql/dist/**
retention-days: 1
backend:
runs-on: ubuntu-latest
needs: petclinic-graphiql
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Java 21
uses: actions/setup-java@v3
with:
java-version: "21"
distribution: "temurin"
cache: maven
- name: Clear embedded graphiql
run: rm -rf backend/src/main/resources/ui/graphiql
- name: Download graphiql
uses: actions/download-artifact@v3
with:
name: graphiql-dist
path: backend/src/main/resources/ui/graphiql
- name: show graphiql artifact
run: ls -lR backend/src/main/resources/ui/
- name: Build with maven
run: ./mvnw -pl backend spring-boot:build-image -Dspring-boot.build-image.imageName=spring-petclinic/petclinic-graphql-backend:0.0.1
- name: Export docker image
run: docker save spring-petclinic/petclinic-graphql-backend:0.0.1|gzip>petclinic-graphql-backend.tar.gz
- name: Archive artifacts
uses: actions/upload-artifact@v3
with:
name: petclinic-backend-docker
path: petclinic-graphql-backend.tar.gz
retention-days: 1
frontend:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./frontend
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 18
- uses: pnpm/[email protected]
name: Install pnpm
id: pnpm-install
with:
version: 8
run_install: false
- name: Install dependencies
run: pnpm install
- name: Code checks
run: pnpm run check
- name: Build application
run: pnpm build
- name: Build frontend docker image
run: docker build . --tag spring-petclinic/petclinic-graphql-frontend:0.0.1
- name: Export frontend docker image
run: docker save spring-petclinic/petclinic-graphql-frontend:0.0.1|gzip>../petclinic-graphql-frontend.tar.gz
- name: LS
run: ls -lR ..
- name: Archive artifacts
uses: actions/upload-artifact@v3
with:
name: petclinic-frontend-docker
path: petclinic-graphql-frontend.tar.gz
retention-days: 1
end-to-end-test:
timeout-minutes: 60
runs-on: ubuntu-latest
needs: [petclinic-graphiql,backend,frontend]
steps:
- name: setup playwright
uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Download backend artifacts
uses: actions/download-artifact@v3
with:
name: petclinic-backend-docker
path: petclinic-backend-docker
- name: Download frontend docker image
uses: actions/download-artifact@v3
with:
name: petclinic-frontend-docker
path: petclinic-frontend-docker
- name: LS
run: ls -lR
- name: Import backend Docker image
run: gunzip -c petclinic-backend-docker/petclinic-graphql-backend.tar.gz|docker load
- name: Import frontend Docker image
run: gunzip -c petclinic-frontend-docker/petclinic-graphql-frontend.tar.gz|docker load
- name: run docker compose
run: docker-compose -f docker-compose-petclinic.yml up -d
- uses: pnpm/[email protected]
name: Install pnpm
id: pnpm-install
with:
version: 8
run_install: false
- name: Install dependencies
working-directory: ./e2e-tests
run: pnpm install
- name: Install Playwright Browsers
working-directory: ./e2e-tests
run: pnpm exec playwright install --with-deps
- name: wait for backend on port 3090
uses: iFaxity/[email protected]
with:
resource: http-get://localhost:3090
- name: wait for frontend on port 3091
uses: iFaxity/[email protected]
with:
resource: http-get://localhost:3091
- name: Run Playwright tests
working-directory: ./e2e-tests
run: pnpm test:docker-compose
- name: Test Report
uses: dorny/test-reporter@v1
if: success() || failure() # run this step even if previous step failed
with:
name: PlayWright Test # Name of the check run which will be created
path: e2e-tests/test-results.xml # Path to test results
reporter: java-junit # Format of test results
- uses: actions/upload-artifact@v3
if: always()
with:
name: playwright-report
path: ./e2e-tests/playwright-report/
retention-days: 2