Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 75 additions & 41 deletions .github/workflows/regression.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ jobs:
runs-on: ubuntu-latest
environment: staging
timeout-minutes: 60
if: github.event_name == 'push' && github.ref == 'refs/heads/develop'
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
Expand All @@ -44,28 +45,43 @@ jobs:
PW_XFD_PASSWORD: ${{ secrets.PW_XFD_PASSWORD }}
PW_XFD_USERNAME: ${{ secrets.PW_XFD_USERNAME }}
run: |
aws ecs run-task \
--cluster crossfeed-playwright-staging-cd-ecs-cluster \
--task-definition crossfeed-staging-cd-playwright-worker \
--launch-type FARGATE \
--network-configuration \
"awsvpcConfiguration={subnets=[\"${{ secrets.AWS_SUBNET }}\"], \
securityGroups=[\"${{ secrets.AWS_SECURITY_GROUP }}\"], \
assignPublicIp=\"ENABLED\"}" \
--region ${{ secrets.AWS_REGION }} \
--overrides '{
"containerOverrides": [
{
"name": "main",
"command": [
"sh",
"-c",
"npx playwright install && npx playwright test"
]
}
]
}'

# Start the ECS task and capture the task ARN
TASK_ARN=$(aws ecs run-task \
--cluster crossfeed-playwright-staging-cd-ecs-cluster \
--task-definition crossfeed-staging-cd-playwright-worker \
--launch-type FARGATE \
--network-configuration 'awsvpcConfiguration={
"subnets": ["${{ secrets.AWS_SUBNET }}"],
"securityGroups": ["${{ secrets.AWS_SECURITY_GROUP }}"],
"assignPublicIp": "ENABLED"
}' \
--region ${{ secrets.AWS_REGION }} \
--overrides '{
"containerOverrides": [
{
"name": "main",
"command": [
"sh",
"-c",
"echo 'Cloning Playwright tests from GitHub...'; \
git clone https://github.com/cisagov/xfd.git /app/xfd; \
cd /app/xfd/playwright && \
echo 'Running Playwright tests'; \
npx playwright test"
]
}
]
}' \
--query 'tasks[0].taskArn' --output text)

echo "Started ECS Task with ARN: $TASK_ARN"

# Wait for the ECS task to complete
aws ecs wait tasks-stopped \
--cluster crossfeed-playwright-staging-cd-ecs-cluster\
--tasks $TASK_ARN --region ${{ secrets.AWS_REGION }}

echo "ECS task completed. Continuing with the next steps."

continue-on-error: false # Ensure it stops if the ECS task fails

Expand Down Expand Up @@ -97,6 +113,7 @@ jobs:
runs-on: ubuntu-latest
environment: integration
timeout-minutes: 60
if: github.event_name == 'push' && github.ref == 'refs/heads/integration'
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
Expand All @@ -115,27 +132,44 @@ jobs:
PW_XFD_PASSWORD: ${{ secrets.PW_XFD_PASSWORD }}
PW_XFD_USERNAME: ${{ secrets.PW_XFD_USERNAME }}
run: |
aws ecs run-task \
--cluster crossfeed-playwright-integration-ecs-cluster \
--task-definition crossfeed-integration-playwright-worker \
# Start the ECS task and capture the task ARN
TASK_ARN=$(aws ecs run-task \
--cluster crossfeed-playwright-staging-cd-ecs-cluster \
--task-definition crossfeed-staging-cd-playwright-worker \
--launch-type FARGATE \
--network-configuration \
"awsvpcConfiguration={subnets=[\"${{ secrets.AWS_SUBNET }}\"], \
securityGroups=[\"${{ secrets.AWS_SECURITY_GROUP }}\"], \
assignPublicIp=\"ENABLED\"}" \
--network-configuration 'awsvpcConfiguration={
"subnets": ["${{ secrets.AWS_SUBNET }}"],
"securityGroups": ["${{ secrets.AWS_SECURITY_GROUP }}"],
"assignPublicIp": "ENABLED"
}' \
--region ${{ secrets.AWS_REGION }} \
--overrides '{
"containerOverrides": [
{
"name": "main",
"command": [
"sh",
"-c",
"npx playwright install && npx playwright test"
]
}
]
}'
"containerOverrides": [
{
"name": "main",
"command": [
"sh",
"-c",
"echo 'Cloning Playwright tests from GitHub...'; \
git clone https://github.com/cisagov/xfd.git /app/xfd; \
cd /app/xfd/playwright && \
echo 'Running Playwright tests'; \
npx playwright test"
]
}
]
}' \
--query 'tasks[0].taskArn' --output text)

echo "Started ECS Task with ARN: $TASK_ARN"

# Wait for the ECS task to complete
aws ecs wait tasks-stopped \
--cluster crossfeed-playwright-staging-cd-ecs-cluster\
--tasks $TASK_ARN --region ${{ secrets.AWS_REGION }}

echo "ECS task completed. Continuing with the next steps."

continue-on-error: false # Ensure it stops if the ECS task fails

- name: Upload test results as artifact
Expand All @@ -146,7 +180,7 @@ jobs:

- name: Upload HTML report to S3
run: |
aws s3 cp ./playwright-report/html \
aws s3 cp ./playwright-report/ \
s3://${{ vars.AUTOMATED_TEST_REPORT_BUCKET_NAME }}/\
playwright-reports/html/ --recursive || \
{ echo "HTML report upload failed"; exit 1; }
Expand Down
5 changes: 5 additions & 0 deletions infrastructure/playwright.tf
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ resource "aws_ecs_task_definition" "playwright_worker" {
"name": "TEST_URL",
"value": "${var.frontend_domain}"
}
],
"command": [
"sh",
"-c",
"echo 'Installing Playwright...'; npx playwright install --with-deps; echo 'Cloning Playwright tests from GitHub...'; git clone https://github.com/cisagov/xfd.git /app/xfd; "
]
}
]
Expand Down
Loading