-
Notifications
You must be signed in to change notification settings - Fork 2
190 lines (180 loc) · 7.53 KB
/
e2e_tests_preview.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
name: Cypress E2E Tests (Preview Deployment)
#on:
# workflow_dispatch:
# inputs:
# run_deploy:
# description: 'Run deploy-preview job'
# required: false
# type: boolean
# default: false
on:
push:
env:
AWS_REGION: ca-central-1 # set this to your preferred AWS region, e.g. us-west-1
ECR_REPOSITORY: harp-video # set this to your Amazon ECR repository name
ECS_SERVICE: harp-video-website-staging-deployment # set this to your Amazon ECS service name
ECS_CLUSTER: HarpVideoDeployment # set this to your Amazon ECS cluster name
ECS_TASK_DEFINITION: amazon-ecs-task-definition.json # set this to the path to your Amazon ECS task definition
# file, e.g. .aws/task-definition.json
CONTAINER_NAME: harp-video # set this to the name of the container in the
# containerDefinitions section of your task definition
permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout
jobs:
deploy-preview:
name: Deploy
runs-on: ubuntu-latest
environment: preview
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Create env File
run: |
echo "${{ secrets.STAGING_ENV_FILE }}" > .env
# - name: configure aws credentials
# uses: aws-actions/configure-aws-credentials@v3
# with:
# role-to-assume: arn:aws:iam::932748244514:role/GithubActionRole
# role-session-name: GithubActionRole
# aws-region: ${{ env.AWS_REGION }}
# - name: Login to Amazon ECR
# id: login-ecr
# uses: aws-actions/amazon-ecr-login@62f4f872db3836360b72999f4b87f1ff13310f3a
# - name: Build, tag, and push image to Amazon ECR
# id: build-image
# env:
# ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
# IMAGE_TAG: ${{ github.sha }}
# run: |
# # Build a docker container and
# # push it to ECR so that it can
# # be deployed to ECS.
# docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -f Dockerfile.prod .
# docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
# echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT
# - name: Fill in the new image ID in the Amazon ECS task definition
# id: task-def
# uses: aws-actions/amazon-ecs-render-task-definition@c804dfbdd57f713b6c079302a4c01db7017a36fc
# with:
# task-definition: ${{ env.ECS_TASK_DEFINITION }}
# container-name: ${{ env.CONTAINER_NAME }}
# image: ${{ steps.build-image.outputs.image }}
# - name: Deploy Amazon ECS task definition
# uses: aws-actions/amazon-ecs-deploy-task-definition@df9643053eda01f169e64a0e60233aacca83799a
# with:
# task-definition: ${{ steps.task-def.outputs.task-definition }}
# service: ${{ env.ECS_SERVICE }}
# cluster: ${{ env.ECS_CLUSTER }}
# wait-for-service-stability: true
setup-db:
name: Migrate Database
runs-on: ubuntu-latest
needs: ['deploy-preview']
steps:
- uses: actions/checkout@v4
- name: Write environment variables
run: |
echo "${{ secrets.STAGING_ENV_FILE }}" > .env
- name: Install Packages
run: |
npm ci
- name: Generate Prisma
run: |
npx prisma generate
- name: Migrate Database
run: npx prisma migrate deploy
# cypress-e2e:
# name: Run Cypress E2E Tests on Preview Deployment
# runs-on: ubuntu-latest
# needs: [ deploy-preview, setup-db]
# steps:
# - uses: actions/checkout@v4
# - name: Write environment variables
# run: |
# echo "${{ secrets.STAGING_ENV_FILE }}" > .env
# - name: Install Packages
# run: |
# npm ci
# - name: Generate Prisma
# run: |
# npx prisma generate
# - name: Run Cypress Tests
# run: |
# npx cypress run
cypress-e2e:
name: Run cypress E2E tests on preview deployment
runs-on: ubuntu-latest
# needs: [ deploy-preview, setup-db ]
# outputs:
# PR_ID: ${{ steps.save-cypress-outputs.outputs.PR_ID }}
steps:
- uses: actions/checkout@v4
- name: Write environment variables
run: |
echo "${{ secrets.STAGING_ENV_FILE }}" > .env
- name: Install Packages
run: |
npm ci
- name: Generate Prisma
run: |
npx prisma generate
- name: Cypress Run E2E Tests
uses: cypress-io/github-action@v6
# env:
# GITHUB_TOKEN: ${{ secrets.PERSONAL_GITHUB_ACCESS_TOKEN }}
with:
browser: chrome
headed: true
# - name: Upload screenshots
# uses: actions/upload-artifact@v4
# if: failure()
# with:
# name: cypress-screenshots
# path: cypress/screenshots
# if-no-files-found: ignore
# - name: Upload videos
# uses: actions/upload-artifact@v3
# if: failure()
# with:
# name: cypress-videos
# path: cypress/videos
# if-no-files-found: ignore
# - name: Save cypress outputs
# if: always()
# id: save-cypress-outputs
# run: |
# echo "PR_ID=$CYPRESS_PULL_REQUEST_ID" >> $GITHUB_OUTPUT
# - name: Upload test results
# if: always()
# uses: actions/upload-artifact@v3
# with:
# name: e2e-test-results
# path: cypress/reports/e2e/e2e*.json
#
# results-report:
# name: Report results
# runs-on: ubuntu-latest
# if: always()
# needs: [ cypress-e2e ]
# steps:
# - uses: actions/checkout@v4
# - name: Download test results
# uses: actions/download-artifact@v4
# with:
# name: e2e-test-results
# path: cypress/reports
# - name: Merge reports to 1 report file
# run: |
# npx mochawesome-merge cypress/reports/*.json > cypress/reports/test_results.json
# - name: Convert report file to markdown
# run: |
# npx mochawesome-json-to-md@0.7.2 -p cypress/reports/test_results.json -o cypress/reports/test_results.md --reportTitle="E2E Test Results"
# - name: Create report and post on PR
# uses: peter-evans/create-or-update-comment@v3
# env:
# PR_ID: ${{ needs.cypress-e2e.outputs.PR_ID }}
# with:
# issue-number: ${{ env.PR_ID }}
# body-path: cypress/reports/test_results.md
# token: ${{ secrets.PERSONAL_GITHUB_ACCESS_TOKEN }}