mirror of
https://github.com/apache/superset.git
synced 2026-04-20 08:34:37 +00:00
build(test env): Shutdown test environments on PR close (#13452)
* Ephemeral env PR close cleanup action * Add documentation for test envs
This commit is contained in:
58
.github/workflows/ephemeral-env-pr-close.yml
vendored
Normal file
58
.github/workflows/ephemeral-env-pr-close.yml
vendored
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
name: Cleanup ephemeral envs (PR close)
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request_target:
|
||||||
|
types: [closed]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
ephemeral-env-cleanup:
|
||||||
|
name: Cleanup ephemeral envs
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Configure AWS credentials
|
||||||
|
uses: aws-actions/configure-aws-credentials@v1
|
||||||
|
with:
|
||||||
|
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||||
|
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||||
|
aws-region: us-west-2
|
||||||
|
|
||||||
|
- name: Describe ECS service
|
||||||
|
id: describe-services
|
||||||
|
run: |
|
||||||
|
echo "::set-output name=active::$(aws ecs describe-services --cluster superset-ci --services pr-${{ github.event.number }}-service | jq '.services[] | select(.status == "ACTIVE") | any')"
|
||||||
|
|
||||||
|
- name: Delete ECS service
|
||||||
|
if: steps.describe-services.outputs.active == 'true'
|
||||||
|
id: delete-service
|
||||||
|
run: |
|
||||||
|
aws ecs delete-service \
|
||||||
|
--cluster superset-ci \
|
||||||
|
--service pr-${{ github.event.number }}-service \
|
||||||
|
--force
|
||||||
|
|
||||||
|
- name: Login to Amazon ECR
|
||||||
|
if: steps.describe-services.outputs.active == 'true'
|
||||||
|
id: login-ecr
|
||||||
|
uses: aws-actions/amazon-ecr-login@v1
|
||||||
|
|
||||||
|
- name: Delete ECR image tag
|
||||||
|
if: steps.describe-services.outputs.active == 'true'
|
||||||
|
id: delete-image-tag
|
||||||
|
run: |
|
||||||
|
aws ecr batch-delete-image \
|
||||||
|
--registry-id $(echo "${{ steps.login-ecr.outputs.registry }}" | grep -Eo "^[0-9]+") \
|
||||||
|
--repository-name superset-ci \
|
||||||
|
--image-ids imageTag=pr-${{ github.event.number }}
|
||||||
|
|
||||||
|
- name: Comment (success)
|
||||||
|
if: steps.describe-services.outputs.active == 'true'
|
||||||
|
uses: actions/github-script@v3
|
||||||
|
with:
|
||||||
|
github-token: ${{secrets.GITHUB_TOKEN}}
|
||||||
|
script: |
|
||||||
|
github.issues.createComment({
|
||||||
|
issue_number: ${{ github.event.number }},
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
body: 'Ephemeral environment shutdown and build artifacts deleted.'
|
||||||
|
})
|
||||||
@@ -39,6 +39,7 @@ little bit helps, and credit will always be given.
|
|||||||
- [Protocol](#protocol)
|
- [Protocol](#protocol)
|
||||||
- [Authoring](#authoring)
|
- [Authoring](#authoring)
|
||||||
- [Reviewing](#reviewing)
|
- [Reviewing](#reviewing)
|
||||||
|
- [Test Environments](#test-environments)
|
||||||
- [Merging](#merging)
|
- [Merging](#merging)
|
||||||
- [Post-merge Responsibility](#post-merge-responsibility)
|
- [Post-merge Responsibility](#post-merge-responsibility)
|
||||||
- [Design Guidelines](#design-guidelines)
|
- [Design Guidelines](#design-guidelines)
|
||||||
@@ -248,6 +249,13 @@ Finally, never submit a PR that will put master branch in broken state. If the P
|
|||||||
- If you are asked to update your pull request with some changes there's no need to create a new one. Push your changes to the same branch.
|
- If you are asked to update your pull request with some changes there's no need to create a new one. Push your changes to the same branch.
|
||||||
- The committers reserve the right to reject any PR and in some cases may request the author to file an issue.
|
- The committers reserve the right to reject any PR and in some cases may request the author to file an issue.
|
||||||
|
|
||||||
|
#### Test Environments
|
||||||
|
|
||||||
|
- Members of the Apache GitHub org can launch an ephemeral test environment directly on a pull request by creating a comment containing (only) the command `/testenv up`
|
||||||
|
- A comment will be created by the workflow script with the address and login information for the ephemeral environment.
|
||||||
|
- Test environments may be created once the Docker build CI workflow for the PR has completed successfully.
|
||||||
|
- Running test environments will be shutdown upon closing the pull request.
|
||||||
|
|
||||||
#### Merging
|
#### Merging
|
||||||
|
|
||||||
- At least one approval is required for merging a PR.
|
- At least one approval is required for merging a PR.
|
||||||
|
|||||||
Reference in New Issue
Block a user