26
26
runs-on : ubuntu-latest
27
27
environment : staging
28
28
timeout-minutes : 60
29
+ if : github.event_name == 'push' && github.ref == 'refs/heads/develop'
29
30
steps :
30
31
- uses : actions/checkout@v3
31
32
- uses : actions/setup-node@v3
@@ -44,28 +45,43 @@ jobs:
44
45
PW_XFD_PASSWORD : ${{ secrets.PW_XFD_PASSWORD }}
45
46
PW_XFD_USERNAME : ${{ secrets.PW_XFD_USERNAME }}
46
47
run : |
47
- aws ecs run-task \
48
- --cluster crossfeed-playwright-staging-cd-ecs-cluster \
49
- --task-definition crossfeed-staging-cd-playwright-worker \
50
- --launch-type FARGATE \
51
- --network-configuration \
52
- "awsvpcConfiguration={subnets=[\"${{ secrets.AWS_SUBNET }}\"], \
53
- securityGroups=[\"${{ secrets.AWS_SECURITY_GROUP }}\"], \
54
- assignPublicIp=\"ENABLED\"}" \
55
- --region ${{ secrets.AWS_REGION }} \
56
- --overrides '{
57
- "containerOverrides": [
58
- {
59
- "name": "main",
60
- "command": [
61
- "sh",
62
- "-c",
63
- "npx playwright install && npx playwright test"
64
- ]
65
- }
66
- ]
67
- }'
68
-
48
+ # Start the ECS task and capture the task ARN
49
+ TASK_ARN=$(aws ecs run-task \
50
+ --cluster crossfeed-playwright-staging-cd-ecs-cluster \
51
+ --task-definition crossfeed-staging-cd-playwright-worker \
52
+ --launch-type FARGATE \
53
+ --network-configuration 'awsvpcConfiguration={
54
+ "subnets": ["${{ secrets.AWS_SUBNET }}"],
55
+ "securityGroups": ["${{ secrets.AWS_SECURITY_GROUP }}"],
56
+ "assignPublicIp": "ENABLED"
57
+ }' \
58
+ --region ${{ secrets.AWS_REGION }} \
59
+ --overrides '{
60
+ "containerOverrides": [
61
+ {
62
+ "name": "main",
63
+ "command": [
64
+ "sh",
65
+ "-c",
66
+ "echo 'Cloning Playwright tests from GitHub...'; \
67
+ git clone https://github.com/cisagov/xfd.git /app/xfd; \
68
+ cd /app/xfd/playwright && \
69
+ echo 'Running Playwright tests'; \
70
+ npx playwright test"
71
+ ]
72
+ }
73
+ ]
74
+ }' \
75
+ --query 'tasks[0].taskArn' --output text)
76
+
77
+ echo "Started ECS Task with ARN: $TASK_ARN"
78
+
79
+ # Wait for the ECS task to complete
80
+ aws ecs wait tasks-stopped \
81
+ --cluster crossfeed-playwright-staging-cd-ecs-cluster\
82
+ --tasks $TASK_ARN --region ${{ secrets.AWS_REGION }}
83
+
84
+ echo "ECS task completed. Continuing with the next steps."
69
85
70
86
continue-on-error : false # Ensure it stops if the ECS task fails
71
87
97
113
runs-on : ubuntu-latest
98
114
environment : integration
99
115
timeout-minutes : 60
116
+ if : github.event_name == 'push' && github.ref == 'refs/heads/integration'
100
117
steps :
101
118
- uses : actions/checkout@v3
102
119
- uses : actions/setup-node@v3
@@ -115,27 +132,44 @@ jobs:
115
132
PW_XFD_PASSWORD : ${{ secrets.PW_XFD_PASSWORD }}
116
133
PW_XFD_USERNAME : ${{ secrets.PW_XFD_USERNAME }}
117
134
run : |
118
- aws ecs run-task \
119
- --cluster crossfeed-playwright-integration-ecs-cluster \
120
- --task-definition crossfeed-integration-playwright-worker \
135
+ # Start the ECS task and capture the task ARN
136
+ TASK_ARN=$(aws ecs run-task \
137
+ --cluster crossfeed-playwright-staging-cd-ecs-cluster \
138
+ --task-definition crossfeed-staging-cd-playwright-worker \
121
139
--launch-type FARGATE \
122
- --network-configuration \
123
- "awsvpcConfiguration={subnets=[\"${{ secrets.AWS_SUBNET }}\"], \
124
- securityGroups=[\"${{ secrets.AWS_SECURITY_GROUP }}\"], \
125
- assignPublicIp=\"ENABLED\"}" \
140
+ --network-configuration 'awsvpcConfiguration={
141
+ "subnets": ["${{ secrets.AWS_SUBNET }}"],
142
+ "securityGroups": ["${{ secrets.AWS_SECURITY_GROUP }}"],
143
+ "assignPublicIp": "ENABLED"
144
+ }' \
126
145
--region ${{ secrets.AWS_REGION }} \
127
146
--overrides '{
128
- "containerOverrides": [
129
- {
130
- "name": "main",
131
- "command": [
132
- "sh",
133
- "-c",
134
- "npx playwright install && npx playwright test"
135
- ]
136
- }
137
- ]
138
- }'
147
+ "containerOverrides": [
148
+ {
149
+ "name": "main",
150
+ "command": [
151
+ "sh",
152
+ "-c",
153
+ "echo 'Cloning Playwright tests from GitHub...'; \
154
+ git clone https://github.com/cisagov/xfd.git /app/xfd; \
155
+ cd /app/xfd/playwright && \
156
+ echo 'Running Playwright tests'; \
157
+ npx playwright test"
158
+ ]
159
+ }
160
+ ]
161
+ }' \
162
+ --query 'tasks[0].taskArn' --output text)
163
+
164
+ echo "Started ECS Task with ARN: $TASK_ARN"
165
+
166
+ # Wait for the ECS task to complete
167
+ aws ecs wait tasks-stopped \
168
+ --cluster crossfeed-playwright-staging-cd-ecs-cluster\
169
+ --tasks $TASK_ARN --region ${{ secrets.AWS_REGION }}
170
+
171
+ echo "ECS task completed. Continuing with the next steps."
172
+
139
173
continue-on-error : false # Ensure it stops if the ECS task fails
140
174
141
175
- name : Upload test results as artifact
@@ -146,7 +180,7 @@ jobs:
146
180
147
181
- name : Upload HTML report to S3
148
182
run : |
149
- aws s3 cp ./playwright-report/html \
183
+ aws s3 cp ./playwright-report/ \
150
184
s3://${{ vars.AUTOMATED_TEST_REPORT_BUCKET_NAME }}/\
151
185
playwright-reports/html/ --recursive || \
152
186
{ echo "HTML report upload failed"; exit 1; }
0 commit comments