-
Notifications
You must be signed in to change notification settings - Fork 1
209 lines (199 loc) · 7.25 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
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
name: Run Tests
on:
workflow_dispatch:
inputs:
capgo_clone_url:
required: true
type: string
capgo_clone_branch:
required: true
type: string
cli_clone_url:
required: true
type: string
cli_clone_branch:
required: true
type: string
tests_to_run:
required: true
type: string
commit_sha:
required: true
type: string
repo_owner:
required: true
type: string
repo_name:
required: true
type: string
jobs:
test:
runs-on: ubuntu-latest
permissions:
issues: write
name: "Run tests"
steps:
- name: Get Github App Token
uses: tibdex/github-app-token@v1
id: get_installation_token
with:
app_id: 392564
private_key: ${{ secrets.PRIVATE_KEY }}
- name: Change Status (start)
uses: actions/github-script@v6
with:
github-token: ${{ steps.get_installation_token.outputs.token }}
script: |
const job = await github.rest.actions.listJobsForWorkflowRun({
repo: 'github-bot',
owner: 'Cap-go',
run_id: context.runId,
});
const jobId = job.data.jobs[0].id
if (!jobId) {
throw new Error('No job id')
}
const jobUrl = 'https://github.com/Cap-go/github-bot/actions/runs/RUN_ID/job/RUN_NUMBER'.replace('RUN_ID', context.runId).replace('RUN_NUMBER', jobId)
core.exportVariable('JOB_URL', jobUrl)
const commentData = `\n<!--- ${JSON.stringify({ capgo_clone_url: '${{ inputs.capgo_clone_url }}', capgo_clone_branch: '${{ inputs.capgo_clone_branch }}', cli_clone_url: '${{ inputs.cli_clone_url }}', cli_clone_branch: '${{ inputs.cli_clone_branch }}', tests_to_run: '${{ inputs.tests_to_run }}', commit_sha: '${{ inputs.commit_sha }}', repo_owner: '${{ inputs.repo_owner }}', repo_name: '${{ inputs.repo_name }}'})} -->`
core.exportVariable('COMMENT_DATA', commentData)
github.rest.checks.create({
owner: '${{ inputs.repo_owner }}',
repo: '${{ inputs.repo_name }}',
name: 'E2E tests',
status: 'in_progress',
head_sha: '${{ inputs.commit_sha }}',
details_url: jobUrl,
output: {
summary: `The detailed output is available [here](${jobUrl})${commentData}`,
title: 'Testing E2E',
},
})
- name: "Checkout Capgo"
uses: actions/checkout@v4
with:
repository: ${{ inputs.capgo_clone_url }}
ref: ${{ inputs.capgo_clone_branch }}
path: capgo
- name: "Checkout CLI"
uses: actions/checkout@v4
with:
repository: ${{ inputs.cli_clone_url }}
ref: ${{ inputs.cli_clone_branch }}
path: cli
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 18
- uses: pnpm/action-setup@v2
name: Install pnpm
with:
version: 8
run_install: false
- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: cd ./capgo && pnpm install && cd ../cli && pnpm install && cd ..
- name: Install Supabase CLI
uses: supabase/setup-cli@v1
with:
version: 1.68.6
- name: Install Deno
uses: denoland/setup-deno@v1
with:
deno-version: vx.x.x
- name: Cache playwright binaries
id: playwright-cache
uses: actions/cache@v2
with:
path: |
~/Library/Caches/ms-playwright
~/.cache/ms-playwright
${{ github.workspace }}/capgo/node_modules/playwright
key: cache-playwright-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: cache-playwright-
- name: Install Playwright
shell: bash
if: steps.playwright-cache.outputs.cache-hit != 'true'
working-directory: ./capgo
run: pnpm exec playwright install --with-deps chromium
- name: Run Supabase Start
working-directory: ./capgo
run: ENV=local supabase start -x studio,imgproxy,inbucket,logflare --ignore-health-check
- name: Build CLI
working-directory: ./cli
run: pnpm run dev
- name: Start redis
working-directory: ./capgo
run: sh ./tests_backend/gh_actions/docker.sh
- name: Start minio
working-directory: ./capgo
run: sh ./tests_backend/gh_actions/minio.sh
- name: Set env variables
shell: bash
run: |
echo MINIO_URL=$(docker inspect minio1 | grep 'Gateway' | head -n 1 | sed -e 's/ "Gateway": "//g' | sed -e 's/",//g') >> $GITHUB_ENV
echo "CLI_PATH=$(realpath ./cli)" >> $GITHUB_ENV
- name: Run CLI Tests
working-directory: ./capgo
run: deno run --allow-all tests_backend/run_backend_tests.ts ${{ inputs.tests_to_run }}
env:
USE_LOCAL_REDIS: true
UPSTASH_TOKEN: ${{ secrets.UPSTASH_TEST_TOKEN }}
UPSTASH_URL: ${{ secrets.UPSTASH_TEST_URL }}
- name: Change Status (failed)
if: failure()
uses: actions/github-script@v6
with:
github-token: ${{ steps.get_installation_token.outputs.token }}
script: |
const { JOB_URL, COMMENT_DATA } = process.env
github.rest.checks.create({
owner: '${{ inputs.repo_owner }}',
repo: '${{ inputs.repo_name }}',
name: 'E2E tests',
status: 'completed',
conclusion: 'failure',
head_sha: '${{ inputs.commit_sha }}',
details_url: JOB_URL,
output: {
summary: `The detailed output is available [here](${JOB_URL})${COMMENT_DATA}`,
title: 'E2E tests failed',
},
})
- name: Change Stats (success)
if: success()
uses: actions/github-script@v6
with:
github-token: ${{ steps.get_installation_token.outputs.token }}
script: |
const { JOB_URL, COMMENT_DATA } = process.env
github.rest.checks.create({
owner: '${{ inputs.repo_owner }}',
repo: '${{ inputs.repo_name }}',
name: 'E2E tests',
status: 'completed',
conclusion: 'success',
head_sha: '${{ inputs.commit_sha }}',
details_url: JOB_URL,
output: {
summary: `The detailed output is available [here](${JOB_URL})${COMMENT_DATA} `,
title: 'E2E tests succeeded',
},
})
- uses: actions/upload-artifact@v3
if: always()
with:
name: playwright-report
path: capgo/test-results/
if-no-files-found: warn
retention-days: 30