Skip to content

Commit

Permalink
chore: run integration tests upon pull request approval
Browse files Browse the repository at this point in the history
  • Loading branch information
dani-chmb committed Nov 4, 2024
1 parent 405ede4 commit fc88935
Show file tree
Hide file tree
Showing 4 changed files with 135 additions and 2 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/integ-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
on:
pull_request_review:
types: [submitted]

name: Run Integration Tests

permissions:
id-token: write
contents: read

jobs:
deploy:
name: Deploy
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/GitHubActionsDeployTaskIntegrationTests
role-session-name: deploy_task_integration_tests
aws-region: us-west-2

# - name: Deploy Amazon ECS task definition with one-off task and wait for task stopped set to false
# uses: ./
# with:
# task-definition: test-resources/task-definition-run-task.json
# cluster: github-actions-deploy-task-def-integ-test
# run-task: true
# run-task-subnets: subnet-e5604fce, subnet-fe9355b4, subnet-c49431bc, subnet-392f9b64
# run-task-assign-public-IP: ENABLED
# run-task-security-groups: sg-067ebcde49c0f3ad8
# run-task-launch-type: FARGATE
# wait-for-task-stopped: false

# - name: Deploy Amazon ECS task definition with one-off task and wait for task stopped set to true
# uses: ./
# with:
# task-definition: test-resources/task-definition-run-task.json
# cluster: github-actions-deploy-task-def-integ-test
# run-task: true
# run-task-subnets: subnet-e5604fce, subnet-fe9355b4, subnet-c49431bc, subnet-392f9b64
# run-task-assign-public-IP: ENABLED
# run-task-security-groups: sg-067ebcde49c0f3ad8
# run-task-launch-type: FARGATE
# wait-for-task-stopped: true
# enable-ecs-managed-tags: true

- name: Deploy Amazon ECS task definition with ECS Service
uses: ./
with:
task-definition: test-resources/task-definition.json
service: github-actions-deploy-task-def-integ-test
cluster: github-actions-deploy-task-def-integ-test
wait-for-service-stability: true
enable-ecs-managed-tags: true
21 changes: 19 additions & 2 deletions .mergify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ queue_rules:
- name: default
conditions:
# Conditions to get out of the queue (= merged)
- status-success=Run Integration Tests
- status-success=Run Unit Tests
- status-success=Semantic Pull Request
- status-success=Analyze (javascript)
Expand All @@ -13,6 +14,7 @@ pull_request_rules:
- "#approved-reviews-by>=1"
- approved-reviews-by=@aws-actions/aws-ecs-devx
- -approved-reviews-by~=author
- status-success=Run Integration Tests
- status-success=Run Unit Tests
- status-success=Semantic Pull Request
- status-success=Analyze (javascript)
Expand All @@ -26,7 +28,7 @@ pull_request_rules:
method: squash
name: default

- name: Automatically approve and merge Dependabot PRs
- name: Automatically approve Dependabot PRs
conditions:
- base=master
- author=dependabot[bot]
Expand All @@ -40,6 +42,21 @@ pull_request_rules:
actions:
review:
type: APPROVE

- name: Automatically merge Dependabot PRs

Check failure on line 46 in .mergify.yml

View check run for this annotation

Mergify / Configuration changed

Invalid YAML

while parsing a block mapping in "<unicode string>", line 31, column 5 did not find expected key in "<unicode string>", line 46, column 5
conditions:
- base=master
- "#approved-reviews-by>=1"
- author=dependabot[bot]
- status-success=Run Integration Tests
- status-success=Run Unit Tests
- status-success=Semantic Pull Request
- status-success=Analyze (javascript)
- -title~=(WIP|wip)
- -label~=(blocked|do-not-merge)
- -merged
- -closed
actions:
queue:
method: squash
name: default
name: default
32 changes: 32 additions & 0 deletions test-resources/task-definition-run-task.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"containerDefinitions": [
{
"entryPoint": [
"sh",
"-c"
],
"portMappings": [
{
"hostPort": 80,
"protocol": "tcp",
"containerPort": 80
}
],
"command": [
"/bin/sh -c \"echo '<html> <head> <title>Amazon ECS Sample App</title> <style>body {margin-top: 40px; background-color: #333;} </style> </head><body> <div style=color:white;text-align:center> <h1>Amazon ECS Sample App</h1> <h2>Congratulations!</h2> <p>Your application is now running on a container in Amazon ECS.</p> </div></body></html>' > /usr/local/apache2/htdocs/index.html && httpd-foreground\""
],
"cpu": 256,
"memoryReservation": 512,
"image": "httpd:2.4",
"essential": true,
"name": "sample-app"
}
],
"memory": "512",
"family": "github-actions-deploy-task-def-integ-tests",
"requiresCompatibilities": [
"FARGATE"
],
"networkMode": "awsvpc",
"cpu": "256"
}
25 changes: 25 additions & 0 deletions test-resources/task-definition.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"containerDefinitions": [
{
"memory": 32,
"essential": true,
"entryPoint": ["ping"],
"name": "alpine_ping",
"readonlyRootFilesystem": true,
"image": "alpine:3.4",
"command": [
"-c",
"4",
"example.com"
],
"cpu": 16
}
],
"memory": "512",
"family": "github-actions-deploy-task-def-integ-tests-run-task",
"requiresCompatibilities": [
"FARGATE"
],
"networkMode": "awsvpc",
"cpu": "256"
}

0 comments on commit fc88935

Please sign in to comment.