From 4d650cb6b43ce33ce00906825487c9f89abaa1e5 Mon Sep 17 00:00:00 2001 From: Anthony Martin <38542602+anthony-c-martin@users.noreply.github.com> Date: Mon, 24 Jul 2023 10:56:36 -0400 Subject: [PATCH] Reorganize GH Actions --- .github/workflows/generate-schemas-batch.yml | 116 ------------------- .github/workflows/generate-schemas.yml | 109 ++++++++++++----- .github/workflows/generate-single.yml | 61 ++++++++++ .github/workflows/main.yml | 23 ++-- generator/autogenlist.ts | 1 - generator/constants.ts | 1 - 6 files changed, 151 insertions(+), 160 deletions(-) delete mode 100644 .github/workflows/generate-schemas-batch.yml create mode 100644 .github/workflows/generate-single.yml diff --git a/.github/workflows/generate-schemas-batch.yml b/.github/workflows/generate-schemas-batch.yml deleted file mode 100644 index 417a17a96f..0000000000 --- a/.github/workflows/generate-schemas-batch.yml +++ /dev/null @@ -1,116 +0,0 @@ -name: Generate Schemas Batch - -on: - schedule: - - cron: '45 5 * * SUN' - workflow_dispatch: - inputs: - api_specs_ref: - description: 'Git ref or full SHA for https://github.com/Azure/azure-rest-api-specs.' - required: true - default: 'main' - -env: - # This must be kept in sync with the arguments passed to the "batch" matrix - BATCH_COUNT: 20 - -jobs: - generate: - name: Update Schemas Batch ${{ matrix.batch }} - runs-on: ubuntu-latest - strategy: - matrix: - batch: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19] - steps: - - name: Checkout repo - uses: actions/checkout@v3 - - - name: Clone azure-rest-api-specs - uses: actions/checkout@v3 - with: - repository: Azure/azure-rest-api-specs - path: workflow-temp/azure-rest-api-specs - ref: ${{ github.event.inputs.api_specs_ref }} - - - name: Setup Node.js - uses: actions/setup-node@v3 - with: - node-version: 16.x - - - name: Install generator npm packages - run: npm ci - working-directory: generator - - - name: Run generator - run: | - rm -Rf "$GITHUB_WORKSPACE/schemas" - rm -Rf "$GITHUB_WORKSPACE/summary.log" - mkdir -p "$GITHUB_WORKSPACE/schemas" - - npm run generate-all -- \ - --local-path "$GITHUB_WORKSPACE/workflow-temp/azure-rest-api-specs" \ - --batch-count ${{ env.BATCH_COUNT }} \ - --batch-index ${{ matrix.batch }} \ - --summary-log-path "$GITHUB_WORKSPACE/summary.log" \ - --combine-batch-mode true - working-directory: generator - - - name: Upload Schemas - uses: actions/upload-artifact@v3 - with: - name: batch-${{ matrix.batch }}-schemas - path: schemas - if-no-files-found: error - - - name: Upload summary log - uses: actions/upload-artifact@v3 - with: - name: batch-${{ matrix.batch }}-summary - path: summary.log - if-no-files-found: error - - combine: - needs: generate - name: Combine Schema Batches - runs-on: ubuntu-latest - steps: - - name: Checkout repo - uses: actions/checkout@v3 - - - name: Download batch results - uses: actions/download-artifact@v3 - with: - path: workflow-temp - - - name: Setup Node.js - uses: actions/setup-node@v3 - with: - node-version: 16.x - - - name: Install generator npm packages - run: npm ci - working-directory: generator - - - name: Combine batches - run: | - npm run combine-batches -- \ - --input-path "$GITHUB_WORKSPACE/workflow-temp" \ - --batch-count ${{ env.BATCH_COUNT }} - working-directory: generator - - - name: Create Pull Request - uses: peter-evans/create-pull-request@v5 - with: - committer: GitHub - author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com> - signoff: false - branch: autogenerate-batch - delete-branch: true - title: | - Update Generated Schemas - body: | - Update Generated Schemas - commit-message: | - Update Generated Schemas - labels: autogenerate - draft: false diff --git a/.github/workflows/generate-schemas.yml b/.github/workflows/generate-schemas.yml index c751479821..bd83a1f1c6 100644 --- a/.github/workflows/generate-schemas.yml +++ b/.github/workflows/generate-schemas.yml @@ -1,71 +1,116 @@ name: Generate Schemas on: + schedule: + - cron: '45 5 * * SUN' workflow_dispatch: inputs: api_specs_ref: description: 'Git ref or full SHA for https://github.com/Azure/azure-rest-api-specs.' required: true default: 'main' - single_path: - description: 'The path to generate types for (e.g. "compute", or "keyvault"). Leave blank to generate all types.' - required: false + +env: + # This must be kept in sync with the arguments passed to the "batch" matrix + BATCH_COUNT: 20 jobs: - update-schemas: - name: Update Schemas + generate: + name: Update Schemas Batch ${{ matrix.batch }} runs-on: ubuntu-latest - + strategy: + matrix: + batch: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19] steps: - - uses: actions/checkout@v2.3.5 + - name: Checkout repo + uses: actions/checkout@v3 - name: Clone azure-rest-api-specs - uses: actions/checkout@v2.3.5 + uses: actions/checkout@v3 with: repository: Azure/azure-rest-api-specs path: workflow-temp/azure-rest-api-specs ref: ${{ github.event.inputs.api_specs_ref }} + + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: 16.x - name: Install generator npm packages run: npm ci working-directory: generator - - - id: generate - name: Run generator + + - name: Run generator run: | - if [ -z "${{ github.event.inputs.single_path }}" ] - then - npm run generate-all -- --local-path "$GITHUB_WORKSPACE/workflow-temp/azure-rest-api-specs" - else - npm run generate-single -- --base-path '${{ github.event.inputs.single_path }}/resource-manager' --local-path "$GITHUB_WORKSPACE/workflow-temp/azure-rest-api-specs" - fi + rm -Rf "$GITHUB_WORKSPACE/schemas" + rm -Rf "$GITHUB_WORKSPACE/summary.log" + mkdir -p "$GITHUB_WORKSPACE/schemas" + + npm run generate-all -- \ + --local-path "$GITHUB_WORKSPACE/workflow-temp/azure-rest-api-specs" \ + --batch-count ${{ env.BATCH_COUNT }} \ + --batch-index ${{ matrix.batch }} \ + --summary-log-path "$GITHUB_WORKSPACE/summary.log" \ + --combine-batch-mode true working-directory: generator - - id: get_swagger_gh_uri - name: Get GitHub URI for azure-rest-api-specs + - name: Upload Schemas + uses: actions/upload-artifact@v3 + with: + name: batch-${{ matrix.batch }}-schemas + path: schemas + if-no-files-found: error + + - name: Upload summary log + uses: actions/upload-artifact@v3 + with: + name: batch-${{ matrix.batch }}-summary + path: summary.log + if-no-files-found: error + + combine: + needs: generate + name: Combine Schema Batches + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@v3 + + - name: Download batch results + uses: actions/download-artifact@v3 + with: + path: workflow-temp + + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: 16.x + + - name: Install generator npm packages + run: npm ci + working-directory: generator + + - name: Combine batches run: | - git_sha=`git rev-parse HEAD` - echo "::set-output name=gh_uri::https://github.com/Azure/azure-rest-api-specs/tree/$git_sha" - working-directory: workflow-temp/azure-rest-api-specs + npm run combine-batches -- \ + --input-path "$GITHUB_WORKSPACE/workflow-temp" \ + --batch-count ${{ env.BATCH_COUNT }} + working-directory: generator - name: Create Pull Request - uses: peter-evans/create-pull-request@v4.1.3 + uses: peter-evans/create-pull-request@v5 with: committer: GitHub author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com> signoff: false - branch: autogenerate - branch-suffix: short-commit-hash + branch: autogenerate-batch delete-branch: true title: | - Update Generated Types ${{ github.event.inputs.single_path && format('(single path: {0})', github.event.inputs.single_path) || '' }} + Update Generated Schemas body: | - Update Generated Types ${{ github.event.inputs.single_path && format('(single path: {0})', github.event.inputs.single_path) || '' }} - - Generate types for ${{ steps.get_swagger_gh_uri.outputs.gh_uri }} + Update Generated Schemas commit-message: | - Update Generated Types ${{ github.event.inputs.single_path && format('(single path: {0})', github.event.inputs.single_path) || '' }} - - Generate types for ${{ steps.get_swagger_gh_uri.outputs.gh_uri }} + Update Generated Schemas labels: autogenerate draft: false diff --git a/.github/workflows/generate-single.yml b/.github/workflows/generate-single.yml new file mode 100644 index 0000000000..91923e563f --- /dev/null +++ b/.github/workflows/generate-single.yml @@ -0,0 +1,61 @@ +name: Generate Single + +on: + workflow_dispatch: + inputs: + api_specs_ref: + description: 'Git ref or full SHA for https://github.com/Azure/azure-rest-api-specs.' + required: true + default: 'main' + single_path: + description: 'The path to generate types for (e.g. "compute", or "keyvault").' + required: true + +jobs: + update-schemas: + name: Update Schemas + runs-on: ubuntu-latest + + steps: + - name: Checkout repo + uses: actions/checkout@v3 + + - name: Clone azure-rest-api-specs + uses: actions/checkout@v3 + with: + repository: Azure/azure-rest-api-specs + path: workflow-temp/azure-rest-api-specs + ref: ${{ github.event.inputs.api_specs_ref }} + + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: 16.x + + - name: Install generator npm packages + run: npm ci + working-directory: generator + + - name: Run generator + run: | + npm run generate-single -- \ + --local-path "$GITHUB_WORKSPACE/workflow-temp/azure-rest-api-specs" \ + --base-path '${{ github.event.inputs.single_path }}/resource-manager' + working-directory: generator + + - name: Create Pull Request + uses: peter-evans/create-pull-request@v5 + with: + committer: GitHub + author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com> + signoff: false + branch: autogenerate-${{ github.event.inputs.single_path }} + delete-branch: true + title: | + Update Generated Schemas (${{ github.event.inputs.single_path }}) + body: | + Update Generated Schemas (${{ github.event.inputs.single_path }}) + commit-message: | + Update Generated Schemas (${{ github.event.inputs.single_path }}) + labels: autogenerate + draft: false \ No newline at end of file diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0f4a633504..164449d05a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -9,15 +9,16 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2.3.5 + - name: Checkout repo + uses: actions/checkout@v3 - name: Setup Node.js - uses: actions/setup-node@v3.5.0 + uses: actions/setup-node@v3 with: - node-version: 14.x + node-version: 16.x - name: Setup .NET Core - uses: actions/setup-dotnet@v3.0.0 + uses: actions/setup-dotnet@v3 with: dotnet-version: '5.0.x' @@ -42,12 +43,13 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2.3.5 + - name: Checkout repo + uses: actions/checkout@v3 - name: Setup Node.js - uses: actions/setup-node@v3.5.0 + uses: actions/setup-node@v3 with: - node-version: 14.x + node-version: 16.x - name: Install run: npm ci @@ -68,12 +70,13 @@ jobs: PR_PREFIX: sdkAuto/ if: ${{ github.event.pull_request.user.login == 'azure-sdk' }} steps: - - uses: actions/checkout@v2.3.5 + - name: Checkout repo + uses: actions/checkout@v3 - name: Setup Node.js - uses: actions/setup-node@v3.5.0 + uses: actions/setup-node@v3 with: - node-version: 14.x + node-version: 16.x - name: Install NPM modules run: npm ci diff --git a/generator/autogenlist.ts b/generator/autogenlist.ts index b76b500009..e886da3cb8 100644 --- a/generator/autogenlist.ts +++ b/generator/autogenlist.ts @@ -2,7 +2,6 @@ // Licensed under the MIT License. import { ScopeType, AutoGenConfig } from './models'; import { postProcessor as insightsApplicationPostProcessor } from './processors/Microsoft.Insights.Application'; -import { postProcessor as resourcesPostProcessor } from './processors/Microsoft.Resources'; import { postProcessor as machineLearningPostProcessor } from './processors/Microsoft.MachineLearning'; import { postProcessor as kustoPostProcessor } from './processors/Microsoft.Kusto'; import { postProcessor as machineLearningServicesPostProcessor } from './processors/Microsoft.MachineLearningServices'; diff --git a/generator/constants.ts b/generator/constants.ts index a2eede0084..b92982a4f5 100644 --- a/generator/constants.ts +++ b/generator/constants.ts @@ -1,6 +1,5 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import os from 'os'; import path from 'path'; export const generatorRoot = path.resolve(__dirname, '../');