From 9f3a5be61773360129494e71c9dfd1d6b81ada81 Mon Sep 17 00:00:00 2001 From: BBBmau Date: Wed, 6 Mar 2024 09:08:15 -0800 Subject: [PATCH 01/20] reduce to one job in teamcity diff check --- .../teamcity-services-diff-check.yml | 29 +++++++++---------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/.github/workflows/teamcity-services-diff-check.yml b/.github/workflows/teamcity-services-diff-check.yml index 37dd8e218554..3e4fa2d2bbce 100644 --- a/.github/workflows/teamcity-services-diff-check.yml +++ b/.github/workflows/teamcity-services-diff-check.yml @@ -13,6 +13,10 @@ jobs: runs-on: ubuntu-22.04 outputs: services: ${{steps.services.outputs.services}} + teamcity-services-diff-check: + + needs: check-pr + runs-on: ubuntu-22.04 steps: - name: Checkout Repository uses: actions/checkout@v4 @@ -26,24 +30,17 @@ jobs: if [ "$newServices" = "0" ];then echo "No new service found." fi - terraform-provider-google: - if: ${{needs.check-pr.outputs.services != '0'}} - needs: check-pr - uses: ./.github/workflows/build-downstream.yml - with: - repo: 'terraform-provider-google' + - name: TeamCity Google Provider Generate + if: ${{steps.services.outputs.services != '0'}} + uses: ./.github/workflows/build-downstream.yml + with: + repo: 'terraform-provider-google' - terraform-provider-google-beta: - if: ${{needs.check-pr.outputs.services != '0'}} - needs: check-pr - uses: ./.github/workflows/build-downstream.yml - with: - repo: 'terraform-provider-google-beta' + - name: TeamCity Google Beta Provider Generate + uses: ./.github/workflows/build-downstream.yml + with: + repo: 'terraform-provider-google-beta' - teamcity-services-diff-check: - needs: [terraform-provider-google, terraform-provider-google-beta] - runs-on: ubuntu-22.04 - steps: - name: Checkout Repository uses: actions/checkout@v4 From 099c99b70037ec1147e7fc3991667d0887391b45 Mon Sep 17 00:00:00 2001 From: BBBmau Date: Wed, 6 Mar 2024 09:12:30 -0800 Subject: [PATCH 02/20] remove check-pr step --- .github/workflows/teamcity-services-diff-check.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/teamcity-services-diff-check.yml b/.github/workflows/teamcity-services-diff-check.yml index 3e4fa2d2bbce..9818ce9e9664 100644 --- a/.github/workflows/teamcity-services-diff-check.yml +++ b/.github/workflows/teamcity-services-diff-check.yml @@ -9,13 +9,8 @@ on: - 'mmv1/third_party/terraform/.teamcity/components/inputs/services_beta.kt' - 'mmv1/products/**' jobs: - check-pr: - runs-on: ubuntu-22.04 - outputs: - services: ${{steps.services.outputs.services}} teamcity-services-diff-check: - needs: check-pr runs-on: ubuntu-22.04 steps: - name: Checkout Repository From ff546a7157274d0413e112bf743899a9ecbf6877 Mon Sep 17 00:00:00 2001 From: BBBmau Date: Wed, 6 Mar 2024 09:15:45 -0800 Subject: [PATCH 03/20] add new service --- mmv1/products/midquery/product.yaml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 mmv1/products/midquery/product.yaml diff --git a/mmv1/products/midquery/product.yaml b/mmv1/products/midquery/product.yaml new file mode 100644 index 000000000000..fa3cfc09a930 --- /dev/null +++ b/mmv1/products/midquery/product.yaml @@ -0,0 +1,22 @@ +# Copyright 2022 Google Inc. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +--- !ruby/object:Api::Product +name: MidQuery +display_name: Mid Query +versions: + - !ruby/object:Api::Product::Version + name: beta + base_url: https://workstations.googleapis.com/v1beta/ +scopes: + - https://www.googleapis.com/auth/cloud-platform \ No newline at end of file From 1d5513c530edcd513efda7e2be944628bf997be6 Mon Sep 17 00:00:00 2001 From: BBBmau Date: Wed, 6 Mar 2024 12:16:00 -0800 Subject: [PATCH 04/20] add resource --- mmv1/products/midquery/AgentPool.yaml | 80 +++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 mmv1/products/midquery/AgentPool.yaml diff --git a/mmv1/products/midquery/AgentPool.yaml b/mmv1/products/midquery/AgentPool.yaml new file mode 100644 index 000000000000..1eadaf5207c2 --- /dev/null +++ b/mmv1/products/midquery/AgentPool.yaml @@ -0,0 +1,80 @@ +# Copyright 2023 Google Inc. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +--- !ruby/object:Api::Resource +name: 'AgentPool' +description: 'Represents an On-Premises Agent pool.' +base_url: 'projects/{{project}}/agentPools' +self_link: 'projects/{{project}}/agentPools/{{name}}' +create_url: 'projects/{{project}}/agentPools?agentPoolId={{name}}' +update_verb: :PATCH +update_mask: true +references: !ruby/object:Api::Resource::ReferenceLinks + guides: + 'Official Documentation': 'https://cloud.google.com/storage-transfer/docs/on-prem-agent-pools' + api: 'https://cloud.google.com/storage-transfer/docs/reference/rest/v1/projects.agentPools' +examples: + - !ruby/object:Provider::Terraform::Examples + name: 'agent_pool_basic' + primary_resource_id: + 'example' + # Skip generating this test as the example is covered in resource_storage_transfer_agent_pool_test.go + skip_test: true + vars: + agent-pool-name: 'agent-pool-example' + test_env_vars: + project_id: :PROJECT_NAME +timeouts: !ruby/object:Api::Timeouts + insert_minutes: 30 +custom_code: !ruby/object:Provider::Terraform::CustomCode + constants: templates/terraform/constants/agent_pool.go.erb + post_create: templates/terraform/post_create/agent_pool.go.erb + pre_update: templates/terraform/pre_update/agent_pool.go.erb + post_import: templates/terraform/post_import/agent_pool.go.erb +properties: + - !ruby/object:Api::Type::String + name: 'name' + description: | + The ID of the agent pool to create. + The agentPoolId must meet the following requirements: + * Length of 128 characters or less. + * Not start with the string goog. + * Start with a lowercase ASCII character, followed by: + * Zero or more: lowercase Latin alphabet characters, numerals, hyphens (-), periods (.), underscores (_), or tildes (~). + * One or more numerals or lowercase ASCII characters. + As expressed by the regular expression: ^(?!goog)[a-z]([a-z0-9-._~]*[a-z0-9])?$. + immutable: true + required: true + url_param_only: true + - !ruby/object:Api::Type::String + name: 'displayName' + description: 'Specifies the client-specified AgentPool description.' + - !ruby/object:Api::Type::Enum + name: 'state' + description: 'Specifies the state of the AgentPool.' + output: true + values: + - :CREATING + - :CREATED + - :DELETING + - !ruby/object:Api::Type::NestedObject + name: 'bandwidthLimit' + description: | + Specifies the bandwidth limit details. If this field is unspecified, the default value is set as 'No Limit'. + properties: + - !ruby/object:Api::Type::String + name: 'limitMbps' + description: + 'Bandwidth rate in megabytes per second, distributed across all the + agents in the pool.' + required: true \ No newline at end of file From 5c56331a6aeeb2082fd64640d2e3965718360066 Mon Sep 17 00:00:00 2001 From: BBBmau Date: Wed, 6 Mar 2024 09:08:15 -0800 Subject: [PATCH 05/20] reduce to one job in teamcity diff check --- .../teamcity-services-diff-check.yml | 29 +++++++++---------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/.github/workflows/teamcity-services-diff-check.yml b/.github/workflows/teamcity-services-diff-check.yml index 37dd8e218554..3e4fa2d2bbce 100644 --- a/.github/workflows/teamcity-services-diff-check.yml +++ b/.github/workflows/teamcity-services-diff-check.yml @@ -13,6 +13,10 @@ jobs: runs-on: ubuntu-22.04 outputs: services: ${{steps.services.outputs.services}} + teamcity-services-diff-check: + + needs: check-pr + runs-on: ubuntu-22.04 steps: - name: Checkout Repository uses: actions/checkout@v4 @@ -26,24 +30,17 @@ jobs: if [ "$newServices" = "0" ];then echo "No new service found." fi - terraform-provider-google: - if: ${{needs.check-pr.outputs.services != '0'}} - needs: check-pr - uses: ./.github/workflows/build-downstream.yml - with: - repo: 'terraform-provider-google' + - name: TeamCity Google Provider Generate + if: ${{steps.services.outputs.services != '0'}} + uses: ./.github/workflows/build-downstream.yml + with: + repo: 'terraform-provider-google' - terraform-provider-google-beta: - if: ${{needs.check-pr.outputs.services != '0'}} - needs: check-pr - uses: ./.github/workflows/build-downstream.yml - with: - repo: 'terraform-provider-google-beta' + - name: TeamCity Google Beta Provider Generate + uses: ./.github/workflows/build-downstream.yml + with: + repo: 'terraform-provider-google-beta' - teamcity-services-diff-check: - needs: [terraform-provider-google, terraform-provider-google-beta] - runs-on: ubuntu-22.04 - steps: - name: Checkout Repository uses: actions/checkout@v4 From 861a49932aa1576b182bf123d0590b6bfce669bb Mon Sep 17 00:00:00 2001 From: BBBmau Date: Wed, 6 Mar 2024 09:12:30 -0800 Subject: [PATCH 06/20] remove check-pr step --- .github/workflows/teamcity-services-diff-check.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/teamcity-services-diff-check.yml b/.github/workflows/teamcity-services-diff-check.yml index 3e4fa2d2bbce..9818ce9e9664 100644 --- a/.github/workflows/teamcity-services-diff-check.yml +++ b/.github/workflows/teamcity-services-diff-check.yml @@ -9,13 +9,8 @@ on: - 'mmv1/third_party/terraform/.teamcity/components/inputs/services_beta.kt' - 'mmv1/products/**' jobs: - check-pr: - runs-on: ubuntu-22.04 - outputs: - services: ${{steps.services.outputs.services}} teamcity-services-diff-check: - needs: check-pr runs-on: ubuntu-22.04 steps: - name: Checkout Repository From 313884b8ec01805edf5f9f6b36dfcda407b725e4 Mon Sep 17 00:00:00 2001 From: BBBmau Date: Wed, 6 Mar 2024 09:18:15 -0800 Subject: [PATCH 07/20] add checkout before provider generate --- .github/workflows/teamcity-services-diff-check.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/teamcity-services-diff-check.yml b/.github/workflows/teamcity-services-diff-check.yml index 9818ce9e9664..194ece1b6f34 100644 --- a/.github/workflows/teamcity-services-diff-check.yml +++ b/.github/workflows/teamcity-services-diff-check.yml @@ -25,6 +25,9 @@ jobs: if [ "$newServices" = "0" ];then echo "No new service found." fi + - name: Checkout Repository + uses: actions/checkout@v4 + - name: TeamCity Google Provider Generate if: ${{steps.services.outputs.services != '0'}} uses: ./.github/workflows/build-downstream.yml From 32e850d9d8619e9b8234815c2d222f093b839c37 Mon Sep 17 00:00:00 2001 From: BBBmau Date: Wed, 6 Mar 2024 11:28:45 -0800 Subject: [PATCH 08/20] build-downstream action test --- .github/actions/build-downstream/action.yml | 104 ++++++++++++++++++ .../teamcity-services-diff-check.yml | 7 +- 2 files changed, 106 insertions(+), 5 deletions(-) create mode 100644 .github/actions/build-downstream/action.yml diff --git a/.github/actions/build-downstream/action.yml b/.github/actions/build-downstream/action.yml new file mode 100644 index 000000000000..2bb19daf320c --- /dev/null +++ b/.github/actions/build-downstream/action.yml @@ -0,0 +1,104 @@ +name: build +description: Generates Provider + + +runs: + using: "composite" + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Ruby + uses: ruby/setup-ruby@036ef458ddccddb148a2b9fb67e95a22fdbf728b # v1.160.0 + with: + ruby-version: '3.1' + + - name: Cache Bundler gems + uses: actions/cache@v3 + with: + path: mmv1/vendor/bundle + key: ${{ runner.os }}-gems-${{ hashFiles('mmv1/**/Gemfile.lock') }} + restore-keys: | + ${{ runner.os }}-gems- + + - name: Install Ruby dependencies + shell: bash + run: | + bundle config path mmv1/vendor/bundle + bundle install + working-directory: mmv1 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: '^1.20' + + # Cache Go modules + - name: Cache Go modules + uses: actions/cache@v3 + with: + path: ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + + - run: go install golang.org/x/tools/cmd/goimports@latest + shell: bash + - name: Build ${{ inputs.repo }} + shell: bash + env: + BASE_BRANCH: ${{ github.event.pull_request.base.ref || github.ref_name }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + set -e + set -x + # Set GOPATH to a directory the runner user has access to + export GOPATH=~/go + + function clone_repo() { + export OUTPUT_PATH=$GOPATH/src/github.com/$UPSTREAM_OWNER/$GH_REPO + GITHUB_PATH=https://x-access-token:$GITHUB_TOKEN@github.com/$UPSTREAM_OWNER/$GH_REPO + mkdir -p "$(dirname $OUTPUT_PATH)" + git clone $GITHUB_PATH $OUTPUT_PATH --branch $BASE_BRANCH + } + + GH_REPO="${{ inputs.repo }}" + if [ "$GH_REPO" == "docs-examples" ] && [ "$BASE_BRANCH" == "main" ]; then + BASE_BRANCH="master" + fi + + GITHUB_PATH=https://x-access-token:$GITHUB_TOKEN@github.com/$UPSTREAM_OWNER/$GH_REPO + + if [[ "$GH_REPO" == terraform-provider-google* ]]; then + UPSTREAM_OWNER=hashicorp + clone_repo + if [ "$GH_REPO" == "terraform-provider-google" ]; then + export VERSION=ga + else + export VERSION=beta + fi + make clean-provider + make provider + elif [ "$GH_REPO" == "terraform-google-conversion" ]; then + UPSTREAM_OWNER=GoogleCloudPlatform + clone_repo + make clean-tgc + make tgc + elif [ "$GH_REPO" == "docs-examples" ]; then + UPSTREAM_OWNER=terraform-google-modules + clone_repo + make tf-oics + else + echo "case not supported" + exit 1 + fi + + (current_dir=$(pwd) && cd $OUTPUT_PATH && zip -r "$current_dir/output.zip" .) + + - name: Upload built artifacts + uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0 + with: + name: artifact-${{ inputs.repo }} + path: output.zip \ No newline at end of file diff --git a/.github/workflows/teamcity-services-diff-check.yml b/.github/workflows/teamcity-services-diff-check.yml index 194ece1b6f34..6c4eeeb2cc1e 100644 --- a/.github/workflows/teamcity-services-diff-check.yml +++ b/.github/workflows/teamcity-services-diff-check.yml @@ -25,17 +25,14 @@ jobs: if [ "$newServices" = "0" ];then echo "No new service found." fi - - name: Checkout Repository - uses: actions/checkout@v4 - - name: TeamCity Google Provider Generate if: ${{steps.services.outputs.services != '0'}} - uses: ./.github/workflows/build-downstream.yml + uses: ./.github/actions/build-downstream/action.yml with: repo: 'terraform-provider-google' - name: TeamCity Google Beta Provider Generate - uses: ./.github/workflows/build-downstream.yml + uses: ./.github/actions/build-downstream/action.yml with: repo: 'terraform-provider-google-beta' From 31ff7624f35fa73fadecc4d10252ce26e100781b Mon Sep 17 00:00:00 2001 From: BBBmau Date: Wed, 6 Mar 2024 11:49:45 -0800 Subject: [PATCH 09/20] action set --- .github/workflows/teamcity-services-diff-check.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/teamcity-services-diff-check.yml b/.github/workflows/teamcity-services-diff-check.yml index 6c4eeeb2cc1e..aec18cc2a67e 100644 --- a/.github/workflows/teamcity-services-diff-check.yml +++ b/.github/workflows/teamcity-services-diff-check.yml @@ -27,12 +27,12 @@ jobs: fi - name: TeamCity Google Provider Generate if: ${{steps.services.outputs.services != '0'}} - uses: ./.github/actions/build-downstream/action.yml + uses: ./.github/actions/build-downstream with: repo: 'terraform-provider-google' - name: TeamCity Google Beta Provider Generate - uses: ./.github/actions/build-downstream/action.yml + uses: ./.github/actions/build-downstream with: repo: 'terraform-provider-google-beta' From 1d9f33e8e77cd287cacb670958dbee3b929f27fc Mon Sep 17 00:00:00 2001 From: BBBmau Date: Wed, 6 Mar 2024 12:01:35 -0800 Subject: [PATCH 10/20] add token input in downstream action --- .github/actions/build-downstream/action.yml | 10 ++++++++-- .github/workflows/teamcity-services-diff-check.yml | 5 ++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/.github/actions/build-downstream/action.yml b/.github/actions/build-downstream/action.yml index 2bb19daf320c..b4e03f5d5d7e 100644 --- a/.github/actions/build-downstream/action.yml +++ b/.github/actions/build-downstream/action.yml @@ -1,6 +1,12 @@ name: build description: Generates Provider - +inputs: + repo: + description: "provider repo" + required: true + token: + description: "github token" + required: true runs: using: "composite" @@ -50,7 +56,7 @@ runs: shell: bash env: BASE_BRANCH: ${{ github.event.pull_request.base.ref || github.ref_name }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ inputs.token }} run: | set -e set -x diff --git a/.github/workflows/teamcity-services-diff-check.yml b/.github/workflows/teamcity-services-diff-check.yml index aec18cc2a67e..8f2fbbd7f274 100644 --- a/.github/workflows/teamcity-services-diff-check.yml +++ b/.github/workflows/teamcity-services-diff-check.yml @@ -10,7 +10,8 @@ on: - 'mmv1/products/**' jobs: teamcity-services-diff-check: - + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} runs-on: ubuntu-22.04 steps: - name: Checkout Repository @@ -30,11 +31,13 @@ jobs: uses: ./.github/actions/build-downstream with: repo: 'terraform-provider-google' + token: '$GITHUB_TOKEN' - name: TeamCity Google Beta Provider Generate uses: ./.github/actions/build-downstream with: repo: 'terraform-provider-google-beta' + token: '$GITHUB_TOKEN' - name: Checkout Repository uses: actions/checkout@v4 From 32669160333b2dc70c6e1b2443e2f6214579312d Mon Sep 17 00:00:00 2001 From: BBBmau Date: Wed, 6 Mar 2024 12:33:15 -0800 Subject: [PATCH 11/20] apply action downstream to weekly diff check --- .github/actions/build-downstream/action.yml | 2 +- .../teamcity-services-diff-check-weekly.yml | 110 +++++++++--------- 2 files changed, 57 insertions(+), 55 deletions(-) diff --git a/.github/actions/build-downstream/action.yml b/.github/actions/build-downstream/action.yml index b4e03f5d5d7e..6d68ece4a9c5 100644 --- a/.github/actions/build-downstream/action.yml +++ b/.github/actions/build-downstream/action.yml @@ -1,5 +1,5 @@ name: build -description: Generates Provider +description: Generates Google/Google-Beta Provider inputs: repo: description: "provider repo" diff --git a/.github/workflows/teamcity-services-diff-check-weekly.yml b/.github/workflows/teamcity-services-diff-check-weekly.yml index 5d857f0eda90..6bfdc83b5d82 100644 --- a/.github/workflows/teamcity-services-diff-check-weekly.yml +++ b/.github/workflows/teamcity-services-diff-check-weekly.yml @@ -9,59 +9,61 @@ on: schedule: # Every Tuesday morning - cron: '0 4 * * 2' - jobs: - terraform-provider-google: - uses: ./.github/workflows/build-downstream.yml - with: - repo: 'terraform-provider-google' - - terraform-provider-google-beta: - uses: ./.github/workflows/build-downstream.yml - with: - repo: 'terraform-provider-google-beta' - teamcity-services-diff-check: - needs: [terraform-provider-google, terraform-provider-google-beta] - runs-on: ubuntu-22.04 - steps: - - name: Checkout Repository - uses: actions/checkout@v4 - - - name: Setup Go - uses: actions/setup-go@v4 - with: - go-version: '^1.20' - - - name: Download built artifacts - GA provider - uses: actions/download-artifact@v2 - with: - name: artifact-terraform-provider-google - path: artifacts - - - name: Unzip the artifacts and delete the zip - run: | - unzip -o artifacts/output.zip -d ./provider - rm artifacts/output.zip - - - name: Download built artifacts - Beta provider - uses: actions/download-artifact@v2 - with: - name: artifact-terraform-provider-google-beta - path: artifacts - - - name: Unzip the artifacts and delete the zip - run: | - unzip -o artifacts/output.zip -d ./provider - rm artifacts/output.zip - - - name: Check that new services have been added to the TeamCity configuration code - run: | - # Create lists of service packages in providers - ls provider/google/services > tools/teamcity-diff-check/services_ga.txt - ls provider/google-beta/services > tools/teamcity-diff-check/services_beta.txt - - # Run tool to compare service packages in the providers vs those listed in TeamCity config files - cd tools/teamcity-diff-check - go run main.go -service_file=services_ga - go run main.go -service_file=services_beta + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + runs-on: ubuntu-22.04 + steps: + - name: TeamCity Google Provider Generate + uses: ./.github/actions/build-downstream + with: + repo: 'terraform-provider-google' + token: '$GITHUB_TOKEN' + + - name: TeamCity Google Beta Provider Generate + uses: ./.github/actions/build-downstream + with: + repo: 'terraform-provider-google-beta' + token: '$GITHUB_TOKEN' + + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Setup Go + uses: actions/setup-go@v4 + with: + go-version: '^1.20' + + - name: Download built artifacts - GA provider + uses: actions/download-artifact@v2 + with: + name: artifact-terraform-provider-google + path: artifacts + + - name: Unzip the artifacts and delete the zip + run: | + unzip -o artifacts/output.zip -d ./provider + rm artifacts/output.zip + + - name: Download built artifacts - Beta provider + uses: actions/download-artifact@v2 + with: + name: artifact-terraform-provider-google-beta + path: artifacts + + - name: Unzip the artifacts and delete the zip + run: | + unzip -o artifacts/output.zip -d ./provider + rm artifacts/output.zip + + - name: Check that new services have been added to the TeamCity configuration code + run: | + # Create lists of service packages in providers + ls provider/google/services > tools/teamcity-diff-check/services_ga.txt + ls provider/google-beta/services > tools/teamcity-diff-check/services_beta.txt + + # Run tool to compare service packages in the providers vs those listed in TeamCity config files + cd tools/teamcity-diff-check + go run main.go -service_file=services_ga + go run main.go -service_file=services_beta From 96d0a97708b1890793dbb8cb136bf872228f6d3e Mon Sep 17 00:00:00 2001 From: BBBmau Date: Wed, 6 Mar 2024 12:41:08 -0800 Subject: [PATCH 12/20] add early exit if no services found --- .github/workflows/teamcity-services-diff-check.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/teamcity-services-diff-check.yml b/.github/workflows/teamcity-services-diff-check.yml index 8f2fbbd7f274..4ae7eed24003 100644 --- a/.github/workflows/teamcity-services-diff-check.yml +++ b/.github/workflows/teamcity-services-diff-check.yml @@ -24,7 +24,8 @@ jobs: newServices=$(($(git diff --name-only --diff-filter=A origin/main HEAD | grep -P "mmv1/products/.*/product.yaml" | wc -l))) echo "services=$newServices" >> "${GITHUB_OUTPUT}" if [ "$newServices" = "0" ];then - echo "No new service found." + echo "No new service found." + exit 1 fi - name: TeamCity Google Provider Generate if: ${{steps.services.outputs.services != '0'}} From 4a68564a84a0ca651325036df1ec068193eb7732 Mon Sep 17 00:00:00 2001 From: BBBmau Date: Wed, 6 Mar 2024 12:54:05 -0800 Subject: [PATCH 13/20] skip all steps if no services found instead of failing --- .github/workflows/teamcity-services-diff-check.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/teamcity-services-diff-check.yml b/.github/workflows/teamcity-services-diff-check.yml index 4ae7eed24003..9e8b27a5494f 100644 --- a/.github/workflows/teamcity-services-diff-check.yml +++ b/.github/workflows/teamcity-services-diff-check.yml @@ -25,9 +25,9 @@ jobs: echo "services=$newServices" >> "${GITHUB_OUTPUT}" if [ "$newServices" = "0" ];then echo "No new service found." - exit 1 fi - name: TeamCity Google Provider Generate + id: generate if: ${{steps.services.outputs.services != '0'}} uses: ./.github/actions/build-downstream with: @@ -35,42 +35,50 @@ jobs: token: '$GITHUB_TOKEN' - name: TeamCity Google Beta Provider Generate + if: steps.generate.outcome == 'success' uses: ./.github/actions/build-downstream with: repo: 'terraform-provider-google-beta' token: '$GITHUB_TOKEN' - name: Checkout Repository + if: steps.generate.outcome == 'success' uses: actions/checkout@v4 - name: Setup Go + if: steps.generate.outcome == 'success' uses: actions/setup-go@v4 with: go-version: '^1.20' - name: Download built artifacts - GA provider + if: steps.generate.outcome == 'success' uses: actions/download-artifact@v2 with: name: artifact-terraform-provider-google path: artifacts - name: Unzip the artifacts and delete the zip + if: steps.generate.outcome == 'success' run: | unzip -o artifacts/output.zip -d ./provider rm artifacts/output.zip - name: Download built artifacts - Beta provider + if: steps.generate.outcome == 'success' uses: actions/download-artifact@v2 with: name: artifact-terraform-provider-google-beta path: artifacts - name: Unzip the artifacts and delete the zip + if: steps.generate.outcome == 'success' run: | unzip -o artifacts/output.zip -d ./provider rm artifacts/output.zip - name: Check that new services have been added to the TeamCity configuration code + if: steps.generate.outcome == 'success' run: | # Create lists of service packages in providers ls provider/google/services > tools/teamcity-diff-check/services_ga.txt From 6c75e274b18badce902316f0d7ae6d5996dc17f8 Mon Sep 17 00:00:00 2001 From: BBBmau Date: Mon, 11 Mar 2024 14:27:17 -0700 Subject: [PATCH 14/20] remove artifacts and extra setup go --- .github/actions/build-downstream/action.yml | 8 +---- .../teamcity-services-diff-check-weekly.yml | 30 ------------------- 2 files changed, 1 insertion(+), 37 deletions(-) diff --git a/.github/actions/build-downstream/action.yml b/.github/actions/build-downstream/action.yml index 6d68ece4a9c5..2ae9db0fc8a4 100644 --- a/.github/actions/build-downstream/action.yml +++ b/.github/actions/build-downstream/action.yml @@ -101,10 +101,4 @@ runs: exit 1 fi - (current_dir=$(pwd) && cd $OUTPUT_PATH && zip -r "$current_dir/output.zip" .) - - - name: Upload built artifacts - uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0 - with: - name: artifact-${{ inputs.repo }} - path: output.zip \ No newline at end of file + (current_dir=$(pwd) && cd $OUTPUT_PATH && zip -r "$current_dir/output.zip" .) \ No newline at end of file diff --git a/.github/workflows/teamcity-services-diff-check-weekly.yml b/.github/workflows/teamcity-services-diff-check-weekly.yml index 1628a9d584d8..b63a9cd99876 100644 --- a/.github/workflows/teamcity-services-diff-check-weekly.yml +++ b/.github/workflows/teamcity-services-diff-check-weekly.yml @@ -21,43 +21,13 @@ jobs: with: repo: 'terraform-provider-google' token: '$GITHUB_TOKEN' - - name: TeamCity Google Beta Provider Generate uses: ./.github/actions/build-downstream with: repo: 'terraform-provider-google-beta' token: '$GITHUB_TOKEN' - - name: Checkout Repository uses: actions/checkout@v4 - - - name: Setup Go - uses: actions/setup-go@v4 - with: - go-version: '^1.20' - - - name: Download built artifacts - GA provider - uses: actions/download-artifact@v2 - with: - name: artifact-terraform-provider-google - path: artifacts - - - name: Unzip the artifacts and delete the zip - run: | - unzip -o artifacts/output.zip -d ./provider - rm artifacts/output.zip - - - name: Download built artifacts - Beta provider - uses: actions/download-artifact@v2 - with: - name: artifact-terraform-provider-google-beta - path: artifacts - - - name: Unzip the artifacts and delete the zip - run: | - unzip -o artifacts/output.zip -d ./provider - rm artifacts/output.zip - - name: Check that new services have been added to the TeamCity configuration code run: | # Create lists of service packages in providers From d6dedafafbfdf5154f933d2154a419faa776471d Mon Sep 17 00:00:00 2001 From: BBBmau Date: Mon, 11 Mar 2024 14:38:22 -0700 Subject: [PATCH 15/20] remove artifacts in diff-check.yml --- .../teamcity-services-diff-check-weekly.yml | 4 +-- .../teamcity-services-diff-check.yml | 35 ------------------- 2 files changed, 2 insertions(+), 37 deletions(-) diff --git a/.github/workflows/teamcity-services-diff-check-weekly.yml b/.github/workflows/teamcity-services-diff-check-weekly.yml index b63a9cd99876..b255c8cff6cb 100644 --- a/.github/workflows/teamcity-services-diff-check-weekly.yml +++ b/.github/workflows/teamcity-services-diff-check-weekly.yml @@ -16,6 +16,8 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} runs-on: ubuntu-22.04 steps: + - name: Checkout Repository + uses: actions/checkout@v4 - name: TeamCity Google Provider Generate uses: ./.github/actions/build-downstream with: @@ -26,8 +28,6 @@ jobs: with: repo: 'terraform-provider-google-beta' token: '$GITHUB_TOKEN' - - name: Checkout Repository - uses: actions/checkout@v4 - name: Check that new services have been added to the TeamCity configuration code run: | # Create lists of service packages in providers diff --git a/.github/workflows/teamcity-services-diff-check.yml b/.github/workflows/teamcity-services-diff-check.yml index 9e8b27a5494f..d832efc38133 100644 --- a/.github/workflows/teamcity-services-diff-check.yml +++ b/.github/workflows/teamcity-services-diff-check.yml @@ -33,50 +33,15 @@ jobs: with: repo: 'terraform-provider-google' token: '$GITHUB_TOKEN' - - name: TeamCity Google Beta Provider Generate if: steps.generate.outcome == 'success' uses: ./.github/actions/build-downstream with: repo: 'terraform-provider-google-beta' token: '$GITHUB_TOKEN' - - name: Checkout Repository if: steps.generate.outcome == 'success' uses: actions/checkout@v4 - - - name: Setup Go - if: steps.generate.outcome == 'success' - uses: actions/setup-go@v4 - with: - go-version: '^1.20' - - - name: Download built artifacts - GA provider - if: steps.generate.outcome == 'success' - uses: actions/download-artifact@v2 - with: - name: artifact-terraform-provider-google - path: artifacts - - - name: Unzip the artifacts and delete the zip - if: steps.generate.outcome == 'success' - run: | - unzip -o artifacts/output.zip -d ./provider - rm artifacts/output.zip - - - name: Download built artifacts - Beta provider - if: steps.generate.outcome == 'success' - uses: actions/download-artifact@v2 - with: - name: artifact-terraform-provider-google-beta - path: artifacts - - - name: Unzip the artifacts and delete the zip - if: steps.generate.outcome == 'success' - run: | - unzip -o artifacts/output.zip -d ./provider - rm artifacts/output.zip - - name: Check that new services have been added to the TeamCity configuration code if: steps.generate.outcome == 'success' run: | From 684c3ab0b8af1a33e1ff6f4eb133647e5163eabc Mon Sep 17 00:00:00 2001 From: BBBmau Date: Mon, 11 Mar 2024 14:44:45 -0700 Subject: [PATCH 16/20] removal of artifacts From 1d23407cc8824f359c0799d5f6c8ca5560e4aea2 Mon Sep 17 00:00:00 2001 From: BBBmau Date: Mon, 11 Mar 2024 15:52:30 -0700 Subject: [PATCH 17/20] using new directories From bcd692b771bc615b48c95a35f462410fc1614e94 Mon Sep 17 00:00:00 2001 From: BBBmau Date: Mon, 11 Mar 2024 15:52:56 -0700 Subject: [PATCH 18/20] using new directories From 6ff1332f62fb5e6d63292b3b322436d51d6ace36 Mon Sep 17 00:00:00 2001 From: BBBmau Date: Mon, 11 Mar 2024 16:50:24 -0700 Subject: [PATCH 19/20] test should show diff From 3fdc4aec70feee4adf3d8d0d029e9862cb3cfe11 Mon Sep 17 00:00:00 2001 From: BBBmau Date: Mon, 11 Mar 2024 16:53:41 -0700 Subject: [PATCH 20/20] test should show diff - failing due to new service