-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(enum-updater): add enum updater tool #33681
base: main
Are you sure you want to change the base?
Changes from 1 commit
51189a5
a2345c0
c490248
7c12d5b
967c457
9b9f6dc
160f06c
8a27fbd
e464a45
fde6057
6d600c7
0341da9
8226a3d
69716c9
eb169bb
48fdeb8
e00c3f4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
name: CDK Enums Auto Updater | ||
on: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
update-analytics-metadata: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: It would be better to rename the job name related to enum specific for better readability. |
||
if: github.repository == 'aws/aws-cdk' | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
pull-requests: write | ||
steps: | ||
- name: Set up Node | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: "*" | ||
env: | ||
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 | ||
|
||
- name: Update Enum Static Mapping | ||
run: | | ||
cd tools/@aws-cdk/enum-updater | ||
./bin/update-enums | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. isn't it should be |
||
|
||
- name: Identify Missing Values and Apply Code Changes | ||
run: | | ||
cd tools/@aws-cdk/enum-updater | ||
./bin/update-enums | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. isn't it should be |
||
|
||
- name: Commit & Push changes | ||
if: steps.git-check.outputs.changes == 'true' | ||
run: | | ||
git config --global user.name 'aws-cdk-automation' | ||
git config --global user.email 'aws-cdk-automation@users.noreply.github.com' | ||
|
||
# Iterate through each module directory that has changes | ||
for module in $(git diff --name-only | grep -E '^packages/(@aws-cdk|aws-cdk-lib)/.*' | sed 's|/.*||' | sort -u); do | ||
moduleName=$(basename $module) | ||
|
||
# Check for existing PR with the same name | ||
prExists=$(gh pr list --state open --search "chore(${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 | ||
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 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" | ||
done | ||
|
||
# - name: Commit & Push changes | ||
# if: steps.git-check.outputs.changes == 'true' | ||
# run: | | ||
# git config --global user.name 'aws-cdk-automation' | ||
# git config --global user.email 'aws-cdk-automation@users.noreply.github.com' | ||
|
||
# git checkout -B ${{ github.event.pull_request.head.ref }} | ||
# git add . | ||
# git commit -m "chore: update analytics metadata blueprints" | ||
# git push origin ${{ github.event.pull_request.head.ref }} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,20 @@ | ||
// import { EnumLikeUpdater } from './metadata-updater'; | ||
import { EnumLikeUpdater } from './metadata-updater'; | ||
// TODO: Uncomment out the rest of the updaters and tweak the import before raising a PR. | ||
// If you're reading this on GitHub, someone forgot to double-check! | ||
import { ConstructsUpdater, EnumLikeUpdater, EnumsUpdater, MethodsUpdater, PropertyUpdater } from './metadata-updater'; | ||
|
||
export function main() { | ||
const dir = '../../../../packages/' | ||
|
||
// new ConstructsUpdater(dir).execute(); | ||
// console.log('Constructs updater finished.'); | ||
// new ConstructsUpdater(dir).execute(); | ||
// console.log('Constructs updater finished.'); | ||
|
||
// new PropertyUpdater(dir).execute(); | ||
// console.log('Property updater finished.') | ||
// new PropertyUpdater(dir).execute(); | ||
// console.log('Property updater finished.') | ||
|
||
// new EnumsUpdater(dir).execute(); | ||
// console.log('Enums updater finished.'); | ||
// new EnumsUpdater(dir).execute(); | ||
// console.log('Enums updater finished.'); | ||
|
||
// new MethodsUpdater(dir).execute(); | ||
// console.log('Methods updater finished.'); | ||
// new MethodsUpdater(dir).execute(); | ||
// console.log('Methods updater finished.'); | ||
new ConstructsUpdater(dir).execute(); | ||
console.log('Constructs updater finished.'); | ||
|
||
// new EnumLikeUpdater(dir).TEST(); | ||
// // console.log('Enum-like updater finished.'); | ||
new PropertyUpdater(dir).execute(); | ||
console.log('Property updater finished.') | ||
|
||
new EnumLikeUpdater(dir).TEST(); | ||
new EnumsUpdater(dir).execute(); | ||
console.log('Enums updater finished.'); | ||
|
||
new EnumLikeUpdater(dir).execute(); | ||
console.log('Enums-like updater finished.'); | ||
|
||
new MethodsUpdater(dir).execute(); | ||
console.log('Methods updater finished.'); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So we trigger this workflow only manually? Should it require any cron schedule to run automatically?