-
Notifications
You must be signed in to change notification settings - Fork 0
162 lines (142 loc) · 5.64 KB
/
e2e-cypress.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
name: Validate, Import and run E2E Tests
on:
pull_request:
types: [opened, synchronize]
workflow_run:
workflows: ["Clone Project"]
types:
- completed
env:
FILES_PATH: 'project-mvp-gold'
jobs:
validate:
name: Validate Snapshot
runs-on: ubuntu-latest
steps:
- name: Checkout Files
uses: actions/checkout@v4
- name: Get Cloned Project ID via API
id: get-cloned-project-id
run: |
max_attempts=20
delay_seconds=30
attempt=0
while [ $attempt -lt $max_attempts ]; do
attempt=$((attempt + 1))
echo "Attempt $attempt"
PR_NUMBER=$(echo "${GITHUB_REF}" | awk -F'/' '{print $3}')
COMMENTS=$(curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/issues/${PR_NUMBER}/comments")
CLONED_PROJECT_ID=$(echo "$COMMENTS" | jq -r '.[] | select(.body | contains("CLONED_PROJECT_ID_'$PR_NUMBER'")) | .body' | cut -d '=' -f2)
if [ -z "$CLONED_PROJECT_ID" ]; then
echo "Failed to find CLONED_PROJECT_ID in the comments."
if [ $attempt -lt $max_attempts ]; then
echo "Retrying in $delay_seconds seconds..."
sleep $delay_seconds
else
echo "Max attempts reached. Exiting."
exit 1
fi
else
echo "CLONED_PROJECT_ID=$CLONED_PROJECT_ID" >> $GITHUB_ENV
echo "::set-output name=cloned_project_id::$CLONED_PROJECT_ID"
break
fi
done
- name: Validate Snapshot
id: validate
uses: descope/descopecli/.github/actions/[email protected]
with:
project_id: ${{ env.CLONED_PROJECT_ID }}
management_key: ${{ secrets.PRODUCTION_MANAGEMENT_KEY || secrets.MANAGEMENT_KEY }}
files_path: ${{ env.FILES_PATH }}
secrets: ${{ inputs.secrets }}
validate_only: true
import:
if: github.event.pull_request
runs-on: ubuntu-latest
needs: validate
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Get Cloned Project ID via API
id: get-cloned-project-id
run: |
max_attempts=20
delay_seconds=30
attempt=0
while [ $attempt -lt $max_attempts ]; do
attempt=$((attempt + 1))
echo "Attempt $attempt"
PR_NUMBER=$(echo "${GITHUB_REF}" | awk -F'/' '{print $3}')
COMMENTS=$(curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/issues/${PR_NUMBER}/comments")
CLONED_PROJECT_ID=$(echo "$COMMENTS" | jq -r '.[] | select(.body | contains("CLONED_PROJECT_ID_'$PR_NUMBER'")) | .body' | cut -d '=' -f2)
if [ -z "$CLONED_PROJECT_ID" ]; then
echo "Failed to find CLONED_PROJECT_ID in the comments."
if [ $attempt -lt $max_attempts ]; then
echo "Retrying in $delay_seconds seconds..."
sleep $delay_seconds
else
echo "Max attempts reached. Exiting."
exit 1
fi
else
echo "CLONED_PROJECT_ID=$CLONED_PROJECT_ID" >> $GITHUB_ENV
echo "::set-output name=cloned_project_id::$CLONED_PROJECT_ID"
break
fi
done
- name: Import Snapshot
id: import
uses: descope/descopecli/.github/actions/[email protected]
with:
project_id: ${{ env.CLONED_PROJECT_ID }}
management_key: ${{ secrets.PRODUCTION_MANAGEMENT_KEY || secrets.MANAGEMENT_KEY }}
files_path: ${{ env.FILES_PATH }}
secrets: ${{ inputs.secrets }}
import_only: true
e2e-tests:
if: github.event.pull_request
runs-on: ubuntu-latest
needs: import
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Get Cloned Project ID via API
id: get-cloned-project-id
run: |
max_attempts=20
delay_seconds=30
attempt=0
while [ $attempt -lt $max_attempts ]; do
attempt=$((attempt + 1))
echo "Attempt $attempt"
PR_NUMBER=$(echo "${GITHUB_REF}" | awk -F'/' '{print $3}')
COMMENTS=$(curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/issues/${PR_NUMBER}/comments")
CLONED_PROJECT_ID=$(echo "$COMMENTS" | jq -r '.[] | select(.body | contains("CLONED_PROJECT_ID_'$PR_NUMBER'")) | .body' | cut -d '=' -f2)
if [ -z "$CLONED_PROJECT_ID" ]; then
echo "Failed to find CLONED_PROJECT_ID in the comments."
if [ $attempt -lt $max_attempts ]; then
echo "Retrying in $delay_seconds seconds..."
sleep $delay_seconds
else
echo "Max attempts reached. Exiting."
exit 1
fi
else
echo "CLONED_PROJECT_ID=$CLONED_PROJECT_ID" >> $GITHUB_ENV
echo "::set-output name=cloned_project_id::$CLONED_PROJECT_ID"
break
fi
done
- name: Cypress run
uses: cypress-io/github-action@v5
env:
MVP_GOLD_ID: ${{ env.CLONED_PROJECT_ID }}
MANAGEMENT_KEY: ${{ secrets.MANAGEMENT_KEY }}
with:
browser: chrome