diff --git a/.github/actions/download-bin/action.yml b/.github/actions/download-bin/action.yml index 646d4f93a..9821e287a 100644 --- a/.github/actions/download-bin/action.yml +++ b/.github/actions/download-bin/action.yml @@ -1,16 +1,23 @@ -name: Download binary assets -description: Downloads the provider and tfgen binaries to `bin/`. +name: Download the provider binary +description: Downloads the provider binary to `bin/`. runs: using: "composite" steps: - - name: Download provider + tfgen binaries - uses: actions/download-artifact@v4 + + - name: Download pulumi-resource-rancher2 + uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 with: - name: rancher2-provider.tar.gz + pattern: pulumi-resource-rancher2-*-linux-amd64.tar.gz path: ${{ github.workspace }}/bin - - name: Untar provider binaries + merge-multiple: true + + - name: Untar pulumi-resource-rancher2 + shell: bash + run: | + tar -zxf ${{ github.workspace }}/bin/*amd64.tar.gz -C ${{ github.workspace}}/bin + + - name: Mark pulumi-resource-rancher2 as executable shell: bash run: | - tar -zxf ${{ github.workspace }}/bin/provider.tar.gz -C ${{ github.workspace}}/bin find ${{ github.workspace }} -name "pulumi-*-rancher2" -print -exec chmod +x {} \; diff --git a/.github/actions/download-sdk/action.yml b/.github/actions/download-sdk/action.yml index 1fd54841b..ec5a2f308 100644 --- a/.github/actions/download-sdk/action.yml +++ b/.github/actions/download-sdk/action.yml @@ -10,7 +10,7 @@ runs: using: "composite" steps: - name: Download ${{ inputs.language }} SDK - uses: actions/download-artifact@v4 + uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 with: name: ${{ inputs.language }}-sdk.tar.gz path: ${{ github.workspace}}/sdk/ diff --git a/.github/actions/setup-tools/action.yml b/.github/actions/setup-tools/action.yml index 642d1d223..6a711d418 100644 --- a/.github/actions/setup-tools/action.yml +++ b/.github/actions/setup-tools/action.yml @@ -20,7 +20,7 @@ runs: steps: - name: Install Go if: inputs.tools == 'all' || contains(inputs.tools, 'go') - uses: actions/setup-go@v5 + uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5 with: go-version: "1.21.x" cache-dependency-path: | @@ -30,45 +30,45 @@ runs: - name: Install pulumictl if: inputs.tools == 'all' || contains(inputs.tools, 'pulumictl') - uses: jaxxstorm/action-install-gh-release@v1.11.0 + uses: jaxxstorm/action-install-gh-release@71d17cb091aa850acb2a1a4cf87258d183eb941b # v1.11.0 with: tag: v0.0.46 repo: pulumi/pulumictl - name: Install Pulumi CLI if: inputs.tools == 'all' || contains(inputs.tools, 'pulumicli') - uses: pulumi/actions@v5 + uses: pulumi/actions@c7fad9e2f0b79653172b36538b8b34b3c0291952 # v6 with: pulumi-version: "dev" - name: Install Schema Tools if: inputs.tools == 'all' || contains(inputs.tools, 'schema-tools') - uses: jaxxstorm/action-install-gh-release@v1.11.0 + uses: jaxxstorm/action-install-gh-release@71d17cb091aa850acb2a1a4cf87258d183eb941b # v1.11.0 with: repo: pulumi/schema-tools - name: Setup Node if: inputs.tools == 'all' || contains(inputs.tools, 'nodejs') - uses: actions/setup-node@v4 + uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4 with: node-version: 20.x registry-url: https://registry.npmjs.org - name: Setup DotNet if: inputs.tools == 'all' || contains(inputs.tools, 'dotnet') - uses: actions/setup-dotnet@v4 + uses: actions/setup-dotnet@3e891b0cb619bf60e2c25674b222b8940e2c1c25 # v4 with: dotnet-version: 6.0.x - name: Setup Python if: inputs.tools == 'all' || contains(inputs.tools, 'python') - uses: actions/setup-python@v5 + uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5 with: python-version: 3.11.8 - name: Setup Java if: inputs.tools == 'all' || contains(inputs.tools, 'java') - uses: actions/setup-java@v4 + uses: actions/setup-java@8df1039502a15bceb9433410b1a100fbe190c53b # v4 with: cache: gradle distribution: temurin @@ -76,6 +76,6 @@ runs: - name: Setup Gradle if: inputs.tools == 'all' || contains(inputs.tools, 'java') - uses: gradle/gradle-build-action@v3 + uses: gradle/gradle-build-action@ac2d340dc04d9e1113182899e983b5400c17cda1 # v3 with: gradle-version: 7.6 diff --git a/.github/actions/upload-sdk/action.yml b/.github/actions/upload-sdk/action.yml index 77d484942..b0dd14042 100644 --- a/.github/actions/upload-sdk/action.yml +++ b/.github/actions/upload-sdk/action.yml @@ -13,7 +13,7 @@ runs: shell: bash run: tar -zcf sdk/${{ inputs.language }}.tar.gz -C sdk/${{ inputs.language }} . - name: Upload artifacts - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 with: name: ${{ inputs.language }}-sdk.tar.gz path: ${{ github.workspace}}/sdk/${{ inputs.language }}.tar.gz diff --git a/.github/workflows/build_provider.yml b/.github/workflows/build_provider.yml index b693f75ac..064035539 100644 --- a/.github/workflows/build_provider.yml +++ b/.github/workflows/build_provider.yml @@ -14,6 +14,7 @@ jobs: runs-on: ubuntu-latest env: PROVIDER_VERSION: ${{ inputs.version }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} strategy: fail-fast: true matrix: @@ -30,28 +31,29 @@ jobs: arch: amd64 steps: - name: Checkout Repo - uses: actions/checkout@v4 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: persist-credentials: false - name: Setup tools uses: ./.github/actions/setup-tools with: tools: pulumictl, go + - name: Prepare local workspace before restoring previously built + run: make prepare_local_workspace - name: Download schema-embed.json - uses: actions/download-artifact@v4 + uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 with: # Use a pattern to avoid failing if the artifact doesn't exist pattern: schema-embed.* # Avoid creating directories for each artifact merge-multiple: true - path: provider/cmd/pulumi-resource-rancher2/schema-embed.json - - name: Prepare for build - # This installs plugins and prepares upstream - run: make upstream + path: provider/cmd/pulumi-resource-rancher2 + - name: Restore makefile progress + run: make --touch provider schema - name: Build & package provider run: make provider_dist-${{ matrix.platform.os }}-${{ matrix.platform.arch }} - name: Upload artifacts - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 with: name: pulumi-resource-rancher2-v${{ inputs.version }}-${{ matrix.platform.os }}-${{ matrix.platform.arch }}.tar.gz path: bin/pulumi-resource-rancher2-v${{ inputs.version }}-${{ matrix.platform.os }}-${{ matrix.platform.arch }}.tar.gz diff --git a/.github/workflows/build_sdk.yml b/.github/workflows/build_sdk.yml index 9c4eb40ec..2e320fe38 100644 --- a/.github/workflows/build_sdk.yml +++ b/.github/workflows/build_sdk.yml @@ -43,11 +43,11 @@ jobs: - java steps: - name: Checkout Repo - uses: actions/checkout@v4 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: persist-credentials: false - name: Cache examples generation - uses: actions/cache@v4 + uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4 with: path: | .pulumi/examples-cache @@ -56,12 +56,14 @@ jobs: uses: ./.github/actions/setup-tools with: tools: pulumictl, pulumicli, ${{ matrix.language }} - - name: Download bin - uses: ./.github/actions/download-bin - - name: Install plugins - run: make install_plugins + - name: Prepare local workspace + run: make prepare_local_workspace + - name: Download tfgen + uses: ./.github/actions/download-tfgen - name: Update path run: echo "${{ github.workspace }}/bin" >> "$GITHUB_PATH" + - name: Restore makefile progress + run: make --touch provider schema - name: Build SDK run: make build_${{ matrix.language }} - name: Check worktree clean diff --git a/.github/workflows/command-dispatch.yml b/.github/workflows/command-dispatch.yml index 8ac733425..6b3c62814 100644 --- a/.github/workflows/command-dispatch.yml +++ b/.github/workflows/command-dispatch.yml @@ -25,10 +25,10 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout Repo - uses: actions/checkout@v4 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: persist-credentials: false - - uses: peter-evans/slash-command-dispatch@v4 + - uses: peter-evans/slash-command-dispatch@13bc09769d122a64f75aa5037256f6f2d78be8c4 # v4 with: commands: | run-acceptance-tests diff --git a/.github/workflows/community-moderation.yml b/.github/workflows/community-moderation.yml index fc701df62..c353895e2 100644 --- a/.github/workflows/community-moderation.yml +++ b/.github/workflows/community-moderation.yml @@ -8,24 +8,24 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout Repo - uses: actions/checkout@v4 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: persist-credentials: false - id: schema_changed name: Check for diff in schema - uses: dorny/paths-filter@v2 + uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2 with: filters: "changed: 'provider/cmd/**/schema.json'" - id: sdk_changed if: steps.schema_changed.outputs.changed == 'false' name: Check for diff in sdk/** - uses: dorny/paths-filter@v2 + uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2 with: filters: "changed: 'sdk/**'" - if: steps.sdk_changed.outputs.changed == 'true' && github.event.pull_request.head.repo.full_name != github.repository name: Send codegen warning as comment on PR - uses: thollander/actions-comment-pull-request@v2 + uses: thollander/actions-comment-pull-request@fabd468d3a1a0b97feee5f6b9e499eab0dd903f6 # v2.5.0 with: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} message: > diff --git a/.github/workflows/license.yml b/.github/workflows/license.yml index 472b0369f..91ace4bfc 100644 --- a/.github/workflows/license.yml +++ b/.github/workflows/license.yml @@ -32,7 +32,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout Repo - uses: actions/checkout@v4 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: persist-credentials: false - name: Setup tools diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 84b15c1d4..257725d69 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -32,11 +32,11 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout Repo - uses: actions/checkout@v4 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: persist-credentials: false - name: Install go - uses: actions/setup-go@v5 + uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5 with: # The versions of golangci-lint and setup-go here cross-depend and need to update together. go-version: 1.23 @@ -50,7 +50,7 @@ jobs: continue-on-error: true run: make upstream - name: golangci-lint - uses: golangci/golangci-lint-action@v6 + uses: golangci/golangci-lint-action@971e284b6050e8a5849b72094c50ab08da042db8 # v6 with: version: v1.60 working-directory: provider diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index 2c8a34bc5..9d336242a 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -52,16 +52,16 @@ jobs: runs-on: ubuntu-latest steps: - name: Free Disk Space (Ubuntu) - uses: jlumbroso/free-disk-space@v1.3.1 + uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be # v1.3.1 with: tool-cache: false swap-storage: false - name: Checkout Repo - uses: actions/checkout@v4 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: persist-credentials: false - name: Configure AWS Credentials - uses: aws-actions/configure-aws-credentials@v4 + uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # v4.0.2 with: aws-access-key-id: ${{ secrets.AWS_CORP_S3_UPLOAD_ACCESS_KEY_ID }} aws-region: us-west-2 @@ -107,6 +107,7 @@ jobs: version: ${{ needs.prerequisites.outputs.version }} isPrerelease: true skipGoSdk: true + skipJavaSdk: true tag_release_if_labeled_needs_release: name: Tag release if labeled as needs-release @@ -130,6 +131,7 @@ jobs: name: test needs: - prerequisites + - build_provider - build_sdk permissions: contents: read @@ -139,22 +141,23 @@ jobs: PROVIDER_VERSION: ${{ needs.prerequisites.outputs.version }} steps: - name: Checkout Repo - uses: actions/checkout@v4 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: persist-credentials: false - name: Setup tools uses: ./.github/actions/setup-tools with: tools: pulumictl, pulumicli, ${{ matrix.language }} + - name: Prepare local workspace + run: make prepare_local_workspace - name: Download bin uses: ./.github/actions/download-bin - - name: Add NuGet source - if: matrix.language == 'dotnet' - run: dotnet nuget add source ${{ github.workspace }}/nuget - name: Download SDK uses: ./.github/actions/download-sdk with: language: ${{ matrix.language }} + - name: Restore makefile progress + run: make --touch provider schema build_${{ matrix.language }} - name: Update path run: echo "${{ github.workspace }}/bin" >> "$GITHUB_PATH" - name: Install Python deps diff --git a/.github/workflows/prerelease.yml b/.github/workflows/prerelease.yml index b586d5887..c17a688af 100644 --- a/.github/workflows/prerelease.yml +++ b/.github/workflows/prerelease.yml @@ -72,6 +72,7 @@ jobs: name: test needs: - prerequisites + - build_provider - build_sdk permissions: contents: read @@ -81,22 +82,23 @@ jobs: PROVIDER_VERSION: ${{ needs.prerequisites.outputs.version }} steps: - name: Checkout Repo - uses: actions/checkout@v4 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: persist-credentials: false - name: Setup tools uses: ./.github/actions/setup-tools with: tools: pulumictl, pulumicli, nodejs, python, dotnet, go, java + - name: Prepare local workspace + run: make prepare_local_workspace - name: Download bin uses: ./.github/actions/download-bin - - name: Add NuGet source - if: matrix.language == 'dotnet' - run: dotnet nuget add source ${{ github.workspace }}/nuget - name: Download SDK uses: ./.github/actions/download-sdk with: language: ${{ matrix.language }} + - name: Restore makefile progress + run: make --touch provider schema build_${{ matrix.language }} - name: Update path run: echo "${{ github.workspace }}/bin" >> "$GITHUB_PATH" - name: Install Python deps diff --git a/.github/workflows/prerequisites.yml b/.github/workflows/prerequisites.yml index aa0e71817..54547a1aa 100644 --- a/.github/workflows/prerequisites.yml +++ b/.github/workflows/prerequisites.yml @@ -45,33 +45,31 @@ jobs: version: ${{ steps.provider-version.outputs.version }} steps: - name: Checkout Repo - uses: actions/checkout@v4 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: persist-credentials: false - - uses: pulumi/provider-version-action@v1 + - uses: pulumi/provider-version-action@0391d47b9b0d865d33dd0a295b1fcf9f7021dd4c # v1.5.3 id: provider-version with: set-env: 'PROVIDER_VERSION' - name: Cache examples generation - uses: actions/cache@v4 + uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4 with: path: | .pulumi/examples-cache key: ${{ runner.os }}-${{ hashFiles('provider/go.sum') }} - - name: Prepare upstream code - run: make upstream - name: Setup tools uses: ./.github/actions/setup-tools with: tools: go, pulumictl, pulumicli, schema-tools - - name: Build schema generator binary - run: make tfgen_build_only - - name: Install plugins - run: make install_plugins + - name: Prepare local workspace before restoring previously built files + run: make prepare_local_workspace - name: Generate schema - run: make tfgen_no_deps + run: make schema + - name: Build registry docs + run: make build_registry_docs - name: Build provider binary - run: make provider_no_deps + run: make provider - name: Unit-test provider code run: make test_provider - if: inputs.is_pr @@ -85,7 +83,7 @@ jobs: } >> "$GITHUB_ENV" - if: inputs.is_pr && inputs.is_automated == false name: Comment on PR with Details of Schema Check - uses: thollander/actions-comment-pull-request@v2 + uses: thollander/actions-comment-pull-request@fabd468d3a1a0b97feee5f6b9e499eab0dd903f6 # v2.5.0 with: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} comment_tag: schemaCheck @@ -95,11 +93,15 @@ jobs: Maintainer note: consult the [runbook](https://github.com/pulumi/platform-providers-team/blob/main/playbooks/tf-provider-updating.md) for dealing with any breaking changes. - - name: Upload bin - uses: ./.github/actions/upload-bin + - name: Upload pulumi-tfgen-rancher2 + uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 + with: + name: pulumi-tfgen-rancher2 + path: ${{ github.workspace }}/bin/pulumi-tfgen-rancher2 + retention-days: 30 - name: Upload schema-embed.json - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 with: name: schema-embed.json path: provider/cmd/pulumi-resource-rancher2/schema-embed.json diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index fd70ea6e7..076f09ccc 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -14,6 +14,10 @@ on: default: false type: boolean description: Skip publishing & verifying the Go SDK + skipJavaSdk: + default: false + type: boolean + description: Skip publishing the Java SDK env: IS_PRERELEASE: ${{ inputs.isPrerelease }} @@ -48,7 +52,7 @@ jobs: if: inputs.skipGoSdk && inputs.isPrerelease == false run: echo "Can't skip Go SDK for stable releases. This is likely a bug in the calling workflow." && exit 1 - name: Checkout Repo - uses: actions/checkout@v4 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: persist-credentials: false - name: Setup tools @@ -56,7 +60,7 @@ jobs: with: tools: pulumictl, pulumicli, go, schema-tools - name: Configure AWS Credentials - uses: aws-actions/configure-aws-credentials@v4 + uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # v4.0.2 with: aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} aws-region: us-east-2 @@ -68,7 +72,7 @@ jobs: - name: Create dist directory run: mkdir -p dist - name: Download provider assets - uses: actions/download-artifact@v4 + uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 with: pattern: pulumi-resource-rancher2-v${{ inputs.version }}-* path: dist @@ -93,7 +97,7 @@ jobs: - name: Upload Provider Binaries run: aws s3 cp dist s3://get.pulumi.com/releases/plugins/ --recursive - name: Create GH Release - uses: softprops/action-gh-release@v2 + uses: softprops/action-gh-release@e7a8f85e1c67a31e6ed99a94b41bd0b71bbee6b8 # v2 if: inputs.isPrerelease == false with: tag_name: v${{ inputs.version }} @@ -112,7 +116,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout Repo - uses: actions/checkout@v4 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: # Persist credentials so we can push back to the repo persist-credentials: true @@ -121,10 +125,17 @@ jobs: with: tools: pulumictl, pulumicli, nodejs, python, dotnet, go, java - name: Publish SDKs - uses: pulumi/pulumi-package-publisher@v0.0.20 + if: inputs.skipJavaSdk == false + uses: pulumi/pulumi-package-publisher@1c0359ba74243cf6651efacfd839c751d8ff87e2 # v0.0.20 with: sdk: all version: ${{ inputs.version }} + - name: Publish SDKs (except Java) + if: inputs.skipJavaSdk == true + uses: pulumi/pulumi-package-publisher@1c0359ba74243cf6651efacfd839c751d8ff87e2 # v0.0.20 + with: + sdk: all,!java + version: ${{ inputs.version }} - name: Download Go SDK uses: ./.github/actions/download-sdk with: @@ -151,7 +162,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Dispatch Metadata build - uses: peter-evans/repository-dispatch@v3 + uses: peter-evans/repository-dispatch@ff45666b9427631e3450c54a1bcbee4d9ff4d7c0 # v3 with: token: ${{ secrets.PULUMI_BOT_TOKEN }} repository: pulumi/registry @@ -172,7 +183,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout Repo - uses: actions/checkout@v4 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: persist-credentials: false - name: Clean up release labels diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index bdfc183c6..d1358aadb 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -26,11 +26,11 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout Repo - uses: actions/checkout@v4 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: persist-credentials: false - name: Comment PR - uses: thollander/actions-comment-pull-request@v2 + uses: thollander/actions-comment-pull-request@fabd468d3a1a0b97feee5f6b9e499eab0dd903f6 # v2.5.0 with: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} message: > diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 05887bfac..8d9a46382 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -78,6 +78,7 @@ jobs: name: test needs: - prerequisites + - build_provider - build_sdk permissions: contents: read @@ -87,22 +88,23 @@ jobs: PROVIDER_VERSION: ${{ needs.prerequisites.outputs.version }} steps: - name: Checkout Repo - uses: actions/checkout@v4 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: persist-credentials: false - name: Setup tools uses: ./.github/actions/setup-tools with: tools: pulumictl, pulumicli, ${{ matrix.language }} + - name: Prepare local workspace + run: make prepare_local_workspace - name: Download bin uses: ./.github/actions/download-bin - - name: Add NuGet source - if: matrix.language == 'dotnet' - run: dotnet nuget add source ${{ github.workspace }}/nuget - name: Download SDK uses: ./.github/actions/download-sdk with: language: ${{ matrix.language }} + - name: Restore makefile progress + run: make --touch provider schema build_${{ matrix.language }} - name: Update path run: echo "${{ github.workspace }}/bin" >> "$GITHUB_PATH" - name: Install Python deps diff --git a/.github/workflows/release_command.yml b/.github/workflows/release_command.yml index f199952c8..5712f40e5 100644 --- a/.github/workflows/release_command.yml +++ b/.github/workflows/release_command.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout Repo - uses: actions/checkout@v4 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: persist-credentials: false - name: Should release PR @@ -28,7 +28,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - if: failure() name: Notify failure - uses: peter-evans/create-or-update-comment@v2 + uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0 with: token: ${{ secrets.GITHUB_TOKEN }} repository: ${{ github.event.client_payload.github.payload.repository.full_name }} @@ -37,7 +37,7 @@ jobs: "release command failed: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" - if: success() name: Notify success - uses: peter-evans/create-or-update-comment@v2 + uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0 with: token: ${{ secrets.GITHUB_TOKEN }} repository: ${{ github.event.client_payload.github.payload.repository.full_name }} diff --git a/.github/workflows/resync-build.yml b/.github/workflows/resync-build.yml deleted file mode 100644 index e6c3f6fab..000000000 --- a/.github/workflows/resync-build.yml +++ /dev/null @@ -1,91 +0,0 @@ -# WARNING: This file is autogenerated - changes will be overwritten when regenerated by https://github.com/pulumi/ci-mgmt - -env: - PULUMI_EXTRA_MAPPING_ERROR: true - PULUMI_MISSING_MAPPING_ERROR: true - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - NUGET_PUBLISH_KEY: ${{ secrets.NUGET_PUBLISH_KEY }} - PUBLISH_REPO_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} - PUBLISH_REPO_USERNAME: ${{ secrets.OSSRH_USERNAME }} - PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_ACCESS_TOKEN }} - PULUMI_API: https://api.pulumi-staging.io - PULUMI_GO_DEP_ROOT: ${{ github.workspace }}/.. - PULUMI_LOCAL_NUGET: ${{ github.workspace }}/nuget - PYPI_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} - PYPI_USERNAME: __token__ - RANCHER_INSECURE: "true" - RANCHER_URL: https://localhost - SIGNING_KEY: ${{ secrets.JAVA_SIGNING_KEY }} - SIGNING_KEY_ID: ${{ secrets.JAVA_SIGNING_KEY_ID }} - SIGNING_PASSWORD: ${{ secrets.JAVA_SIGNING_PASSWORD }} - TF_APPEND_USER_AGENT: pulumi -jobs: - resync_build: - name: resync-build - runs-on: ubuntu-latest - steps: - - name: Checkout Repo - uses: actions/checkout@v4 - with: - # Persist credentials so we can push a new branch. - persist-credentials: true - - name: Checkout repo - uses: actions/checkout@v4 - with: - path: ci-mgmt - repository: pulumi/ci-mgmt - persist-credentials: false - - id: run-url - name: Create URL to the run output - run: echo "run-url=https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" >> "$GITHUB_OUTPUT" - - name: Setup tools - uses: ./.github/actions/setup-tools - with: - tools: pulumictl, pulumicli, go, nodejs, dotnet, python - - name: Sync with ci-mgmt - run: cp -r "ci-mgmt/provider-ci/providers/$PROVIDER/repo/." . - - name: Remove ci-mgmt directory - run: rm -rf ci-mgmt - - name: Required entries for gitignore - run: |- - cat <<- EOF > "$RUNNER_TEMP/gitignore" - sdk/java/build - sdk/java/.gradle - sdk/java/gradle - sdk/java/gradlew - sdk/java/gradlew.bat - EOF - shell: bash - - name: Adding missing lines to .gitignore - run: | - comm -23 <(sort "$RUNNER_TEMP/gitignore") <(sort .gitignore) >> .gitignore.temp - cat .gitignore.temp >> .gitignore - rm .gitignore.temp - shell: bash - - name: Build - run: make build - - name: Create PR (no linked issue) - uses: peter-evans/create-pull-request@v3.12.0 - with: - author: pulumi-bot - base: master - body: This pull request was generated automatically by the resync-build workflow - in this repository. - branch: pulumi-bot/resync-${{ github.run_id}} - commit-message: Resync build for pulumi-rancher2 - committer: pulumi-bot - labels: impact/no-changelog-required - team-reviewers: platform-integrations - title: Fix up build for pulumi-rancher2 - token: ${{ secrets.PULUMI_BOT_TOKEN }} -name: Resync build -on: - workflow_dispatch: - inputs: - automerge: - default: false - description: Mark created PR for auto-merging? - required: true - type: boolean diff --git a/.github/workflows/run-acceptance-tests.yml b/.github/workflows/run-acceptance-tests.yml index d1c338812..6afd65c94 100644 --- a/.github/workflows/run-acceptance-tests.yml +++ b/.github/workflows/run-acceptance-tests.yml @@ -77,7 +77,7 @@ jobs: name: Create URL to the run output run: echo "run-url=https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" >> "$GITHUB_OUTPUT" - name: Update with Result - uses: peter-evans/create-or-update-comment@v1 + uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0 with: body: "Please view the PR build: ${{ steps.run-url.outputs.run-url }}" issue-number: ${{ github.event.client_payload.github.payload.issue.number }} @@ -102,7 +102,7 @@ jobs: - lint runs-on: ubuntu-latest steps: - - uses: guibranco/github-status-action-v2@0849440ec82c5fa69b2377725b9b7852a3977e76 + - uses: guibranco/github-status-action-v2@0849440ec82c5fa69b2377725b9b7852a3977e76 # v1.1.13 with: authToken: ${{secrets.GITHUB_TOKEN}} # Write an explicit status check called "Sentinel" which will only pass if this code really runs. @@ -120,6 +120,7 @@ jobs: name: test needs: - prerequisites + - build_provider - build_sdk permissions: contents: read @@ -129,13 +130,13 @@ jobs: PROVIDER_VERSION: ${{ needs.prerequisites.outputs.version }} steps: - name: Checkout Repo - uses: actions/checkout@v4 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: ref: ${{ env.PR_COMMIT_SHA }} persist-credentials: false - name: Checkout p/examples if: matrix.testTarget == 'pulumiExamples' - uses: actions/checkout@v4 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: repository: pulumi/examples path: p-examples @@ -143,15 +144,16 @@ jobs: uses: ./.github/actions/setup-tools with: tools: pulumictl, pulumicli, ${{ matrix.language }} + - name: Prepare local workspace + run: make prepare_local_workspace - name: Download bin uses: ./.github/actions/download-bin - - name: Add NuGet source - if: matrix.language == 'dotnet' - run: dotnet nuget add source ${{ github.workspace }}/nuget - name: Download SDK uses: ./.github/actions/download-sdk with: language: ${{ matrix.language }} + - name: Restore makefile progress + run: make --touch provider schema build_${{ matrix.language }} - name: Update path run: echo "${{ github.workspace }}/bin" >> "$GITHUB_PATH" - name: Install Python deps diff --git a/.github/workflows/upgrade-bridge.yml b/.github/workflows/upgrade-bridge.yml index dcfea70e7..bfcea9e1d 100644 --- a/.github/workflows/upgrade-bridge.yml +++ b/.github/workflows/upgrade-bridge.yml @@ -49,16 +49,23 @@ on: required: false type: boolean default: false + +permissions: + contents: write + issues: write + pull-requests: write + env: - GH_TOKEN: ${{ secrets.PULUMI_BOT_TOKEN }} + GH_TOKEN: ${{ secrets.PULUMI_PROVIDER_AUTOMATION_TOKEN || secrets.PULUMI_BOT_TOKEN || secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + jobs: upgrade_provider: name: upgrade-provider runs-on: ubuntu-latest steps: - name: Checkout Repo - uses: actions/checkout@v4 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: persist-credentials: false - name: Setup tools @@ -67,7 +74,7 @@ jobs: tools: pulumictl, pulumicli, nodejs, python, dotnet, go, java - name: Call upgrade provider action if: github.event_name == 'workflow_dispatch' - uses: pulumi/pulumi-upgrade-provider-action@v0.0.12 + uses: pulumi/pulumi-upgrade-provider-action@a1d9f03fbfd923f787427c1d9e99c2356711d483 # v0.0.13 with: kind: ${{ inputs.kind }} email: bot@pulumi.com @@ -80,7 +87,7 @@ jobs: pr-title-prefix: ${{ inputs.pr-title-prefix }} - name: Call upgrade provider action if: github.event_name == 'repository_dispatch' - uses: pulumi/pulumi-upgrade-provider-action@v0.0.12 + uses: pulumi/pulumi-upgrade-provider-action@a1d9f03fbfd923f787427c1d9e99c2356711d483 # v0.0.13 with: kind: ${{ github.event.client_payload.kind || 'bridge' }} email: bot@pulumi.com diff --git a/.github/workflows/upgrade-provider.yml b/.github/workflows/upgrade-provider.yml index 6e7ec04dc..3eaa9b4a5 100644 --- a/.github/workflows/upgrade-provider.yml +++ b/.github/workflows/upgrade-provider.yml @@ -22,16 +22,22 @@ on: # 3 AM UTC ~ 8 PM PDT / 7 PM PST daily. Time chosen to run during off hours. - cron: 0 3 * * * +permissions: + contents: write + issues: write + pull-requests: write + env: - GH_TOKEN: ${{ secrets.PULUMI_BOT_TOKEN }} + GH_TOKEN: ${{ secrets.PULUMI_PROVIDER_AUTOMATION_TOKEN || secrets.PULUMI_BOT_TOKEN || secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + jobs: upgrade_provider: name: upgrade-provider runs-on: ubuntu-latest steps: - name: Checkout Repo - uses: actions/checkout@v4 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: # Persist credentials so upgrade-provider can push a new branch. persist-credentials: true diff --git a/.github/workflows/verify-release.yml b/.github/workflows/verify-release.yml index 34b54715e..677702d83 100644 --- a/.github/workflows/verify-release.yml +++ b/.github/workflows/verify-release.yml @@ -71,7 +71,7 @@ jobs: runs-on: ${{ matrix.runner }} steps: - name: Checkout Repo - uses: actions/checkout@v4 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: persist-credentials: false - name: Setup tools diff --git a/Makefile b/Makefile index 1bcf93ed2..03ca71ce3 100644 --- a/Makefile +++ b/Makefile @@ -27,151 +27,244 @@ LDFLAGS_UPSTREAM_VERSION= LDFLAGS_EXTRAS= LDFLAGS=$(LDFLAGS_PROJ_VERSION) $(LDFLAGS_UPSTREAM_VERSION) $(LDFLAGS_EXTRAS) $(LDFLAGS_STRIP_SYMBOLS) -development: install_plugins provider build_sdks install_sdks - -build: install_plugins provider build_sdks install_sdks - -build_sdks: build_nodejs build_python build_dotnet build_go build_java build_registry_docs - -install_go_sdk: - -install_java_sdk: - -install_python_sdk: +# Create a `.make` directory for tracking targets which don't generate a single file output. This should be ignored by git. +# For targets which either don't generate a single file output, or the output file is committed, we use a "sentinel" +# file within `.make/` to track the staleness of the target and only rebuild when needed. +# For each phony target, we create an internal target with the same name, but prefixed with `.make/` where the work is performed. +# At the end of each internal target we run `@touch $@` to update the file which is the name of the target. + +# Ensure all directories exist before evaluating targets to avoid issues with `touch` creating directories. +_ := $(shell mkdir -p .make bin .pulumi/bin) + +# Build the provider and all SDKs and install ready for testing +build: install_plugins provider build_sdks install_sdks build_registry_docs +# Keep aliases for old targets to ensure backwards compatibility +development: build +only_build: build +# Prepare the workspace for building the provider and SDKs +# Importantly this is run by CI ahead of restoring the bin directory and resuming SDK builds +prepare_local_workspace: install_plugins upstream +# Creates all generated files which need to be committed +generate: generate_sdks schema build_registry_docs +generate_sdks: generate_nodejs generate_python generate_dotnet generate_go generate_java +build_sdks: build_nodejs build_python build_dotnet build_go build_java +install_sdks: install_nodejs_sdk install_python_sdk install_dotnet_sdk install_go_sdk install_java_sdk +.PHONY: development only_build build generate generate_sdks build_sdks install_sdks -install_sdks: install_dotnet_sdk install_python_sdk install_nodejs_sdk install_java_sdk +help: + @echo "Usage: make [target]" + @echo "" + @echo "Main Targets" + @echo " build (default) Build the provider and all SDKs and install for testing" + @echo " generate Generate all SDKs, documentation and schema" + @echo " provider Build the local provider binary" + @echo " lint_provider<.fix> Run the linter on the provider (& optionally fix)" + @echo " test_provider Run the provider tests" + @echo " test Run the example tests (must run 'build' first)" + @echo " clean Clean up generated files" + @echo "" + @echo "More Precise Targets" + @echo " schema Generate the schema" + @echo " generate_sdks Generate all SDKs" + @echo " build_sdks Build all SDKs" + @echo " install_sdks Install all SDKs" + @echo " provider_dist Build and package the provider for all platforms" + @echo "" + @echo "Tool Targets" + @echo " ci-mgmt Re-generate CI configuration from .ci-mgmt.yaml" + @echo " debug_tfgen Start a debug server for tfgen" + @echo "" + @echo "Internal Targets (automatically run as dependencies of other targets)" + @echo " prepare_local_workspace Prepare for building" + @echo " install_plugins Install plugin dependencies" + @echo " upstream Initialize the upstream submodule, if present" + @echo "" + @echo "Language-Specific Targets" + @echo " generate_[language] Generate the SDK files ready for committing" + @echo " build_[language] Build the SDK to check correctness" + @echo " install_[language]_sdk Install the SDK ready for testing" + @echo "" + @echo " [language] = nodejs python dotnet go java" + @echo "" +.PHONY: help -only_build: build +GEN_PULUMI_HOME := $(WORKING_DIR)/.pulumi +GEN_PULUMI_CONVERT_EXAMPLES_CACHE_DIR := $(GEN_PULUMI_HOME)/examples-cache +GEN_ENVS := PULUMI_HOME=$(GEN_PULUMI_HOME) PULUMI_CONVERT_EXAMPLES_CACHE_DIR=$(GEN_PULUMI_CONVERT_EXAMPLES_CACHE_DIR) PULUMI_CONVERT=$(PULUMI_CONVERT) PULUMI_DISABLE_AUTOMATIC_PLUGIN_ACQUISITION=$(PULUMI_CONVERT) -build_dotnet: export PULUMI_HOME := $(WORKING_DIR)/.pulumi -build_dotnet: export PATH := $(WORKING_DIR)/.pulumi/bin:$(PATH) -build_dotnet: export PULUMI_CONVERT_EXAMPLES_CACHE_DIR := $(WORKING_DIR)/.pulumi/examples-cache -build_dotnet: upstream - PULUMI_CONVERT=$(PULUMI_CONVERT) PULUMI_DISABLE_AUTOMATIC_PLUGIN_ACQUISITION=$(PULUMI_CONVERT) $(WORKING_DIR)/bin/$(TFGEN) dotnet --out sdk/dotnet/ +generate_dotnet: .make/generate_dotnet +build_dotnet: .make/build_dotnet +.make/generate_dotnet: export PATH := $(WORKING_DIR)/.pulumi/bin:$(PATH) +.make/generate_dotnet: .make/install_plugins bin/$(TFGEN) + $(GEN_ENVS) $(WORKING_DIR)/bin/$(TFGEN) dotnet --out sdk/dotnet/ cd sdk/dotnet/ && \ printf "module fake_dotnet_module // Exclude this directory from Go tools\n\ngo 1.17\n" > go.mod && \ - echo "$(VERSION_GENERIC)" >version.txt && \ - dotnet build - -build_go: export PULUMI_HOME := $(WORKING_DIR)/.pulumi -build_go: export PATH := $(WORKING_DIR)/.pulumi/bin:$(PATH) -build_go: export PULUMI_CONVERT_EXAMPLES_CACHE_DIR := $(WORKING_DIR)/.pulumi/examples-cache -build_go: upstream - PULUMI_CONVERT=$(PULUMI_CONVERT) PULUMI_DISABLE_AUTOMATIC_PLUGIN_ACQUISITION=$(PULUMI_CONVERT) $(WORKING_DIR)/bin/$(TFGEN) go --out sdk/go/ + echo "$(VERSION_GENERIC)" >version.txt + @touch $@ +.make/build_dotnet: .make/generate_dotnet + cd sdk/dotnet/ && dotnet build + @touch $@ +.PHONY: generate_dotnet build_dotnet + +generate_go: .make/generate_go +build_go: .make/build_go +.make/generate_go: export PATH := $(WORKING_DIR)/.pulumi/bin:$(PATH) +.make/generate_go: .make/install_plugins bin/$(TFGEN) + $(GEN_ENVS) $(WORKING_DIR)/bin/$(TFGEN) go --out sdk/go/ + @touch $@ +.make/build_go: .make/generate_go cd sdk && go list "$$(grep -e "^module" go.mod | cut -d ' ' -f 2)/go/..." | xargs -I {} bash -c 'go build {} && go clean -i {}' - -build_java: PACKAGE_VERSION := $(VERSION_GENERIC) -build_java: export PULUMI_HOME := $(WORKING_DIR)/.pulumi -build_java: export PATH := $(WORKING_DIR)/.pulumi/bin:$(PATH) -build_java: export PULUMI_CONVERT_EXAMPLES_CACHE_DIR := $(WORKING_DIR)/.pulumi/examples-cache -build_java: bin/pulumi-java-gen upstream - $(WORKING_DIR)/bin/$(JAVA_GEN) generate --schema provider/cmd/$(PROVIDER)/schema.json --out sdk/java --build gradle-nexus + @touch $@ +.PHONY: generate_go build_go + +generate_java: .make/generate_java +build_java: .make/build_java +.make/generate_java: export PATH := $(WORKING_DIR)/.pulumi/bin:$(PATH) +.make/generate_java: PACKAGE_VERSION := $(VERSION_GENERIC) +.make/generate_java: .make/install_plugins bin/pulumi-java-gen .make/schema + PULUMI_HOME=$(GEN_PULUMI_HOME) PULUMI_CONVERT_EXAMPLES_CACHE_DIR=$(GEN_PULUMI_CONVERT_EXAMPLES_CACHE_DIR) bin/$(JAVA_GEN) generate --schema provider/cmd/$(PROVIDER)/schema.json --out sdk/java --build gradle-nexus + printf "module fake_java_module // Exclude this directory from Go tools\n\ngo 1.17\n" > sdk/java/go.mod + @touch $@ +.make/build_java: PACKAGE_VERSION := $(VERSION_GENERIC) +.make/build_java: .make/generate_java cd sdk/java/ && \ - printf "module fake_java_module // Exclude this directory from Go tools\n\ngo 1.17\n" > go.mod && \ gradle --console=plain build && \ gradle --console=plain javadoc - -build_nodejs: export PULUMI_HOME := $(WORKING_DIR)/.pulumi -build_nodejs: export PATH := $(WORKING_DIR)/.pulumi/bin:$(PATH) -build_nodejs: export PULUMI_CONVERT_EXAMPLES_CACHE_DIR := $(WORKING_DIR)/.pulumi/examples-cache -build_nodejs: upstream - PULUMI_CONVERT=$(PULUMI_CONVERT) PULUMI_DISABLE_AUTOMATIC_PLUGIN_ACQUISITION=$(PULUMI_CONVERT) $(WORKING_DIR)/bin/$(TFGEN) nodejs --out sdk/nodejs/ + @touch $@ +.PHONY: generate_java build_java + +generate_nodejs: .make/generate_nodejs +build_nodejs: .make/build_nodejs +.make/generate_nodejs: export PATH := $(WORKING_DIR)/.pulumi/bin:$(PATH) +.make/generate_nodejs: .make/install_plugins bin/$(TFGEN) + $(GEN_ENVS) $(WORKING_DIR)/bin/$(TFGEN) nodejs --out sdk/nodejs/ + printf "module fake_nodejs_module // Exclude this directory from Go tools\n\ngo 1.17\n" > sdk/nodejs/go.mod + @touch $@ +.make/build_nodejs: .make/generate_nodejs cd sdk/nodejs/ && \ - printf "module fake_nodejs_module // Exclude this directory from Go tools\n\ngo 1.17\n" > go.mod && \ yarn install && \ yarn run tsc && \ cp ../../README.md ../../LICENSE* package.json yarn.lock ./bin/ - -build_python: export PULUMI_HOME := $(WORKING_DIR)/.pulumi -build_python: export PATH := $(WORKING_DIR)/.pulumi/bin:$(PATH) -build_python: export PULUMI_CONVERT_EXAMPLES_CACHE_DIR := $(WORKING_DIR)/.pulumi/examples-cache -build_python: upstream - rm -rf sdk/python/ - PULUMI_CONVERT=$(PULUMI_CONVERT) PULUMI_DISABLE_AUTOMATIC_PLUGIN_ACQUISITION=$(PULUMI_CONVERT) $(WORKING_DIR)/bin/$(TFGEN) python --out sdk/python/ + @touch $@ +.PHONY: generate_nodejs build_nodejs + +generate_python: .make/generate_python +build_python: .make/build_python +.make/generate_python: export PATH := $(WORKING_DIR)/.pulumi/bin:$(PATH) +.make/generate_python: .make/install_plugins bin/$(TFGEN) + $(GEN_ENVS) $(WORKING_DIR)/bin/$(TFGEN) python --out sdk/python/ + printf "module fake_python_module // Exclude this directory from Go tools\n\ngo 1.17\n" > sdk/python/go.mod + cp README.md sdk/python/ + @touch $@ +.make/build_python: .make/generate_python cd sdk/python/ && \ - printf "module fake_python_module // Exclude this directory from Go tools\n\ngo 1.17\n" > go.mod && \ - cp ../../README.md . && \ rm -rf ./bin/ ../python.bin/ && cp -R . ../python.bin && mv ../python.bin ./bin && \ rm ./bin/go.mod && \ python3 -m venv venv && \ ./venv/bin/python -m pip install build==1.2.1 && \ cd ./bin && \ ../venv/bin/python -m build . - + @touch $@ +.PHONY: generate_python build_python # Run the bridge's registry-docs command to generated the content of the installation docs/ folder at provider repo root -build_registry_docs: - $(WORKING_DIR)/bin/$(TFGEN) registry-docs --out $(WORKING_DIR)/docs +build_registry_docs: .make/build_registry_docs +.make/build_registry_docs: .make/install_plugins bin/$(TFGEN) + bin/$(TFGEN) registry-docs --out $(WORKING_DIR)/docs + @touch $@ +.PHONY: build_registry_docs clean: rm -rf sdk/{dotnet,nodejs,go,python} - -cleanup: - rm -r $(WORKING_DIR)/bin - rm -f provider/cmd/$(PROVIDER)/schema.go - -help: - @grep '^[^.#]\+:\s\+.*#' Makefile | \ - sed "s/\(.\+\):\s*\(.*\) #\s*\(.*\)/`printf "\033[93m"`\1`printf "\033[0m"` \3 [\2]/" | \ - expand -t20 - -install_dotnet_sdk: - mkdir -p $(WORKING_DIR)/nuget - find . -name '*.nupkg' -print -exec cp -p {} $(WORKING_DIR)/nuget \; - -install_nodejs_sdk: + rm -rf bin/* + rm -rf .make/* + if dotnet nuget list source | grep "$(WORKING_DIR)/nuget"; then \ + dotnet nuget remove source "$(WORKING_DIR)/nuget" \ + ; fi +.PHONY: clean + +install_dotnet_sdk: .make/install_dotnet_sdk +.make/install_dotnet_sdk: .make/build_dotnet + mkdir -p nuget + find sdk/dotnet/bin -name '*.nupkg' -print -exec cp -p "{}" ${WORKING_DIR}/nuget \; + if ! dotnet nuget list source | grep "${WORKING_DIR}/nuget"; then \ + dotnet nuget add source "${WORKING_DIR}/nuget" --name "${WORKING_DIR}/nuget" \ + ; fi + @touch $@ +install_go_sdk: +install_java_sdk: +install_nodejs_sdk: .make/install_nodejs_sdk +.make/install_nodejs_sdk: .make/build_nodejs yarn link --cwd $(WORKING_DIR)/sdk/nodejs/bin + @touch $@ +install_python_sdk: +.PHONY: install_dotnet_sdk install_go_sdk install_java_sdk install_nodejs_sdk install_python_sdk -install_plugins: export PULUMI_HOME := $(WORKING_DIR)/.pulumi -install_plugins: export PATH := $(WORKING_DIR)/.pulumi/bin:$(PATH) -install_plugins: .pulumi/bin/pulumi +# Install Pulumi plugins required for TFGen to resolve references +install_plugins: .make/install_plugins +.make/install_plugins: export PULUMI_HOME := $(WORKING_DIR)/.pulumi +.make/install_plugins: export PATH := $(WORKING_DIR)/.pulumi/bin:$(PATH) +.make/install_plugins: .pulumi/bin/pulumi .pulumi/bin/pulumi plugin install resource std 1.6.2 .pulumi/bin/pulumi plugin install converter terraform 1.0.16 + @touch $@ +.PHONY: install_plugins lint_provider: provider cd provider && golangci-lint run --path-prefix provider -c ../.golangci.yml - # `lint_provider.fix` is a utility target meant to be run manually # that will run the linter and fix errors when possible. lint_provider.fix: cd provider && golangci-lint run --path-prefix provider -c ../.golangci.yml --fix +.PHONY: lint_provider lint_provider.fix # `make provider_no_deps` builds the provider binary directly, without ensuring that # `cmd/pulumi-resource-rancher2/schema.json` is valid and up to date. # To create a release ready binary, you should use `make provider`. +build_provider_cmd = cd provider && go build $(PULUMI_PROVIDER_BUILD_PARALLELISM) -o $(WORKING_DIR)/bin/$(PROVIDER) -ldflags "$(LDFLAGS)" $(PROJECT)/$(PROVIDER_PATH)/cmd/$(PROVIDER) +provider: bin/$(PROVIDER) provider_no_deps: - (cd provider && go build $(PULUMI_PROVIDER_BUILD_PARALLELISM) -o $(WORKING_DIR)/bin/$(PROVIDER) -ldflags "$(LDFLAGS)" $(PROJECT)/$(PROVIDER_PATH)/cmd/$(PROVIDER)) - -provider: tfgen provider_no_deps + $(call build_provider_cmd) +bin/$(PROVIDER): .make/schema + $(call build_provider_cmd) +.PHONY: provider provider_no_deps test: export PATH := $(WORKING_DIR)/bin:$(PATH) test: cd examples && go test -v -tags=all -parallel $(TESTPARALLELISM) -timeout 2h +.PHONY: test test_provider: - @echo "" - @echo "== test_provider ===================================================================" - @echo "" cd provider && go test -v -short ./... -parallel $(TESTPARALLELISM) - -tfgen: install_plugins upstream tfgen_no_deps - -tfgen_no_deps: export PULUMI_HOME := $(WORKING_DIR)/.pulumi -tfgen_no_deps: export PATH := $(WORKING_DIR)/.pulumi/bin:$(PATH) -tfgen_no_deps: export PULUMI_CONVERT := $(PULUMI_CONVERT) -tfgen_no_deps: export PULUMI_CONVERT_EXAMPLES_CACHE_DIR := $(WORKING_DIR)/.pulumi/examples-cache -tfgen_no_deps: export PULUMI_DISABLE_AUTOMATIC_PLUGIN_ACQUISITION := $(PULUMI_CONVERT) -tfgen_no_deps: export PULUMI_MISSING_DOCS_ERROR := $(PULUMI_MISSING_DOCS_ERROR) -tfgen_no_deps: tfgen_build_only +.PHONY: test_provider + +tfgen: schema +schema: .make/schema +# This does actually have dependencies, but we're keeping it around for backwards compatibility for now +tfgen_no_deps: .make/schema +.make/schema: export PULUMI_HOME := $(WORKING_DIR)/.pulumi +.make/schema: export PATH := $(WORKING_DIR)/.pulumi/bin:$(PATH) +.make/schema: export PULUMI_CONVERT := $(PULUMI_CONVERT) +.make/schema: export PULUMI_CONVERT_EXAMPLES_CACHE_DIR := $(WORKING_DIR)/.pulumi/examples-cache +.make/schema: export PULUMI_DISABLE_AUTOMATIC_PLUGIN_ACQUISITION := $(PULUMI_CONVERT) +.make/schema: export PULUMI_MISSING_DOCS_ERROR := $(PULUMI_MISSING_DOCS_ERROR) +.make/schema: bin/$(TFGEN) .make/install_plugins .make/upstream $(WORKING_DIR)/bin/$(TFGEN) schema --out provider/cmd/$(PROVIDER) (cd provider && VERSION=$(VERSION_GENERIC) go generate cmd/$(PROVIDER)/main.go) - -tfgen_build_only: + @touch $@ +tfgen_build_only: bin/$(TFGEN) +bin/$(TFGEN): provider/*.go provider/go.* .make/upstream (cd provider && go build $(PULUMI_PROVIDER_BUILD_PARALLELISM) -o $(WORKING_DIR)/bin/$(TFGEN) -ldflags "$(LDFLAGS_PROJ_VERSION) $(LDFLAGS_EXTRAS)" $(PROJECT)/$(PROVIDER_PATH)/cmd/$(TFGEN)) +.PHONY: tfgen schema tfgen_no_deps tfgen_build_only -upstream: +# Apply patches to the upstream submodule, if it exists +upstream: .make/upstream +# Re-run if the upstream commit or the patches change +.make/upstream: $(wildcard patches/*) $(wildcard .git/modules/upstream/HEAD) ifneq ("$(wildcard upstream)","") ./upstream.sh init endif + @touch $@ +.PHONY: upstream bin/pulumi-java-gen: .pulumi-java-gen.version pulumictl download-binary -n pulumi-language-java -v v$(shell cat .pulumi-java-gen.version) -r pulumi/pulumi-java @@ -183,6 +276,7 @@ bin/pulumi-java-gen: .pulumi-java-gen.version # ci-mgmt: .ci-mgmt.yaml go run github.com/pulumi/ci-mgmt/provider-ci@master generate +.PHONY: ci-mgmt # Because some codegen depends on the version of the CLI used, we install a local CLI # version pinned to the same version as `provider/go.mod`. @@ -193,6 +287,7 @@ ci-mgmt: .ci-mgmt.yaml .pulumi/bin/pulumi: .pulumi/version @if [ -x .pulumi/bin/pulumi ] && [ "v$$(cat .pulumi/version)" = "$$(.pulumi/bin/pulumi version)" ]; then \ echo "pulumi/bin/pulumi version: v$$(cat .pulumi/version)"; \ + touch $@; \ else \ curl -fsSL https://get.pulumi.com | \ HOME=$(WORKING_DIR) sh -s -- --version "$$(cat .pulumi/version)"; \ @@ -200,14 +295,12 @@ ci-mgmt: .ci-mgmt.yaml # Compute the version of Pulumi to use by inspecting the Go dependencies of the provider. .pulumi/version: provider/go.mod - @mkdir -p .pulumi - @cd provider && go list -f "{{slice .Version 1}}" -m github.com/pulumi/pulumi/pkg/v3 | tee ../$@ + cd provider && go list -f "{{slice .Version 1}}" -m github.com/pulumi/pulumi/pkg/v3 | tee ../$@ # Start debug server for tfgen debug_tfgen: dlv --listen=:2345 --headless=true --api-version=2 exec $(WORKING_DIR)/bin/$(TFGEN) -- schema --out provider/cmd/$(PROVIDER) - -.PHONY: development build build_sdks install_go_sdk install_java_sdk install_python_sdk install_sdks only_build build_dotnet build_go build_java build_nodejs build_python clean cleanup help install_dotnet_sdk install_nodejs_sdk install_plugins lint_provider provider provider_no_deps test tfgen upstream ci-mgmt test_provider debug_tfgen tfgen_build_only +.PHONY: debug_tfgen # Provider cross-platform build & packaging diff --git a/sdk/go.mod b/sdk/go.mod index 74ca553c3..1f9d3338c 100644 --- a/sdk/go.mod +++ b/sdk/go.mod @@ -4,7 +4,6 @@ go 1.21 require ( github.com/blang/semver v3.5.1+incompatible - github.com/pulumi/pulumi-rancher2/sdk/v7 v7.1.2 github.com/pulumi/pulumi/sdk/v3 v3.140.0 ) diff --git a/sdk/go.sum b/sdk/go.sum index cc5b8b29f..22da94d1a 100644 --- a/sdk/go.sum +++ b/sdk/go.sum @@ -150,8 +150,6 @@ github.com/pulumi/appdash v0.0.0-20231130102222-75f619a67231 h1:vkHw5I/plNdTr435 github.com/pulumi/appdash v0.0.0-20231130102222-75f619a67231/go.mod h1:murToZ2N9hNJzewjHBgfFdXhZKjY3z5cYC1VXk+lbFE= github.com/pulumi/esc v0.9.1 h1:HH5eEv8sgyxSpY5a8yePyqFXzA8cvBvapfH8457+mIs= github.com/pulumi/esc v0.9.1/go.mod h1:oEJ6bOsjYlQUpjf70GiX+CXn3VBmpwFDxUTlmtUN84c= -github.com/pulumi/pulumi-rancher2/sdk/v7 v7.1.2 h1:XbvZmJEzI31tx9x295ZUWZoFyNdRD5VhMGnL+qw239I= -github.com/pulumi/pulumi-rancher2/sdk/v7 v7.1.2/go.mod h1:/iAGxiDiuJ5z5KiI5lxKuNG2YOxEC/Tj2vY8Fzw9+bE= github.com/pulumi/pulumi/sdk/v3 v3.140.0 h1:+Z/RBvdYg7tBNkBwk4p/FzlV7niBT3TbLAICq/Y0LDU= github.com/pulumi/pulumi/sdk/v3 v3.140.0/go.mod h1:PvKsX88co8XuwuPdzolMvew5lZV+4JmZfkeSjj7A6dI= github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= diff --git a/upstream.sh b/upstream.sh index 87593cde3..640b83632 100755 --- a/upstream.sh +++ b/upstream.sh @@ -138,11 +138,14 @@ apply_patches() { # Iterating over the patches folder in sorted order, # apply the patch using a 3-way merge strategy. This mirrors the default behavior of 'git merge' cd upstream + # Allow directory to be empty + shopt -s nullglob for patch in ../patches/*.patch; do if ! git apply --3way "${patch}" --allow-empty; then err_failed_to_apply "$(basename "${patch}")" fi done + shopt -u nullglob } clean_rebases() { @@ -227,13 +230,16 @@ checkout() { # Create a new branch 'pulumi/patch-checkout' which will contain the commits for each patch git checkout -B pulumi/patch-checkout + # Allow directory to be empty + shopt -s nullglob for patch in ../patches/*.patch; do if ! git am --3way "${patch}"; then err_failed_to_apply "$(basename "${patch}")" fi done + shopt -u nullglob - cat <