|
1 | 1 | name: Generate Schemas |
2 | 2 |
|
3 | 3 | on: |
| 4 | + schedule: |
| 5 | + - cron: '45 5 * * SUN' |
4 | 6 | workflow_dispatch: |
5 | 7 | inputs: |
6 | 8 | api_specs_ref: |
7 | 9 | description: 'Git ref or full SHA for https://github.com/Azure/azure-rest-api-specs.' |
8 | 10 | required: true |
9 | 11 | default: 'main' |
10 | | - single_path: |
11 | | - description: 'The path to generate types for (e.g. "compute", or "keyvault"). Leave blank to generate all types.' |
12 | | - required: false |
| 12 | + |
| 13 | +env: |
| 14 | + # This must be kept in sync with the arguments passed to the "batch" matrix |
| 15 | + BATCH_COUNT: 20 |
13 | 16 |
|
14 | 17 | jobs: |
15 | | - update-schemas: |
16 | | - name: Update Schemas |
| 18 | + generate: |
| 19 | + name: Update Schemas Batch ${{ matrix.batch }} |
17 | 20 | runs-on: ubuntu-latest |
18 | | - |
| 21 | + strategy: |
| 22 | + matrix: |
| 23 | + batch: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19] |
19 | 24 | steps: |
20 | | - - uses: actions/checkout@v2.3.5 |
| 25 | + - name: Checkout repo |
| 26 | + uses: actions/checkout@v3 |
21 | 27 |
|
22 | 28 | - name: Clone azure-rest-api-specs |
23 | | - uses: actions/checkout@v2.3.5 |
| 29 | + uses: actions/checkout@v3 |
24 | 30 | with: |
25 | 31 | repository: Azure/azure-rest-api-specs |
26 | 32 | path: workflow-temp/azure-rest-api-specs |
27 | 33 | ref: ${{ github.event.inputs.api_specs_ref }} |
| 34 | + |
| 35 | + - name: Setup Node.js |
| 36 | + uses: actions/setup-node@v3 |
| 37 | + with: |
| 38 | + node-version: 16.x |
28 | 39 |
|
29 | 40 | - name: Install generator npm packages |
30 | 41 | run: npm ci |
31 | 42 | working-directory: generator |
32 | | - |
33 | | - - id: generate |
34 | | - name: Run generator |
| 43 | + |
| 44 | + - name: Run generator |
35 | 45 | run: | |
36 | | - if [ -z "${{ github.event.inputs.single_path }}" ] |
37 | | - then |
38 | | - npm run generate-all -- --local-path "$GITHUB_WORKSPACE/workflow-temp/azure-rest-api-specs" |
39 | | - else |
40 | | - npm run generate-single -- --base-path '${{ github.event.inputs.single_path }}/resource-manager' --local-path "$GITHUB_WORKSPACE/workflow-temp/azure-rest-api-specs" |
41 | | - fi |
| 46 | + rm -Rf "$GITHUB_WORKSPACE/schemas" |
| 47 | + rm -Rf "$GITHUB_WORKSPACE/summary.log" |
| 48 | + mkdir -p "$GITHUB_WORKSPACE/schemas" |
| 49 | +
|
| 50 | + npm run generate-all -- \ |
| 51 | + --local-path "$GITHUB_WORKSPACE/workflow-temp/azure-rest-api-specs" \ |
| 52 | + --batch-count ${{ env.BATCH_COUNT }} \ |
| 53 | + --batch-index ${{ matrix.batch }} \ |
| 54 | + --summary-log-path "$GITHUB_WORKSPACE/summary.log" \ |
| 55 | + --combine-batch-mode true |
42 | 56 | working-directory: generator |
43 | 57 |
|
44 | | - - id: get_swagger_gh_uri |
45 | | - name: Get GitHub URI for azure-rest-api-specs |
| 58 | + - name: Upload Schemas |
| 59 | + uses: actions/upload-artifact@v3 |
| 60 | + with: |
| 61 | + name: batch-${{ matrix.batch }}-schemas |
| 62 | + path: schemas |
| 63 | + if-no-files-found: error |
| 64 | + |
| 65 | + - name: Upload summary log |
| 66 | + uses: actions/upload-artifact@v3 |
| 67 | + with: |
| 68 | + name: batch-${{ matrix.batch }}-summary |
| 69 | + path: summary.log |
| 70 | + if-no-files-found: error |
| 71 | + |
| 72 | + combine: |
| 73 | + needs: generate |
| 74 | + name: Combine Schema Batches |
| 75 | + runs-on: ubuntu-latest |
| 76 | + steps: |
| 77 | + - name: Checkout repo |
| 78 | + uses: actions/checkout@v3 |
| 79 | + |
| 80 | + - name: Download batch results |
| 81 | + uses: actions/download-artifact@v3 |
| 82 | + with: |
| 83 | + path: workflow-temp |
| 84 | + |
| 85 | + - name: Setup Node.js |
| 86 | + uses: actions/setup-node@v3 |
| 87 | + with: |
| 88 | + node-version: 16.x |
| 89 | + |
| 90 | + - name: Install generator npm packages |
| 91 | + run: npm ci |
| 92 | + working-directory: generator |
| 93 | + |
| 94 | + - name: Combine batches |
46 | 95 | run: | |
47 | | - git_sha=`git rev-parse HEAD` |
48 | | - echo "::set-output name=gh_uri::https://github.com/Azure/azure-rest-api-specs/tree/$git_sha" |
49 | | - working-directory: workflow-temp/azure-rest-api-specs |
| 96 | + npm run combine-batches -- \ |
| 97 | + --input-path "$GITHUB_WORKSPACE/workflow-temp" \ |
| 98 | + --batch-count ${{ env.BATCH_COUNT }} |
| 99 | + working-directory: generator |
50 | 100 |
|
51 | 101 | - name: Create Pull Request |
52 | | - uses: peter-evans/create-pull-request@v4.1.3 |
| 102 | + uses: peter-evans/create-pull-request@v5 |
53 | 103 | with: |
54 | 104 | committer: GitHub <noreply@github.com> |
55 | 105 | author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com> |
56 | 106 | signoff: false |
57 | | - branch: autogenerate |
58 | | - branch-suffix: short-commit-hash |
| 107 | + branch: autogenerate-batch |
59 | 108 | delete-branch: true |
60 | 109 | title: | |
61 | | - Update Generated Types ${{ github.event.inputs.single_path && format('(single path: {0})', github.event.inputs.single_path) || '' }} |
| 110 | + Update Generated Schemas |
62 | 111 | body: | |
63 | | - Update Generated Types ${{ github.event.inputs.single_path && format('(single path: {0})', github.event.inputs.single_path) || '' }} |
64 | | -
|
65 | | - Generate types for ${{ steps.get_swagger_gh_uri.outputs.gh_uri }} |
| 112 | + Update Generated Schemas |
66 | 113 | commit-message: | |
67 | | - Update Generated Types ${{ github.event.inputs.single_path && format('(single path: {0})', github.event.inputs.single_path) || '' }} |
68 | | -
|
69 | | - Generate types for ${{ steps.get_swagger_gh_uri.outputs.gh_uri }} |
| 114 | + Update Generated Schemas |
70 | 115 | labels: autogenerate |
71 | 116 | draft: false |
0 commit comments