From e0e81358489624bc2d8b9084cb9b1f623bb3df9b Mon Sep 17 00:00:00 2001 From: Sander Blue Date: Fri, 27 Sep 2024 12:20:14 -0500 Subject: [PATCH] chore(automation): attempt 2 to create the first automated PR for codegen --- .github/workflows/generate.yml | 75 ++++++++++++++++++---------- .github/workflows/graphql-schema.yml | 11 ++-- schema-test-new.json | 39 --------------- 3 files changed, 55 insertions(+), 70 deletions(-) diff --git a/.github/workflows/generate.yml b/.github/workflows/generate.yml index 40ab03c6..6b4e8487 100644 --- a/.github/workflows/generate.yml +++ b/.github/workflows/generate.yml @@ -5,20 +5,32 @@ on: # - 'feat/automated-codegen' workflow_dispatch: inputs: + tutoneConfig: + required: true + type: string + description: 'The API endpoints for which to generate code' packages: required: true type: string description: 'A comma-separated list of packages to generate for which to generate code' - apiEndpoints: - required: true + newMutations: + required: false type: string - description: 'The API endpoints for which to generate code' + description: 'A comma-separated list of new mutations' workflow_call: inputs: - apiEndpoints: + tutoneConfig: required: true type: string description: 'The API endpoints for which to generate code' + packages: + required: true + type: string + description: 'A comma-separated list of packages to generate for which to generate code' + newMutations: + required: false + type: string + description: 'A comma-separated list of new mutations' jobs: generate: @@ -29,8 +41,7 @@ jobs: with: go-version: 1.21.x - - name: Add GOBIN to PATH - run: echo "${{ inputs.apiEndpoints }}" + - run: echo "${{ inputs.tutoneConfig }}" shell: bash - name: Add GOBIN to PATH @@ -60,7 +71,7 @@ jobs: uses: DamianReeves/write-file-action@master with: path: .tutone.tmp.yml - contents: ${{inputs.apiEndpoints}} + contents: ${{inputs.tutoneConfig}} - name: Check config file contents run: cat .tutone.tmp.yml @@ -71,29 +82,23 @@ jobs: env: NEW_RELIC_API_KEY: ${{ secrets.NEW_RELIC_API_KEY }} - # - name: Create new branch, commit, and push changes - # shell: bash - # run: | - # branch_name="tmp/generated-code" - - # if git ls-remote --exit-code --heads origin $branch_name > /dev/null; then - # git push origin --delete $branch_name - # fi - - # git checkout -b $branch_name - - # git status - # git add pkg .tutone.tmp.yml - # git status - - # git commit --no-verify -m 'feat(codegen): generate code based on latest API changes' - # git push origin $branch_name + - name: Remove old automation branch if present + shell: bash + run: | + branch_name="automation/generated-code" + if git ls-remote --exit-code --heads origin $branch_name > /dev/null; then + git push origin --delete $branch_name + fi - name: Create pull request + id: create-pull-request uses: peter-evans/create-pull-request@v3 with: base: main - add-paths: 'pkg' + add-paths: | + pkg + .tutone.tmp.yml + types.go author: 'nr-developer-toolkit ' token: ${{ secrets.DEV_TOOLKIT_TOKEN }} commit-message: 'feat(automation): update generated code' @@ -101,7 +106,25 @@ jobs: branch: automation/generated-code title: 'feat(automation): generate code based on latest API changes' body: | - Update generated code using Tutone + ### Automated Pull Request + + The following packages have been added or updated: `${{ inputs.packages }}`. + + The following new mutations will be added to the codebase: + `${{ inputs.newMutations }}` + + Please perform the following actions before merging: + - [ ] Review the changes to the generated code + - [ ] Add new integration tests as necessary + - [ ] Update applicable tests as necessary + - [ ] Double check the .tutone.yml config file for accuracy + + **Note:** If something looks off or you have questions, please reach out to an Observability as Code team member for assistance. labels: | enhancement + automated pr draft: true + + - name: Pull request URL + run: | + echo "Pull Request: ${{ steps.create-pull-request.outputs.pull-request-url }}" diff --git a/.github/workflows/graphql-schema.yml b/.github/workflows/graphql-schema.yml index 9becc4f0..7421a787 100644 --- a/.github/workflows/graphql-schema.yml +++ b/.github/workflows/graphql-schema.yml @@ -14,7 +14,9 @@ jobs: name: Check for API updates runs-on: ubuntu-latest outputs: - apiEndpoints: ${{ steps.schema-diff.outputs.tutone_config }} + tutoneConfig: ${{ steps.schema-diff.outputs.tutone_config }} + newMutations: ${{ steps.schema-diff.outputs.new_api_mutations }} + packages: ${{ steps.schema-diff.outputs.packages }} steps: - name: Install Node uses: actions/setup-node@v4 @@ -160,9 +162,8 @@ jobs: needs: checkForApiUpdates uses: newrelic/newrelic-client-go/.github/workflows/generate.yml@feat/automated-codegen with: - apiEndpoints: ${{ needs.checkForApiUpdates.outputs.apiEndpoints }} + tutoneConfig: ${{ needs.checkForApiUpdates.outputs.tutoneConfig }} + packages: ${{ needs.checkForApiUpdates.outputs.packages }} + newMutations: ${{ needs.checkForApiUpdates.outputs.newMutations }} secrets: inherit - # secrets: - # NEW_RELIC_API_KEY: ${{ secrets.NEW_RELIC_API_KEY }} - # DEV_TOOLKIT_TOKEN: ${{ secrets.DEV_TOOLKIT_TOKEN }} diff --git a/schema-test-new.json b/schema-test-new.json index 9af0499f..3e78b9bb 100644 --- a/schema-test-new.json +++ b/schema-test-new.json @@ -24,45 +24,6 @@ } } ] - }, - { - "name": "userManagementCreateGroup", - "description": "A mutation for creating a group in an authentication domain.", - "type": { - "name": "UserManagementCreateGroupPayload", - "kind": "OBJECT" - }, - "args": [ - { - "name": "createGroupOptions", - "description": "The input object representing the group to create", - "type": { - "name": "UserManagementCreateGroup", - "kind": "INPUT_OBJECT" - } - } - ] - }, - { - "name": "userManagementCreateUser", - "description": "A mutation for creating a user in an authentication domain.", - "type": { - "name": "UserManagementCreateUserPayload", - "kind": "OBJECT" - }, - "args": [ - { - "name": "createUserOptions", - "description": "The input object representing the user to be created.", - "type": { - "kind": "NON_NULL", - "ofType": { - "name": "UserManagementCreateUser", - "kind": "INPUT_OBJECT" - } - } - } - ] } ] },