Skip to content

Commit

Permalink
Update purge test resources (both azure and aws) workflows (radius-pr…
Browse files Browse the repository at this point in the history
  • Loading branch information
ytimocin authored May 7, 2024
1 parent 1f24aa9 commit eb8fa2d
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 7 deletions.
18 changes: 15 additions & 3 deletions .github/workflows/purge-aws-test-resources.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
Expand All @@ -23,8 +23,8 @@ on:

env:
AWS_REGION: us-west-2
AWS_RESOURCE_TYPES: 'AWS::RDS::DBSubnetGroup,AWS::RDS::DBInstance,AWS::S3::Bucket,AWS::Logs::MetricFilter,AWS::Logs::LogGroup'
AWS_RESOURCE_TYPES: "AWS::RDS::DBSubnetGroup,AWS::RDS::DBInstance,AWS::S3::Bucket,AWS::Logs::MetricFilter,AWS::Logs::LogGroup"

jobs:
purge_aws_resources:
name: Delete old AWS resources created by tests
Expand All @@ -40,3 +40,15 @@ jobs:
- name: Delete old AWS resources
run: |
./.github/scripts/delete-aws-resources.sh ${{ env.AWS_RESOURCE_TYPES }}
- name: Create issue for failing purge aws test resources run
uses: actions/github-script@v7
if: failure()
with:
github-token: ${{ secrets.GH_RAD_CI_BOT_PAT }}
script: |
github.rest.issues.create({
...context.repo,
title: `Purge aws test resources failed - Run ID: ${context.runId}`,
labels: ['bug', 'test-failure'],
body: `## Bug information \n\nThis bug is generated automatically if the purge aws test resources workflow fails. For the further investigation, please visit [here](${process.env.ACTION_LINK}).`
})
20 changes: 16 additions & 4 deletions .github/workflows/purge-test-resources.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
Expand All @@ -18,15 +18,15 @@ name: Purge test resources

permissions:
id-token: write # Required for requesting the JWT
contents: read # Required for actions/checkout
contents: read # Required for actions/checkout

on:
schedule:
# Run twice a day
- cron: "30 0,12 * * *"

env:
AZURE_RG_DELETE_LIST_FILE: 'az_rg_list.txt'
AZURE_RG_DELETE_LIST_FILE: "az_rg_list.txt"
# The valid resource time window in seconds to delete the test resources. 6 hours
VALID_RESOURCE_WINDOW: 6*60*60
jobs:
Expand Down Expand Up @@ -93,5 +93,17 @@ jobs:
cat ${{ env.AZURE_RG_DELETE_LIST_FILE}} | while read line
do
echo " * $line" >> $GITHUB_STEP_SUMMARY
az group delete --resource-group $line --yes --verbose
az group delete --resource-group $line --yes --verbose --no-wait
done
- name: Create issue for failing purge test resources run
uses: actions/github-script@v7
if: failure()
with:
github-token: ${{ secrets.GH_RAD_CI_BOT_PAT }}
script: |
github.rest.issues.create({
...context.repo,
title: `Purge test resources failed - Run ID: ${context.runId}`,
labels: ['bug', 'test-failure'],
body: `## Bug information \n\nThis bug is generated automatically if the purge test resources workflow fails. For the further investigation, please visit [here](${process.env.ACTION_LINK}).`
})

0 comments on commit eb8fa2d

Please sign in to comment.