Skip to content

Commit 6bace71

Browse files
authored
Merge pull request #844 from cisagov/CRASM-2286_Bug_fix_regression_yaml
Add command to clone repository into AWS Playwright Container
2 parents 9e28031 + 7a2bc7a commit 6bace71

File tree

2 files changed

+80
-41
lines changed

2 files changed

+80
-41
lines changed

.github/workflows/regression.yml

Lines changed: 75 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ jobs:
2626
runs-on: ubuntu-latest
2727
environment: staging
2828
timeout-minutes: 60
29+
if: github.event_name == 'push' && github.ref == 'refs/heads/develop'
2930
steps:
3031
- uses: actions/checkout@v3
3132
- uses: actions/setup-node@v3
@@ -44,28 +45,43 @@ jobs:
4445
PW_XFD_PASSWORD: ${{ secrets.PW_XFD_PASSWORD }}
4546
PW_XFD_USERNAME: ${{ secrets.PW_XFD_USERNAME }}
4647
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."
6985
7086
continue-on-error: false # Ensure it stops if the ECS task fails
7187

@@ -97,6 +113,7 @@ jobs:
97113
runs-on: ubuntu-latest
98114
environment: integration
99115
timeout-minutes: 60
116+
if: github.event_name == 'push' && github.ref == 'refs/heads/integration'
100117
steps:
101118
- uses: actions/checkout@v3
102119
- uses: actions/setup-node@v3
@@ -115,27 +132,44 @@ jobs:
115132
PW_XFD_PASSWORD: ${{ secrets.PW_XFD_PASSWORD }}
116133
PW_XFD_USERNAME: ${{ secrets.PW_XFD_USERNAME }}
117134
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 \
121139
--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+
}' \
126145
--region ${{ secrets.AWS_REGION }} \
127146
--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+
139173
continue-on-error: false # Ensure it stops if the ECS task fails
140174

141175
- name: Upload test results as artifact
@@ -146,7 +180,7 @@ jobs:
146180

147181
- name: Upload HTML report to S3
148182
run: |
149-
aws s3 cp ./playwright-report/html \
183+
aws s3 cp ./playwright-report/ \
150184
s3://${{ vars.AUTOMATED_TEST_REPORT_BUCKET_NAME }}/\
151185
playwright-reports/html/ --recursive || \
152186
{ echo "HTML report upload failed"; exit 1; }

infrastructure/playwright.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ resource "aws_ecs_task_definition" "playwright_worker" {
8383
"name": "TEST_URL",
8484
"value": "${var.frontend_domain}"
8585
}
86+
],
87+
"command": [
88+
"sh",
89+
"-c",
90+
"echo 'Installing Playwright...'; npx playwright install --with-deps; echo 'Cloning Playwright tests from GitHub...'; git clone https://github.com/cisagov/xfd.git /app/xfd; "
8691
]
8792
}
8893
]

0 commit comments

Comments
 (0)