From 5c56331a6aeeb2082fd64640d2e3965718360066 Mon Sep 17 00:00:00 2001 From: BBBmau Date: Wed, 6 Mar 2024 09:08:15 -0800 Subject: [PATCH 01/18] 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 02/18] 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 03/18] 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 04/18] 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 05/18] 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 06/18] 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 07/18] 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 08/18] 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 09/18] 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 10/18] 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 11/18] 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 9314bbfd9cf822d0702754416920675ffb925562 Mon Sep 17 00:00:00 2001 From: BBBmau Date: Mon, 11 Mar 2024 15:51:46 -0700 Subject: [PATCH 12/18] use generated directories --- .github/workflows/teamcity-services-diff-check-weekly.yml | 6 ++++-- .github/workflows/teamcity-services-diff-check.yml | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/teamcity-services-diff-check-weekly.yml b/.github/workflows/teamcity-services-diff-check-weekly.yml index b255c8cff6cb..ecce07a388ee 100644 --- a/.github/workflows/teamcity-services-diff-check-weekly.yml +++ b/.github/workflows/teamcity-services-diff-check-weekly.yml @@ -23,16 +23,18 @@ jobs: with: repo: 'terraform-provider-google' token: '$GITHUB_TOKEN' + - run: export GOOGLE_REPO_PATH=$OUTPUT_PATH - name: TeamCity Google Beta Provider Generate uses: ./.github/actions/build-downstream with: repo: 'terraform-provider-google-beta' token: '$GITHUB_TOKEN' + - run: export GOOGLE_BETA_REPO_PATH=$OUTPUT_PATH - 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 + ls ${GOOGLE_REPO_PATH}/google/services > tools/teamcity-diff-check/services_ga.txt + ls ${GOOGLE_BETA_REPO_PATH}/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 diff --git a/.github/workflows/teamcity-services-diff-check.yml b/.github/workflows/teamcity-services-diff-check.yml index d832efc38133..3f8ff83b579b 100644 --- a/.github/workflows/teamcity-services-diff-check.yml +++ b/.github/workflows/teamcity-services-diff-check.yml @@ -33,12 +33,14 @@ jobs: with: repo: 'terraform-provider-google' token: '$GITHUB_TOKEN' + - run: export GOOGLE_REPO_PATH=$OUTPUT_PATH - 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' + - run: export GOOGLE_BETA_REPO_PATH=$OUTPUT_PATH - name: Checkout Repository if: steps.generate.outcome == 'success' uses: actions/checkout@v4 @@ -46,8 +48,8 @@ jobs: if: steps.generate.outcome == 'success' 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 + ls ${GOOGLE_REPO_PATH}/google/services > tools/teamcity-diff-check/services_ga.txt + ls ${GOOGLE_BETA_REPO_PATH}/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 From e38beccec519e35ca564c31c0a212ed1f80680ac Mon Sep 17 00:00:00 2001 From: BBBmau Date: Mon, 11 Mar 2024 16:15:50 -0700 Subject: [PATCH 13/18] outputpath test --- .github/actions/build-downstream/action.yml | 1 + .github/workflows/teamcity-services-diff-check-weekly.yml | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/actions/build-downstream/action.yml b/.github/actions/build-downstream/action.yml index 2ae9db0fc8a4..366ad9a96aed 100644 --- a/.github/actions/build-downstream/action.yml +++ b/.github/actions/build-downstream/action.yml @@ -65,6 +65,7 @@ runs: function clone_repo() { export OUTPUT_PATH=$GOPATH/src/github.com/$UPSTREAM_OWNER/$GH_REPO + echo $OUTPUT_PATH >> $GITHUB_ENV 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 diff --git a/.github/workflows/teamcity-services-diff-check-weekly.yml b/.github/workflows/teamcity-services-diff-check-weekly.yml index ecce07a388ee..7da8b330ea3f 100644 --- a/.github/workflows/teamcity-services-diff-check-weekly.yml +++ b/.github/workflows/teamcity-services-diff-check-weekly.yml @@ -23,13 +23,13 @@ jobs: with: repo: 'terraform-provider-google' token: '$GITHUB_TOKEN' - - run: export GOOGLE_REPO_PATH=$OUTPUT_PATH + - run: export GOOGLE_REPO_PATH=${{ env.OUTPUT_PATH}} - name: TeamCity Google Beta Provider Generate uses: ./.github/actions/build-downstream with: repo: 'terraform-provider-google-beta' token: '$GITHUB_TOKEN' - - run: export GOOGLE_BETA_REPO_PATH=$OUTPUT_PATH + - run: export GOOGLE_BETA_REPO_PATH=${{ env.OUTPUT_PATH}} - name: Check that new services have been added to the TeamCity configuration code run: | # Create lists of service packages in providers From 286539eb23bcd9954a5d1e13b8a992bd7f769534 Mon Sep 17 00:00:00 2001 From: BBBmau Date: Mon, 11 Mar 2024 16:24:42 -0700 Subject: [PATCH 14/18] use proper format --- .github/actions/build-downstream/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/build-downstream/action.yml b/.github/actions/build-downstream/action.yml index 366ad9a96aed..ff4fae5c5f1b 100644 --- a/.github/actions/build-downstream/action.yml +++ b/.github/actions/build-downstream/action.yml @@ -65,7 +65,7 @@ runs: function clone_repo() { export OUTPUT_PATH=$GOPATH/src/github.com/$UPSTREAM_OWNER/$GH_REPO - echo $OUTPUT_PATH >> $GITHUB_ENV + echo "$OUTPUT_PATH" >> $GITHUB_ENV 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 From c2bc32e6d5596a47ae225ca02a856b63aca4662d Mon Sep 17 00:00:00 2001 From: BBBmau Date: Mon, 11 Mar 2024 16:32:13 -0700 Subject: [PATCH 15/18] fix format --- .github/actions/build-downstream/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/build-downstream/action.yml b/.github/actions/build-downstream/action.yml index ff4fae5c5f1b..78b51cf9aca5 100644 --- a/.github/actions/build-downstream/action.yml +++ b/.github/actions/build-downstream/action.yml @@ -65,7 +65,7 @@ runs: function clone_repo() { export OUTPUT_PATH=$GOPATH/src/github.com/$UPSTREAM_OWNER/$GH_REPO - echo "$OUTPUT_PATH" >> $GITHUB_ENV + echo "OUTPUT_PATH=$OUTPUT_PATH" >> $GITHUB_ENV 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 From 5d11529d061edae6bd35e9b81c3985afbceca7f5 Mon Sep 17 00:00:00 2001 From: BBBmau Date: Mon, 11 Mar 2024 16:42:28 -0700 Subject: [PATCH 16/18] use githubenv --- .github/workflows/teamcity-services-diff-check-weekly.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/teamcity-services-diff-check-weekly.yml b/.github/workflows/teamcity-services-diff-check-weekly.yml index 7da8b330ea3f..9efb6f5017ff 100644 --- a/.github/workflows/teamcity-services-diff-check-weekly.yml +++ b/.github/workflows/teamcity-services-diff-check-weekly.yml @@ -23,18 +23,18 @@ jobs: with: repo: 'terraform-provider-google' token: '$GITHUB_TOKEN' - - run: export GOOGLE_REPO_PATH=${{ env.OUTPUT_PATH}} + - run: echo "GOOGLE_REPO_PATH=${{ env.OUTPUT_PATH}}" >> $GITHUB_ENV - name: TeamCity Google Beta Provider Generate uses: ./.github/actions/build-downstream with: repo: 'terraform-provider-google-beta' token: '$GITHUB_TOKEN' - - run: export GOOGLE_BETA_REPO_PATH=${{ env.OUTPUT_PATH}} + - run: echo "GOOGLE_BETA_REPO_PATH=${{ env.OUTPUT_PATH}}" >> $GITHUB_ENV - name: Check that new services have been added to the TeamCity configuration code run: | # Create lists of service packages in providers - ls ${GOOGLE_REPO_PATH}/google/services > tools/teamcity-diff-check/services_ga.txt - ls ${GOOGLE_BETA_REPO_PATH}/google-beta/services > tools/teamcity-diff-check/services_beta.txt + ls ${{env.GOOGLE_REPO_PATH}}/google/services > tools/teamcity-diff-check/services_ga.txt + ls ${{env.GOOGLE_BETA_REPO_PATH}}/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 From 5ef20ff950f38b3881959b6bd8d2e65ec2a5e4f9 Mon Sep 17 00:00:00 2001 From: BBBmau Date: Mon, 11 Mar 2024 16:53:20 -0700 Subject: [PATCH 17/18] update diff-check.yml with correct repo path --- .github/workflows/teamcity-services-diff-check.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/teamcity-services-diff-check.yml b/.github/workflows/teamcity-services-diff-check.yml index 3f8ff83b579b..92b8dbc59b91 100644 --- a/.github/workflows/teamcity-services-diff-check.yml +++ b/.github/workflows/teamcity-services-diff-check.yml @@ -33,14 +33,14 @@ jobs: with: repo: 'terraform-provider-google' token: '$GITHUB_TOKEN' - - run: export GOOGLE_REPO_PATH=$OUTPUT_PATH + - run: echo "GOOGLE_REPO_PATH=${{ env.OUTPUT_PATH}}" >> $GITHUB_ENV - 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' - - run: export GOOGLE_BETA_REPO_PATH=$OUTPUT_PATH + - run: echo "GOOGLE_BETA_REPO_PATH=${{ env.OUTPUT_PATH}}" >> $GITHUB_ENV - name: Checkout Repository if: steps.generate.outcome == 'success' uses: actions/checkout@v4 @@ -48,8 +48,8 @@ jobs: if: steps.generate.outcome == 'success' run: | # Create lists of service packages in providers - ls ${GOOGLE_REPO_PATH}/google/services > tools/teamcity-diff-check/services_ga.txt - ls ${GOOGLE_BETA_REPO_PATH}/google-beta/services > tools/teamcity-diff-check/services_beta.txt + ls ${{env.GOOGLE_REPO_PATH}}/google/services > tools/teamcity-diff-check/services_ga.txt + ls ${{env.GOOGLE_BETA_REPO_PATH}}/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 From 6efcfc6ffaa1c7615f27c55aca5edcc815b9a35b Mon Sep 17 00:00:00 2001 From: BBBmau Date: Tue, 12 Mar 2024 19:39:24 -0700 Subject: [PATCH 18/18] improve descriptions --- .github/actions/build-downstream/action.yml | 2 +- .../workflows/teamcity-services-diff-check-weekly.yml | 9 +++++++-- .github/workflows/teamcity-services-diff-check.yml | 9 +++++++-- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/.github/actions/build-downstream/action.yml b/.github/actions/build-downstream/action.yml index 78b51cf9aca5..012248b10862 100644 --- a/.github/actions/build-downstream/action.yml +++ b/.github/actions/build-downstream/action.yml @@ -1,5 +1,5 @@ name: build -description: Generates Google/Google-Beta Provider +description: Generates given downstream Magic Modules Repository from `repo` input 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 9efb6f5017ff..355501e14d51 100644 --- a/.github/workflows/teamcity-services-diff-check-weekly.yml +++ b/.github/workflows/teamcity-services-diff-check-weekly.yml @@ -23,13 +23,18 @@ jobs: with: repo: 'terraform-provider-google' token: '$GITHUB_TOKEN' - - run: echo "GOOGLE_REPO_PATH=${{ env.OUTPUT_PATH}}" >> $GITHUB_ENV + # The path where GA/Beta providers are generated is grabbed from the OUTPUT_PATH that's set in build_downstream.yaml + # export OUTPUT_PATH=$GOPATH/src/github.com/$UPSTREAM_OWNER/$GH_REPO + # OUTPUT_PATH changes after each generate (GA/beta) + - name: Set GOOGLE_REPO_PATH to path where GA provider was generated + run: echo "GOOGLE_REPO_PATH=${{ env.OUTPUT_PATH}}" >> $GITHUB_ENV - name: TeamCity Google Beta Provider Generate uses: ./.github/actions/build-downstream with: repo: 'terraform-provider-google-beta' token: '$GITHUB_TOKEN' - - run: echo "GOOGLE_BETA_REPO_PATH=${{ env.OUTPUT_PATH}}" >> $GITHUB_ENV + - name: Set GOOGLE_BETA_REPO_PATH to path where beta provider was generated + run: echo "GOOGLE_BETA_REPO_PATH=${{ env.OUTPUT_PATH}}" >> $GITHUB_ENV - 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 92b8dbc59b91..9ffee2130bdb 100644 --- a/.github/workflows/teamcity-services-diff-check.yml +++ b/.github/workflows/teamcity-services-diff-check.yml @@ -33,14 +33,19 @@ jobs: with: repo: 'terraform-provider-google' token: '$GITHUB_TOKEN' - - run: echo "GOOGLE_REPO_PATH=${{ env.OUTPUT_PATH}}" >> $GITHUB_ENV + # The path where GA/Beta providers are generated is grabbed from the OUTPUT_PATH that's set in build_downstream.yaml + # export OUTPUT_PATH=$GOPATH/src/github.com/$UPSTREAM_OWNER/$GH_REPO + # OUTPUT_PATH changes after each generate (GA/beta) + - name: Set GOOGLE_REPO_PATH to path where GA provider was generated + run: echo "GOOGLE_REPO_PATH=${{ env.OUTPUT_PATH}}" >> $GITHUB_ENV - 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' - - run: echo "GOOGLE_BETA_REPO_PATH=${{ env.OUTPUT_PATH}}" >> $GITHUB_ENV + - name: Set GOOGLE_BETA_REPO_PATH to path where beta provider was generated + run: echo "GOOGLE_BETA_REPO_PATH=${{ env.OUTPUT_PATH}}" >> $GITHUB_ENV - name: Checkout Repository if: steps.generate.outcome == 'success' uses: actions/checkout@v4