Skip to content
39 changes: 25 additions & 14 deletions .github/workflows/enum-auto-updater.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
NODE_OPTIONS: "--max-old-space-size=8196 --experimental-worker ${NODE_OPTIONS:-}"

- name: Install dependencies
run: yarn install --frozen-lockfile && cd tools/@aws-cdk/enum-updater && yarn build
run: cd tools/@aws-cdk/enum-updater && yarn install --frozen-lockfile && yarn build

- name: Identify Missing Values and Apply Code Changes
run: |
Expand All @@ -36,6 +36,11 @@ jobs:
else
echo "changes=false" >> $GITHUB_OUTPUT
fi

# Authentication is required for gh cli
- name: Setup GitHub CLI
run: |
gh auth login --with-token <<< "${{ secrets.GITHUB_TOKEN }}"

- name: Commit & Push changes
if: steps.git-check.outputs.changes == 'true'
Expand All @@ -46,33 +51,39 @@ jobs:
# Iterate through each module directory that has changes
for module in $(git diff --name-only | grep -E '^packages/(@aws-cdk|aws-cdk-lib)/.*' | sed -E 's|^packages/(@aws-cdk\|aws-cdk-lib)/([^/]+).*|\2|' | sort -u); do
moduleName=$(basename $module)

# Determine the correct path for the module
if [[ -d "packages/aws-cdk-lib/$module" ]]; then
modulePath="packages/aws-cdk-lib/$module"
elif [[ -d "packages/@aws-cdk/$module" ]]; then
modulePath="packages/@aws-cdk/$module"
else
echo "Cannot find module directory for $module"
continue
fi

# Check for existing PR with the same name
prExists=$(gh pr list --state open --search "feat(${moduleName#aws-}): add new enum values for ${moduleName#aws-}" --json number,title -q '.[].number')

# If a PR exists, close it and continue
if [[ -n "$prExists" ]]; then
echo "PR already exists for module ${moduleName#aws-}, closing the existing PR."
gh pr close "$prExists" --confirm # Close the PR by its number
gh pr close "$prExists" --confirm
fi

# Create a new branch for the module
branchName="enum-update/${moduleName#aws-}"
git checkout -b "$branchName"

# Stage, commit, and push changes for the module
git add "packages/$module" # Add only changes for this module
git add "$modulePath" # Using the correct path
git commit -m "chore(${moduleName#aws-}): add new enum values for ${moduleName#aws-}"
git push origin "$branchName"

# Create a new pull request
gh pr create --title "chore(${moduleName#aws-}): add new enum values for ${moduleName#aws-}" \
--body "This PR updates the enum values for ${moduleName#aws-}." \
--base main \
--head "$branchName"
--label "contribution/core,pr-linter/exempt-integ-test,pr-linter/exempt-readme,pr-linter/exempt-test" \
--reviewer "aws-cdk-team" \
done

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Create a new pull request
gh pr create --title "chore(${moduleName#aws-}): add new enum values for ${moduleName#aws-}" \
--body "This PR updates the enum values for ${moduleName#aws-}." \
--base main \
--head "$branchName" \
--label "contribution/core,pr-linter/exempt-integ-test,pr-linter/exempt-readme,pr-linter/exempt-test"
done
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"@nx/workspace": "^20",
"@types/node": "18.11.19",
"@types/prettier": "2.6.0",
"@types/tmp": "^0.2.6",
"@yarnpkg/lockfile": "^1.1.0",
"aws-sdk-js-codemod": "^0.28.2",
"cdk-generate-synthetic-examples": "^0.2.22",
Expand Down Expand Up @@ -88,6 +89,7 @@
"tools/@aws-cdk/lazify",
"tools/@aws-cdk/lambda-integration-test-updater",
"tools/@aws-cdk/construct-metadata-updater",
"tools/@aws-cdk/enum-updater",
"scripts/@aws-cdk/script-tests"
],
"nohoist": [
Expand Down
12 changes: 12 additions & 0 deletions packages/aws-cdk-lib/aws-autoscaling/lib/auto-scaling-group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2392,6 +2392,14 @@ export class HealthChecks {
enum HealthCheckType {
EC2 = 'EC2',
ELB = 'ELB',
/**
* PLACEHOLDER_COMMENT_TO_BE_FILLED_OUT
*/
EBS = 'EBS',
/**
* PLACEHOLDER_COMMENT_TO_BE_FILLED_OUT
*/
VPC_LATTICE = 'VPC_LATTICE',
}

/**
Expand All @@ -2410,6 +2418,10 @@ export enum AdditionalHealthCheckType {
* VPC LATTICE Health Check
*/
VPC_LATTICE = 'VPC_LATTICE',
/**
* PLACEHOLDER_COMMENT_TO_BE_FILLED_OUT
*/
EC2 = 'EC2',
}

/**
Expand Down
5 changes: 5 additions & 0 deletions packages/aws-cdk-lib/aws-autoscaling/lib/volume.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,4 +210,9 @@ export enum EbsDeviceVolumeType {
* Cold HDD
*/
SC1 = 'sc1',

/**
* PLACEHOLDER_COMMENT_TO_BE_FILLED_OUT
*/
IO2 = 'io2',
}
5 changes: 3 additions & 2 deletions tools/@aws-cdk/enum-updater/lib/missing-enum-updater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,10 +311,11 @@ export class MissingEnumsUpdater {
let textToInsert = hasDoubleLineBreaks ? '\n' : '';

newEnumValues.forEach((enumVal: string, index: number) => {
const enumConstantName = enumVal.toUpperCase().replace(/[^A-Z0-9]+/g, '_').replace(/_+$/, '');
const enumValue = enumVal.toString();
const enumConstantName = enumValue.toUpperCase().replace(/[^A-Z0-9]+/g, '_').replace(/_+$/, '');

textToInsert += ` /**\n * PLACEHOLDER_COMMENT_TO_BE_FILLED_OUT\n */\n`;
textToInsert += ` ${enumConstantName} = '${enumVal}'`;
textToInsert += ` ${enumConstantName} = '${enumValue}'`;

// Add a comma and appropriate newlines after each member
textToInsert += ',';
Expand Down
Loading