Skip to content

Commit

Permalink
Merge branch 'GoogleCloudPlatform:main' into create-quota-preference-…
Browse files Browse the repository at this point in the history
…resource
  • Loading branch information
lola98 authored Mar 8, 2024
2 parents 6f3e3c7 + 5989a16 commit 13d04ae
Show file tree
Hide file tree
Showing 132 changed files with 3,352 additions and 298 deletions.
1 change: 1 addition & 0 deletions .ci/infra/terraform/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ module "project-services" {
"apikeys.googleapis.com",
"appengine.googleapis.com",
"appengineflex.googleapis.com",
"apphub.googleapis.com",
"artifactregistry.googleapis.com",
"assuredworkloads.googleapis.com",
"autoscaling.googleapis.com",
Expand Down
17 changes: 15 additions & 2 deletions .ci/magician/cmd/check_cassettes.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (

var ccEnvironmentVariables = [...]string{
"COMMIT_SHA",
"GITHUB_TOKEN_DOWNSTREAMS",
"GOCACHE",
"GOPATH",
"GOOGLE_BILLING_ACCOUNT",
Expand Down Expand Up @@ -56,13 +55,19 @@ var checkCassettesCmd = &cobra.Command{
env[ev] = val
}

githubToken, ok := lookupGithubTokenOrFallback("GITHUB_TOKEN_DOWNSTREAMS")
if !ok {
fmt.Println("Did not provide GITHUB_TOKEN_DOWNSTREAMS or GITHUB_TOKEN environment variables")
os.Exit(1)
}

rnr, err := exec.NewRunner()
if err != nil {
fmt.Println("Error creating Runner: ", err)
os.Exit(1)
}

ctlr := source.NewController(env["GOPATH"], "modular-magician", env["GITHUB_TOKEN_DOWNSTREAMS"], rnr)
ctlr := source.NewController(env["GOPATH"], "modular-magician", githubToken, rnr)

vt, err := vcr.NewTester(env, rnr)
if err != nil {
Expand All @@ -73,6 +78,14 @@ var checkCassettesCmd = &cobra.Command{
},
}

func lookupGithubTokenOrFallback(tokenName string) (string, bool) {
val, ok := os.LookupEnv(tokenName)
if !ok {
return os.LookupEnv("GITHUB_TOKEN")
}
return val, ok
}

func listCCEnvironmentVariables() string {
var result string
for i, ev := range ccEnvironmentVariables {
Expand Down
4 changes: 2 additions & 2 deletions .ci/magician/cmd/community_checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ var communityApprovalCmd = &cobra.Command{
baseBranch := args[5]
fmt.Println("Base Branch: ", baseBranch)

githubToken, ok := os.LookupEnv("GITHUB_TOKEN_MAGIC_MODULES")
githubToken, ok := lookupGithubTokenOrFallback("GITHUB_TOKEN_MAGIC_MODULES")
if !ok {
fmt.Println("Did not provide GITHUB_TOKEN_MAGIC_MODULES environment variable")
fmt.Println("Did not provide GITHUB_TOKEN_MAGIC_MODULES or GITHUB_TOKEN environment variables")
os.Exit(1)
}
gh := github.NewClient(githubToken)
Expand Down
10 changes: 8 additions & 2 deletions .ci/magician/cmd/generate_comment.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ var gcEnvironmentVariables = [...]string{
"BUILD_ID",
"BUILD_STEP",
"COMMIT_SHA",
"GITHUB_TOKEN_DOWNSTREAMS",
"GITHUB_TOKEN_MAGIC_MODULES",
"GOPATH",
"HOME",
"PATH",
Expand Down Expand Up @@ -71,6 +69,14 @@ var generateCommentCmd = &cobra.Command{
env[ev] = val
}

for _, tokenName := range []string{"GITHUB_TOKEN_DOWNSTREAMS", "GITHUB_TOKEN_MAGIC_MODULES"} {
val, ok := lookupGithubTokenOrFallback(tokenName)
if !ok {
fmt.Printf("Did not provide %s or GITHUB_TOKEN environment variable\n", tokenName)
os.Exit(1)
}
env[tokenName] = val
}
gh := github.NewClient(env["GITHUB_TOKEN_MAGIC_MODULES"])
rnr, err := exec.NewRunner()
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions .ci/magician/cmd/generate_downstream.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ var gdEnvironmentVariables = [...]string{
var gdTokenEnvironmentVariables = [...]string{
"GITHUB_TOKEN_CLASSIC",
"GITHUB_TOKEN_DOWNSTREAMS",
"GITHUB_TOKEN",
}

var generateDownstreamCmd = &cobra.Command{
Expand Down
4 changes: 2 additions & 2 deletions .ci/magician/cmd/membership_checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ var membershipCheckerCmd = &cobra.Command{
baseBranch := args[5]
fmt.Println("Base Branch: ", baseBranch)

githubToken, ok := os.LookupEnv("GITHUB_TOKEN_MAGIC_MODULES")
githubToken, ok := lookupGithubTokenOrFallback("GITHUB_TOKEN_MAGIC_MODULES")
if !ok {
fmt.Println("Did not provide GITHUB_TOKEN_MAGIC_MODULES environment variable")
fmt.Println("Did not provide GITHUB_TOKEN_MAGIC_MODULES or GITHUB_TOKEN environment variables")
os.Exit(1)
}
gh := github.NewClient(githubToken)
Expand Down
4 changes: 2 additions & 2 deletions .ci/magician/cmd/request_service_reviewers.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ var requestServiceReviewersCmd = &cobra.Command{
prNumber := args[0]
fmt.Println("PR Number: ", prNumber)

githubToken, ok := os.LookupEnv("GITHUB_TOKEN_MAGIC_MODULES")
githubToken, ok := lookupGithubTokenOrFallback("GITHUB_TOKEN_MAGIC_MODULES")
if !ok {
fmt.Println("Did not provide GITHUB_TOKEN_MAGIC_MODULES environment variable")
fmt.Println("Did not provide GITHUB_TOKEN_MAGIC_MODULES or GITHUB_TOKEN environment variable")
os.Exit(1)
}
gh := github.NewClient(githubToken)
Expand Down
11 changes: 9 additions & 2 deletions .ci/magician/cmd/test_terraform_vcr.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ import (
)

var ttvEnvironmentVariables = [...]string{
"GITHUB_TOKEN_DOWNSTREAMS",
"GITHUB_TOKEN_MAGIC_MODULES",
"GOCACHE",
"GOPATH",
"GOOGLE_BILLING_ACCOUNT",
Expand Down Expand Up @@ -55,6 +53,15 @@ var testTerraformVCRCmd = &cobra.Command{
env[ev] = val
}

for _, tokenName := range []string{"GITHUB_TOKEN_DOWNSTREAMS", "GITHUB_TOKEN_MAGIC_MODULES"} {
val, ok := lookupGithubTokenOrFallback(tokenName)
if !ok {
fmt.Printf("Did not provide %s or GITHUB_TOKEN environment variable\n", tokenName)
os.Exit(1)
}
env[tokenName] = val
}

baseBranch := os.Getenv("BASE_BRANCH")
if baseBranch == "" {
baseBranch = "main"
Expand Down
4 changes: 2 additions & 2 deletions .ci/magician/cmd/test_tgc.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ var testTGCCmd = &cobra.Command{
commit := os.Getenv("COMMIT_SHA")
pr := os.Getenv("PR_NUMBER")

githubToken, ok := os.LookupEnv("GITHUB_TOKEN_MAGIC_MODULES")
githubToken, ok := lookupGithubTokenOrFallback("GITHUB_TOKEN_MAGIC_MODULES")
if !ok {
fmt.Println("Did not provide GITHUB_TOKEN_MAGIC_MODULES environment variable")
fmt.Println("Did not provide GITHUB_TOKEN_MAGIC_MODULES or GITHUB_TOKEN environment variables")
os.Exit(1)
}
gh := github.NewClient(githubToken)
Expand Down
4 changes: 2 additions & 2 deletions .ci/magician/cmd/test_tpg.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ var testTPGCmd = &cobra.Command{
commit := os.Getenv("COMMIT_SHA")
pr := os.Getenv("PR_NUMBER")

githubToken, ok := os.LookupEnv("GITHUB_TOKEN_MAGIC_MODULES")
githubToken, ok := lookupGithubTokenOrFallback("GITHUB_TOKEN_MAGIC_MODULES")
if !ok {
fmt.Println("Did not provide GITHUB_TOKEN_MAGIC_MODULES environment variable")
fmt.Println("Did not provide GITHUB_TOKEN_MAGIC_MODULES or GITHUB_TOKEN environment variables")
os.Exit(1)
}
gh := github.NewClient(githubToken)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ post_body=$( jq -n \
--arg state "pending" \
'{context: $context, target_url: $target_url, state: $state}')

# Fall back to old github token if new token is unavailable.
if [[ -z $GITHUB_TOKEN_MAGIC_MODULES ]]; then
GITHUB_TOKEN_MAGIC_MODULES=$GITHUB_TOKEN
fi

curl \
-X POST \
-u "$github_username:$GITHUB_TOKEN_MAGIC_MODULES" \
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/build-downstream.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout Repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Ruby
uses: ruby/setup-ruby@ec02537da5712d66d4d50a0f33b7eb52773b5ed1
uses: ruby/setup-ruby@036ef458ddccddb148a2b9fb67e95a22fdbf728b # v1.160.0
with:
ruby-version: '3.1'

- name: Cache Bundler gems
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: mmv1/vendor/bundle
key: ${{ runner.os }}-gems-${{ hashFiles('mmv1/**/Gemfile.lock') }}
Expand All @@ -45,13 +45,13 @@ jobs:
working-directory: mmv1

- name: Set up Go
uses: actions/setup-go@v3
uses: actions/setup-go@v4
with:
go-version: '^1.20'

# Cache Go modules
- name: Cache Go modules
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
Expand Down Expand Up @@ -108,7 +108,7 @@ jobs:
(current_dir=$(pwd) && cd $OUTPUT_PATH && zip -r "$current_dir/output.zip" .)
- name: Upload built artifacts
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0
with:
name: artifact-${{ inputs.repo }}
path: output.zip
2 changes: 1 addition & 1 deletion .github/workflows/changelog-checker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-22.04
steps:
- name: Checkout Repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
path: repo
- name: Check Changelog
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/magic-modules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-22.04
steps:
- name: Checkout Repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
path: repo
fetch-depth: 0
Expand All @@ -36,7 +36,7 @@ jobs:
runs-on: ubuntu-22.04
steps:
- name: Checkout Repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
path: repo
fetch-depth: 2
Expand All @@ -49,7 +49,7 @@ jobs:
git fetch origin ${{ github.base_ref }} # Fetch the base branch
git merge --no-ff origin/${{ github.base_ref }} # Merge with the base branch
- name: Set up Ruby
uses: ruby/setup-ruby@ec02537da5712d66d4d50a0f33b7eb52773b5ed1
uses: ruby/setup-ruby@036ef458ddccddb148a2b9fb67e95a22fdbf728b # v1.160.0
with:
ruby-version: '3.1'
- name: Install dependencies
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/membership-checker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
build-and-unit-tests:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
name: repository-documentation
name: repository-documentation-deploy

permissions: read-all

on:
push:
branches:
- main # Set a branch to deploy
pull_request:
paths:
- 'docs/**'
- main

jobs:
deploy:
runs-on: ubuntu-22.04
permissions:
contents: write
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: true # Fetch Hugo themes (true OR recursive)
fetch-depth: 0 # Fetch all history for .GitInfo and .Lastmod
Expand All @@ -29,7 +30,6 @@ jobs:

- name: Deploy
uses: peaceiris/actions-gh-pages@de7ea6f8efb354206b205ef54722213d99067935 # v3.9.0
if: github.ref == 'refs/heads/main'
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs/public
27 changes: 27 additions & 0 deletions .github/workflows/repository-documentation-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: repository-documentation-test

permissions: read-all

on:
pull_request:
paths:
- 'docs/**'

jobs:
deploy:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
submodules: true # Fetch Hugo themes (true OR recursive)
fetch-depth: 0 # Fetch all history for .GitInfo and .Lastmod

- name: Setup Hugo
uses: peaceiris/actions-hugo@16361eb4acea8698b220b76c0d4e84e1fd22c61d # v2.6.0
with:
hugo-version: '0.115.0'
extended: true

- name: Build
working-directory: ./docs
run: hugo --minify
4 changes: 2 additions & 2 deletions .github/workflows/teamcity-services-diff-check-weekly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ jobs:
runs-on: ubuntu-22.04
steps:
- name: Checkout Repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v3
uses: actions/setup-go@v4
with:
go-version: '^1.20'

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/teamcity-services-diff-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
services: ${{steps.services.outputs.services}}
steps:
- name: Checkout Repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: "Check for New Services"
Expand Down Expand Up @@ -45,10 +45,10 @@ jobs:
runs-on: ubuntu-22.04
steps:
- name: Checkout Repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v3
uses: actions/setup-go@v4
with:
go-version: '^1.20'

Expand Down
Loading

0 comments on commit 13d04ae

Please sign in to comment.