Skip to content

Commit

Permalink
Remove unneeded cache step in TeamCity-related GHAs, lint GHA files (#…
Browse files Browse the repository at this point in the history
…10075)

* Remove unneeded GHA steps - do we need to cache here?

* Whitespace

* Test change with fake new service

* Resolve build error in fake service

* Re-order GHA steps and add name

* Add name to checkout step

* Add comments, remove extra whitespace

* Remove fake new service
  • Loading branch information
SarahFrench committed Feb 28, 2024
1 parent 0615861 commit 78bdab3
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 49 deletions.
38 changes: 15 additions & 23 deletions .github/workflows/teamcity-services-diff-check-weekly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,30 @@ jobs:
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:
- uses: actions/checkout@v3

- name: Checkout Repository
uses: actions/checkout@v3

- name: Setup Go
uses: actions/setup-go@v3
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
Expand All @@ -39,33 +45,19 @@ jobs:
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: Setup Go
uses: actions/setup-go@v3
with:
go-version: '^1.20'

- name: Cache Go modules and build cache
uses: actions/cache@v3
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: ${{ runner.os }}-test-terraform-provider-google-${{hashFiles('go.sum','google-*/transport/**','google-*/tpgresource/**','google-*/acctest/**','google-*/envvar/**','google-*/sweeper/**','google-*/verify/**') }}
restore-keys: |
${{ runner.os }}-test-terraform-provider-google-${{ hashFiles('go.sum') }}
${{ runner.os }}-test-terraform-provider-google-
- name: Diff Check
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
45 changes: 19 additions & 26 deletions .github/workflows/teamcity-services-diff-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ jobs:
outputs:
services: ${{steps.services.outputs.services}}
steps:
- uses: actions/checkout@v3
- name: Checkout Repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- id: services
name: "Check for New Services"
- name: "Check for New Services"
id: services
run: |
newServices=$(($(git diff --name-only --diff-filter=A origin/main HEAD | grep -P "mmv1/products/.*/product.yaml" | wc -l)))
echo "services=$newServices" >> "${GITHUB_OUTPUT}"
Expand All @@ -32,26 +33,32 @@ jobs:
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'

teamcity-services-diff-check:
needs: [terraform-provider-google, terraform-provider-google-beta]
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3

- name: Checkout Repository
uses: actions/checkout@v3

- name: Setup Go
uses: actions/setup-go@v3
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
Expand All @@ -62,33 +69,19 @@ jobs:
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: Setup Go
uses: actions/setup-go@v3
with:
go-version: '^1.20'

- name: Cache Go modules and build cache
uses: actions/cache@v3
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: ${{ runner.os }}-test-terraform-provider-google-${{hashFiles('go.sum','google-*/transport/**','google-*/tpgresource/**','google-*/acctest/**','google-*/envvar/**','google-*/sweeper/**','google-*/verify/**') }}
restore-keys: |
${{ runner.os }}-test-terraform-provider-google-${{ hashFiles('go.sum') }}
${{ runner.os }}-test-terraform-provider-google-
- name: Diff Check
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

0 comments on commit 78bdab3

Please sign in to comment.