-
Notifications
You must be signed in to change notification settings - Fork 1
220 lines (193 loc) · 6.88 KB
/
webclient-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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
name: Web-client tests
on:
pull_request:
branches:
- main
paths:
- "packages/web-client/**"
- ".github/workflows/webclient-deploy.yml"
- ".github/workflows/webclient-setup/action.yml"
- ".github/workflows/webclient-test.yml"
- ".github/workflows/webclient-test-deploy.yml"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
issues: write
pull-requests: write
jobs:
svelte-check:
if: github.event.pull_request.draft == false
timeout-minutes: 2
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
cache: "npm"
- name: Install dependencies & build
run: npm i
- name: Run sync
run: npm run wc:sync
- name: Run svelte-check
run: npm run wc:check
deploy-preview:
needs: ["svelte-check"]
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
outputs:
previewUrl: ${{ steps.preview-url.outputs.url }}
steps:
- uses: actions/checkout@v3
with:
submodules: "true"
- name: Set-up env
uses: ./.github/workflows/webclient-setup
- run: npm run wc:build
- name: Deploy preview build
uses: cloudflare/[email protected]
with:
apiToken: ${{ secrets.CLOUDFLARE_WORKERS_DEPLOY_API_TOKEN }}
workingDirectory: "packages/web-client/"
command: pages publish ".svelte-kit/cloudflare" --branch=${{ github.head_ref }} --project-name=hot-or-not-web-client --commit-dirty=true | tee url.txt
env:
CLOUDFLARE_ACCOUNT_ID: "a209c523d2d9646cc56227dbe6ce3ede"
- name: Get preview deployment URL
id: preview-url
working-directory: "packages/web-client/"
run: |
echo "url=$(grep -o 'http[s]*://[^\\]*' url.txt)" >> $GITHUB_OUTPUT
comment-on-pr:
name: Add a comment with the deployment link on the PR
if: github.actor != 'dependabot[bot]'
needs: ["deploy-preview"]
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v6
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'Deployed on Cloudflare pages: ${{ needs.deploy-preview.outputs.previewUrl }}'
})
google-chat-webhook:
name: Send URL to Google chat workspace
if: github.actor != 'dependabot[bot]'
needs: ["deploy-preview"]
runs-on: ubuntu-latest
steps:
- name: Send deployment URL to Google Chat
uses: fjogeleit/[email protected]
with:
url: "https://chat.googleapis.com/v1/spaces/AAAAAfsrp8U/messages?key=AIzaSyDdI0hCZtE6vySjMm-WEfRq3CPzqKqqsHI&token=_QvV-c8ZdTVTzGZxXW_PdR_o-0HI8VhO3I9dMAp6zls%3D"
method: "POST"
customHeaders: '{"Content-Type": "application/json"}'
data: '{"text": "PR: \"${{ github.event.pull_request.title }}\" deployed at: \n ${{ needs.deploy-preview.outputs.previewUrl }}"}'
tests-lighthouse-reports:
needs: ["svelte-check"]
if: github.event.pull_request.draft == false
timeout-minutes: 40
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: "true"
- uses: actions/setup-node@v3
with:
node-version: 18
cache: "npm"
- name: Install dependencies
run: npm i
- name: Echo expression
run: echo ${{ (github.actor != 'dependabot[bot]' && 'wc:test:record') || 'wc:test' }}
- name: Add Rust wasm target
run: rustup target add wasm32-unknown-unknown
- name: Install DFX
run: DFX_VERSION=0.13.1 sh -ci "$(curl -fsSL https://smartcontracts.org/install.sh)"
- name: Cache rust dependencies, build output and DFX build cache
uses: actions/cache@v3
id: dfx-cache
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
./packages/hot-or-not-backend-canister/target/
./packages/hot-or-not-backend-canister/.dfx/
key: ${{ runner.os }}-testing-${{ hashFiles('**/Cargo.lock') }}
- name: Start DFX Server
if: always()
working-directory: ./packages/hot-or-not-backend-canister
run: dfx start --background
- name: Provision local canister IDs for the canisters
working-directory: ./packages/hot-or-not-backend-canister
run: |
dfx canister create --no-wallet configuration
dfx canister create --no-wallet individual_user_template
dfx canister create --no-wallet user_index
dfx canister create --no-wallet post_cache
- name: Install canisters
if: always()
working-directory: ./packages/hot-or-not-backend-canister
run: ./scripts/canisters/local_deploy/install_all_canisters.sh -si
- name: Test DFX connection
if: always()
run: dfx ping http://localhost:4943
# - name: Run vitest
# run: |
# set -euxo pipefail
# npm run wc:test:vi
- name: Set-up env
uses: ./.github/workflows/webclient-setup
- name: Run Cypress tests
uses: cypress-io/github-action@v5
with:
browser: chrome
project: ./packages/web-client
build: npm run wc:build
start: npm run wc:preview
command: npm run ${{ (github.actor != 'dependabot[bot]' && 'wc:test:record') || 'wc:test' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
CYPRESS_PROJECT_ID: uv7vm5
TEST_HOST: http://localhost:4173
- name: Lighthouse CI check
run: |
npm run wc:build
npm install -g @lhci/cli
lhci_host=http://localhost:4174 lhci autorun
env:
LHCI_GITHUB_APP_TOKEN: ${{ secrets.LHCI_GITHUB_APP_TOKEN }}
- name: Stop DFX Server
run: dfx stop
if: always()
- uses: actions/upload-artifact@v3
if: always()
with:
name: lighthouse-ci-report
path: lhci_report
retention-days: 7
- uses: actions/upload-artifact@v3
if: always()
with:
name: coverage-report
path: packages/web-client/coverage/
retention-days: 7
- uses: actions/upload-artifact@v3
if: always()
with:
name: cypress-report
path: packages/web-client/cypress/
retention-days: 7
- uses: actions/upload-artifact@v3
if: always()
with:
name: cypress-report
path: packages/web-client/cypress/reports/mochawesome-report
retention-days: 7