diff --git a/.github/workflows/apengine-metadata-flexible.yaml b/.github/workflows/apengine-metadata-flexible.yaml new file mode 100644 index 0000000000..740021cd0e --- /dev/null +++ b/.github/workflows/apengine-metadata-flexible.yaml @@ -0,0 +1,67 @@ +name: apengine-metadata-flexible +on: + push: + branches: + - main + paths: + - 'apengine/metadata/flexible/**' + pull_request: + paths: + - 'apengine/metadata/flexible/**' + pull_request_target: + types: [labeled] + schedule: + - cron: '0 0 * * 0' +jobs: + test: + if: ${{ github.event.action != 'labeled' || github.event.label.name == 'actions:force-run' }} + runs-on: ubuntu-latest + timeout-minutes: 60 + permissions: + contents: 'write' + pull-requests: 'write' + id-token: 'write' + steps: + - uses: actions/checkout@v3.1.0 + with: + ref: ${{github.event.pull_request.head.ref}} + repository: ${{github.event.pull_request.head.repo.full_name}} + - uses: 'google-github-actions/auth@v0.8.3' + with: + workload_identity_provider: 'projects/1046198160504/locations/global/workloadIdentityPools/github-actions-pool/providers/github-actions-provider' + service_account: 'kokoro-system-test@long-door-651.iam.gserviceaccount.com' + create_credentials_file: 'true' + access_token_lifetime: 600s + - uses: actions/setup-node@v3.5.1 + with: + node-version: 16 + - run: npm install + working-directory: apengine/metadata/flexible + - run: npm test + working-directory: apengine/metadata/flexible + env: + MOCHA_REPORTER_SUITENAME: apengine_metadata_flexible + MOCHA_REPORTER_OUTPUT: apengine_metadata_flexible_sponge_log.xml + MOCHA_REPORTER: xunit + - if: ${{ github.event.action == 'labeled' && github.event.label.name == 'actions:force-run' }} + uses: actions/github-script@v6 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + try { + await github.rest.issues.removeLabel({ + name: 'actions:force-run', + owner: 'GoogleCloudPlatform', + repo: 'nodejs-docs-samples', + issue_number: context.payload.pull_request.number + }); + } catch (e) { + if (!e.message.includes('Label does not exist')) { + throw e; + } + } + - if: ${{ github.event_name == 'schedule'}} + run: | + curl https://github.com/googleapis/repo-automation-bots/releases/download/flakybot-1.1.0/flakybot -o flakybot -s -L + chmod +x ./flakybot + ./flakybot --repo GoogleCloudPlatform/nodejs-docs-samples --commit_hash ${{github.sha}} --build_url https://github.com/${{github.repository}}/actions/runs/${{github.run_id}} diff --git a/.github/workflows/appengine-analytics.yaml b/.github/workflows/appengine-analytics.yaml index 47c0007d95..e14f0874fb 100644 --- a/.github/workflows/appengine-analytics.yaml +++ b/.github/workflows/appengine-analytics.yaml @@ -22,7 +22,7 @@ jobs: pull-requests: 'write' id-token: 'write' steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v3.1.0 with: ref: ${{github.event.pull_request.head.ref}} repository: ${{github.event.pull_request.head.repo.full_name}} @@ -32,9 +32,9 @@ jobs: service_account: 'kokoro-system-test@long-door-651.iam.gserviceaccount.com' create_credentials_file: 'true' access_token_lifetime: 600s - - uses: actions/setup-node@v3 + - uses: actions/setup-node@v3.5.1 with: - node-version: 14 + node-version: 16 - run: npm install working-directory: appengine/analytics - run: npm test @@ -60,7 +60,7 @@ jobs: throw e; } } - - if: ${{ github.event_name == 'schedule' && always() }} + - if: ${{ github.event_name == 'schedule'}} run: | curl https://github.com/googleapis/repo-automation-bots/releases/download/flakybot-1.1.0/flakybot -o flakybot -s -L chmod +x ./flakybot diff --git a/.github/workflows/appengine-building-an-app-build.yaml b/.github/workflows/appengine-building-an-app-build.yaml index 6b47f2f593..0ed6c1dbc8 100644 --- a/.github/workflows/appengine-building-an-app-build.yaml +++ b/.github/workflows/appengine-building-an-app-build.yaml @@ -22,7 +22,7 @@ jobs: pull-requests: 'write' id-token: 'write' steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v3.1.0 with: ref: ${{github.event.pull_request.head.ref}} repository: ${{github.event.pull_request.head.repo.full_name}} @@ -32,9 +32,9 @@ jobs: service_account: 'kokoro-system-test@long-door-651.iam.gserviceaccount.com' create_credentials_file: 'true' access_token_lifetime: 600s - - uses: actions/setup-node@v3 + - uses: actions/setup-node@v3.5.1 with: - node-version: 14 + node-version: 16 - run: npm install working-directory: appengine/building-an-app/build - run: npm test @@ -60,7 +60,7 @@ jobs: throw e; } } - - if: ${{ github.event_name == 'schedule' && always() }} + - if: ${{ github.event_name == 'schedule'}} run: | curl https://github.com/googleapis/repo-automation-bots/releases/download/flakybot-1.1.0/flakybot -o flakybot -s -L chmod +x ./flakybot diff --git a/.github/workflows/appengine-building-an-app-update.yaml b/.github/workflows/appengine-building-an-app-update.yaml index 85f2962a0f..f1b8ae8ed5 100644 --- a/.github/workflows/appengine-building-an-app-update.yaml +++ b/.github/workflows/appengine-building-an-app-update.yaml @@ -22,19 +22,23 @@ jobs: pull-requests: 'write' id-token: 'write' steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v3.1.0 with: ref: ${{github.event.pull_request.head.ref}} repository: ${{github.event.pull_request.head.repo.full_name}} +<<<<<<< HEAD + - uses: 'google-github-actions/auth@v0.8.3' +======= - uses: google-github-actions/auth@v1.0.0 +>>>>>>> main with: workload_identity_provider: 'projects/1046198160504/locations/global/workloadIdentityPools/github-actions-pool/providers/github-actions-provider' service_account: 'kokoro-system-test@long-door-651.iam.gserviceaccount.com' create_credentials_file: 'true' access_token_lifetime: 600s - - uses: actions/setup-node@v3 + - uses: actions/setup-node@v3.5.1 with: - node-version: 14 + node-version: 16 - run: npm install working-directory: appengine/building-an-app/update - run: npm test @@ -60,7 +64,7 @@ jobs: throw e; } } - - if: ${{ github.event_name == 'schedule' && always() }} + - if: ${{ github.event_name == 'schedule'}} run: | curl https://github.com/googleapis/repo-automation-bots/releases/download/flakybot-1.1.0/flakybot -o flakybot -s -L chmod +x ./flakybot diff --git a/.github/workflows/appengine-datastore.yaml b/.github/workflows/appengine-datastore.yaml index ef93fdea66..b96058bd8b 100644 --- a/.github/workflows/appengine-datastore.yaml +++ b/.github/workflows/appengine-datastore.yaml @@ -22,20 +22,23 @@ jobs: pull-requests: 'write' id-token: 'write' steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v3.1.0 with: ref: ${{github.event.pull_request.head.ref}} repository: ${{github.event.pull_request.head.repo.full_name}} +<<<<<<< HEAD + - uses: 'google-github-actions/auth@v0.8.3' +======= - uses: google-github-actions/auth@v1.0.0 +>>>>>>> main with: workload_identity_provider: 'projects/1046198160504/locations/global/workloadIdentityPools/github-actions-pool/providers/github-actions-provider' service_account: 'kokoro-system-test@long-door-651.iam.gserviceaccount.com' create_credentials_file: 'true' - credentials_json: '${{ secrets.GOOGLE_CREDENTIALS }}' access_token_lifetime: 600s - - uses: actions/setup-node@v3 + - uses: actions/setup-node@v3.5.1 with: - node-version: 14 + node-version: 16 - run: npm install working-directory: appengine/datastore - run: npm test @@ -61,7 +64,7 @@ jobs: throw e; } } - - if: ${{ github.event_name == 'schedule' && always() }} + - if: ${{ github.event_name == 'schedule'}} run: | curl https://github.com/googleapis/repo-automation-bots/releases/download/flakybot-1.1.0/flakybot -o flakybot -s -L chmod +x ./flakybot diff --git a/.github/workflows/appengine-endpoints.yaml b/.github/workflows/appengine-endpoints.yaml index 8cef3206f4..61e51ff447 100644 --- a/.github/workflows/appengine-endpoints.yaml +++ b/.github/workflows/appengine-endpoints.yaml @@ -22,19 +22,23 @@ jobs: pull-requests: 'write' id-token: 'write' steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v3.1.0 with: ref: ${{github.event.pull_request.head.ref}} repository: ${{github.event.pull_request.head.repo.full_name}} +<<<<<<< HEAD + - uses: 'google-github-actions/auth@v0.8.3' +======= - uses: google-github-actions/auth@v1.0.0 +>>>>>>> main with: workload_identity_provider: 'projects/1046198160504/locations/global/workloadIdentityPools/github-actions-pool/providers/github-actions-provider' service_account: 'kokoro-system-test@long-door-651.iam.gserviceaccount.com' create_credentials_file: 'true' access_token_lifetime: 600s - - uses: actions/setup-node@v3 + - uses: actions/setup-node@v3.5.1 with: - node-version: 14 + node-version: 16 - run: npm install working-directory: appengine/endpoints - run: npm test @@ -60,7 +64,7 @@ jobs: throw e; } } - - if: ${{ github.event_name == 'schedule' && always() }} + - if: ${{ github.event_name == 'schedule'}} run: | curl https://github.com/googleapis/repo-automation-bots/releases/download/flakybot-1.1.0/flakybot -o flakybot -s -L chmod +x ./flakybot diff --git a/.github/workflows/appengine-hello-world-flexible.yaml b/.github/workflows/appengine-hello-world-flexible.yaml index 817e183cf7..c8d55ab279 100644 --- a/.github/workflows/appengine-hello-world-flexible.yaml +++ b/.github/workflows/appengine-hello-world-flexible.yaml @@ -22,19 +22,23 @@ jobs: pull-requests: 'write' id-token: 'write' steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v3.1.0 with: ref: ${{github.event.pull_request.head.ref}} repository: ${{github.event.pull_request.head.repo.full_name}} +<<<<<<< HEAD + - uses: 'google-github-actions/auth@v0.8.3' +======= - uses: google-github-actions/auth@v1.0.0 +>>>>>>> main with: workload_identity_provider: 'projects/1046198160504/locations/global/workloadIdentityPools/github-actions-pool/providers/github-actions-provider' service_account: 'kokoro-system-test@long-door-651.iam.gserviceaccount.com' create_credentials_file: 'true' access_token_lifetime: 600s - - uses: actions/setup-node@v3 + - uses: actions/setup-node@v3.5.1 with: - node-version: 14 + node-version: 16 - run: npm install working-directory: appengine/hello-world/flexible - run: npm test @@ -60,7 +64,7 @@ jobs: throw e; } } - - if: ${{ github.event_name == 'schedule' && always() }} + - if: ${{ github.event_name == 'schedule'}} run: | curl https://github.com/googleapis/repo-automation-bots/releases/download/flakybot-1.1.0/flakybot -o flakybot -s -L chmod +x ./flakybot diff --git a/.github/workflows/appengine-hello-world-standard.yaml b/.github/workflows/appengine-hello-world-standard.yaml index cbe8fd705d..41bb3b12f4 100644 --- a/.github/workflows/appengine-hello-world-standard.yaml +++ b/.github/workflows/appengine-hello-world-standard.yaml @@ -22,19 +22,23 @@ jobs: pull-requests: 'write' id-token: 'write' steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v3.1.0 with: ref: ${{github.event.pull_request.head.ref}} repository: ${{github.event.pull_request.head.repo.full_name}} +<<<<<<< HEAD + - uses: 'google-github-actions/auth@v0.8.3' +======= - uses: google-github-actions/auth@v1.0.0 +>>>>>>> main with: workload_identity_provider: 'projects/1046198160504/locations/global/workloadIdentityPools/github-actions-pool/providers/github-actions-provider' service_account: 'kokoro-system-test@long-door-651.iam.gserviceaccount.com' create_credentials_file: 'true' access_token_lifetime: 600s - - uses: actions/setup-node@v3 + - uses: actions/setup-node@v3.5.1 with: - node-version: 14 + node-version: 16 - run: npm install working-directory: appengine/hello-world/standard - run: npm test @@ -60,7 +64,7 @@ jobs: throw e; } } - - if: ${{ github.event_name == 'schedule' && always() }} + - if: ${{ github.event_name == 'schedule'}} run: | curl https://github.com/googleapis/repo-automation-bots/releases/download/flakybot-1.1.0/flakybot -o flakybot -s -L chmod +x ./flakybot diff --git a/.github/workflows/appengine-memcached.yaml b/.github/workflows/appengine-memcached.yaml index 78ba3fc4c2..5d8dd5204c 100644 --- a/.github/workflows/appengine-memcached.yaml +++ b/.github/workflows/appengine-memcached.yaml @@ -22,19 +22,23 @@ jobs: pull-requests: 'write' id-token: 'write' steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v3.1.0 with: ref: ${{github.event.pull_request.head.ref}} repository: ${{github.event.pull_request.head.repo.full_name}} +<<<<<<< HEAD + - uses: 'google-github-actions/auth@v0.8.3' +======= - uses: google-github-actions/auth@v1.0.0 +>>>>>>> main with: workload_identity_provider: 'projects/1046198160504/locations/global/workloadIdentityPools/github-actions-pool/providers/github-actions-provider' service_account: 'kokoro-system-test@long-door-651.iam.gserviceaccount.com' create_credentials_file: 'true' access_token_lifetime: 600s - - uses: actions/setup-node@v3 + - uses: actions/setup-node@v3.5.1 with: - node-version: 14 + node-version: 16 - run: npm install working-directory: appengine/memcached - run: npm test @@ -60,7 +64,7 @@ jobs: throw e; } } - - if: ${{ github.event_name == 'schedule' && always() }} + - if: ${{ github.event_name == 'schedule'}} run: | curl https://github.com/googleapis/repo-automation-bots/releases/download/flakybot-1.1.0/flakybot -o flakybot -s -L chmod +x ./flakybot diff --git a/.github/workflows/appengine-metadata-standard.yaml b/.github/workflows/appengine-metadata-standard.yaml index e9afcfc72b..d3f1f6c7fc 100644 --- a/.github/workflows/appengine-metadata-standard.yaml +++ b/.github/workflows/appengine-metadata-standard.yaml @@ -22,20 +22,23 @@ jobs: pull-requests: 'write' id-token: 'write' steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v3.1.0 with: ref: ${{github.event.pull_request.head.ref}} repository: ${{github.event.pull_request.head.repo.full_name}} +<<<<<<< HEAD + - uses: 'google-github-actions/auth@v0.8.3' +======= - uses: google-github-actions/auth@v1.0.0 +>>>>>>> main with: workload_identity_provider: 'projects/1046198160504/locations/global/workloadIdentityPools/github-actions-pool/providers/github-actions-provider' service_account: 'kokoro-system-test@long-door-651.iam.gserviceaccount.com' create_credentials_file: 'true' - token_format: 'access_token' access_token_lifetime: 600s - - uses: actions/setup-node@v3 + - uses: actions/setup-node@v3.5.1 with: - node-version: 14 + node-version: 16 - run: npm install working-directory: appengine/metadata/standard - run: npm test @@ -61,7 +64,7 @@ jobs: throw e; } } - - if: ${{ github.event_name == 'schedule' && always() }} + - if: ${{ github.event_name == 'schedule'}} run: | curl https://github.com/googleapis/repo-automation-bots/releases/download/flakybot-1.1.0/flakybot -o flakybot -s -L chmod +x ./flakybot diff --git a/.github/workflows/appengine-pubsub.yaml b/.github/workflows/appengine-pubsub.yaml index 92cb61ca0d..09bec59a48 100644 --- a/.github/workflows/appengine-pubsub.yaml +++ b/.github/workflows/appengine-pubsub.yaml @@ -22,23 +22,23 @@ jobs: pull-requests: 'write' id-token: 'write' steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v3.1.0 with: ref: ${{github.event.pull_request.head.ref}} repository: ${{github.event.pull_request.head.repo.full_name}} +<<<<<<< HEAD + - uses: 'google-github-actions/auth@v0.8.3' +======= - uses: google-github-actions/auth@v1.0.0 +>>>>>>> main with: workload_identity_provider: 'projects/1046198160504/locations/global/workloadIdentityPools/github-actions-pool/providers/github-actions-provider' service_account: 'kokoro-system-test@long-door-651.iam.gserviceaccount.com' create_credentials_file: 'true' - credentials_json: '${{ secrets.GOOGLE_CREDENTIALS }}' - id_token_audience: 'example.com' - token_format: 'id_token' - id_token_include_email: true access_token_lifetime: 600s - - uses: actions/setup-node@v3 + - uses: actions/setup-node@v3.5.1 with: - node-version: 14 + node-version: 16 - run: npm install working-directory: appengine/pubsub - run: npm test @@ -64,7 +64,7 @@ jobs: throw e; } } - - if: ${{ github.event_name == 'schedule' && always() }} + - if: ${{ github.event_name == 'schedule'}} run: | curl https://github.com/googleapis/repo-automation-bots/releases/download/flakybot-1.1.0/flakybot -o flakybot -s -L chmod +x ./flakybot diff --git a/.github/workflows/appengine-static-files.yaml b/.github/workflows/appengine-static-files.yaml index 63a16a07ee..ed136f5dd9 100644 --- a/.github/workflows/appengine-static-files.yaml +++ b/.github/workflows/appengine-static-files.yaml @@ -22,19 +22,23 @@ jobs: pull-requests: 'write' id-token: 'write' steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v3.1.0 with: ref: ${{github.event.pull_request.head.ref}} repository: ${{github.event.pull_request.head.repo.full_name}} +<<<<<<< HEAD + - uses: 'google-github-actions/auth@v0.8.3' +======= - uses: google-github-actions/auth@v1.0.0 +>>>>>>> main with: workload_identity_provider: 'projects/1046198160504/locations/global/workloadIdentityPools/github-actions-pool/providers/github-actions-provider' service_account: 'kokoro-system-test@long-door-651.iam.gserviceaccount.com' create_credentials_file: 'true' access_token_lifetime: 600s - - uses: actions/setup-node@v3 + - uses: actions/setup-node@v3.5.1 with: - node-version: 14 + node-version: 16 - run: npm install working-directory: appengine/static-files - run: npm test @@ -60,7 +64,7 @@ jobs: throw e; } } - - if: ${{ github.event_name == 'schedule' && always() }} + - if: ${{ github.event_name == 'schedule'}} run: | curl https://github.com/googleapis/repo-automation-bots/releases/download/flakybot-1.1.0/flakybot -o flakybot -s -L chmod +x ./flakybot diff --git a/.github/workflows/appengine-storage-flexible.yaml b/.github/workflows/appengine-storage-flexible.yaml index c3f7f6389f..d180e29578 100644 --- a/.github/workflows/appengine-storage-flexible.yaml +++ b/.github/workflows/appengine-storage-flexible.yaml @@ -22,19 +22,23 @@ jobs: pull-requests: 'write' id-token: 'write' steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v3.1.0 with: ref: ${{github.event.pull_request.head.ref}} repository: ${{github.event.pull_request.head.repo.full_name}} +<<<<<<< HEAD + - uses: 'google-github-actions/auth@v0.8.3' +======= - uses: google-github-actions/auth@v1.0.0 +>>>>>>> main with: workload_identity_provider: 'projects/1046198160504/locations/global/workloadIdentityPools/github-actions-pool/providers/github-actions-provider' service_account: 'kokoro-system-test@long-door-651.iam.gserviceaccount.com' - token_format: 'access_token' + create_credentials_file: 'true' access_token_lifetime: 600s - - uses: actions/setup-node@v3 + - uses: actions/setup-node@v3.5.1 with: - node-version: 14 + node-version: 16 - run: npm install working-directory: appengine/storage/flexible - run: npm test @@ -60,7 +64,7 @@ jobs: throw e; } } - - if: ${{ github.event_name == 'schedule' && always() }} + - if: ${{ github.event_name == 'schedule'}} run: | curl https://github.com/googleapis/repo-automation-bots/releases/download/flakybot-1.1.0/flakybot -o flakybot -s -L chmod +x ./flakybot diff --git a/.github/workflows/appengine-storage-standard.yaml b/.github/workflows/appengine-storage-standard.yaml index a0637f729b..503f450c63 100644 --- a/.github/workflows/appengine-storage-standard.yaml +++ b/.github/workflows/appengine-storage-standard.yaml @@ -22,18 +22,23 @@ jobs: pull-requests: 'write' id-token: 'write' steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v3.1.0 with: ref: ${{github.event.pull_request.head.ref}} repository: ${{github.event.pull_request.head.repo.full_name}} +<<<<<<< HEAD + - uses: 'google-github-actions/auth@v0.8.3' +======= - uses: google-github-actions/auth@v1.0.0 +>>>>>>> main with: workload_identity_provider: 'projects/1046198160504/locations/global/workloadIdentityPools/github-actions-pool/providers/github-actions-provider' service_account: 'kokoro-system-test@long-door-651.iam.gserviceaccount.com' + create_credentials_file: 'true' access_token_lifetime: 600s - - uses: actions/setup-node@v3 + - uses: actions/setup-node@v3.5.1 with: - node-version: 14 + node-version: 16 - run: npm install working-directory: appengine/storage/standard - run: npm test @@ -59,7 +64,7 @@ jobs: throw e; } } - - if: ${{ github.event_name == 'schedule' && always() }} + - if: ${{ github.event_name == 'schedule'}} run: | curl https://github.com/googleapis/repo-automation-bots/releases/download/flakybot-1.1.0/flakybot -o flakybot -s -L chmod +x ./flakybot diff --git a/.github/workflows/appengine-twilio.yaml b/.github/workflows/appengine-twilio.yaml index a0cd0634db..abfd7a2c0d 100644 --- a/.github/workflows/appengine-twilio.yaml +++ b/.github/workflows/appengine-twilio.yaml @@ -22,19 +22,23 @@ jobs: pull-requests: 'write' id-token: 'write' steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v3.1.0 with: ref: ${{github.event.pull_request.head.ref}} repository: ${{github.event.pull_request.head.repo.full_name}} +<<<<<<< HEAD + - uses: 'google-github-actions/auth@v0.8.3' +======= - uses: google-github-actions/auth@v1.0.0 +>>>>>>> main with: workload_identity_provider: 'projects/1046198160504/locations/global/workloadIdentityPools/github-actions-pool/providers/github-actions-provider' service_account: 'kokoro-system-test@long-door-651.iam.gserviceaccount.com' create_credentials_file: 'true' access_token_lifetime: 600s - - uses: actions/setup-node@v3 + - uses: actions/setup-node@v3.5.1 with: - node-version: 14 + node-version: 16 - run: npm install working-directory: appengine/twilio - run: npm test @@ -60,7 +64,7 @@ jobs: throw e; } } - - if: ${{ github.event_name == 'schedule' && always() }} + - if: ${{ github.event_name == 'schedule'}} run: | curl https://github.com/googleapis/repo-automation-bots/releases/download/flakybot-1.1.0/flakybot -o flakybot -s -L chmod +x ./flakybot diff --git a/.github/workflows/appengine-typescript.yaml b/.github/workflows/appengine-typescript.yaml index 3917f43184..a7b646ab6b 100644 --- a/.github/workflows/appengine-typescript.yaml +++ b/.github/workflows/appengine-typescript.yaml @@ -22,7 +22,7 @@ jobs: pull-requests: 'write' id-token: 'write' steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v3.1.0 with: ref: ${{github.event.pull_request.head.ref}} repository: ${{github.event.pull_request.head.repo.full_name}} @@ -32,9 +32,9 @@ jobs: service_account: 'kokoro-system-test@long-door-651.iam.gserviceaccount.com' create_credentials_file: 'true' access_token_lifetime: 600s - - uses: actions/setup-node@v3 + - uses: actions/setup-node@v3.5.1 with: - node-version: 14 + node-version: 16 - run: npm install working-directory: appengine/typescript - run: npm test @@ -60,7 +60,7 @@ jobs: throw e; } } - - if: ${{ github.event_name == 'schedule' && always() }} + - if: ${{ github.event_name == 'schedule'}} run: | curl https://github.com/googleapis/repo-automation-bots/releases/download/flakybot-1.1.0/flakybot -o flakybot -s -L chmod +x ./flakybot diff --git a/.github/workflows/appengine-websockets.yaml b/.github/workflows/appengine-websockets.yaml index f78d1b5983..1d7e43e0e3 100644 --- a/.github/workflows/appengine-websockets.yaml +++ b/.github/workflows/appengine-websockets.yaml @@ -22,19 +22,23 @@ jobs: pull-requests: 'write' id-token: 'write' steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v3.1.0 with: ref: ${{github.event.pull_request.head.ref}} repository: ${{github.event.pull_request.head.repo.full_name}} +<<<<<<< HEAD + - uses: 'google-github-actions/auth@v0.8.3' +======= - uses: google-github-actions/auth@v1.0.0 +>>>>>>> main with: workload_identity_provider: 'projects/1046198160504/locations/global/workloadIdentityPools/github-actions-pool/providers/github-actions-provider' service_account: 'kokoro-system-test@long-door-651.iam.gserviceaccount.com' create_credentials_file: 'true' access_token_lifetime: 600s - - uses: actions/setup-node@v3 + - uses: actions/setup-node@v3.5.1 with: - node-version: 14 + node-version: 16 - run: npm install working-directory: appengine/websockets - run: npm test @@ -60,7 +64,7 @@ jobs: throw e; } } - - if: ${{ github.event_name == 'schedule' && always() }} + - if: ${{ github.event_name == 'schedule'}} run: | curl https://github.com/googleapis/repo-automation-bots/releases/download/flakybot-1.1.0/flakybot -o flakybot -s -L chmod +x ./flakybot diff --git a/.github/workflows/auth.yaml b/.github/workflows/auth.yaml index 7f27054411..8d6092d52d 100644 --- a/.github/workflows/auth.yaml +++ b/.github/workflows/auth.yaml @@ -22,20 +22,23 @@ jobs: pull-requests: 'write' id-token: 'write' steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v3.1.0 with: ref: ${{github.event.pull_request.head.ref}} repository: ${{github.event.pull_request.head.repo.full_name}} +<<<<<<< HEAD + - uses: 'google-github-actions/auth@v0.8.3' +======= - uses: google-github-actions/auth@v1.0.0 +>>>>>>> main with: workload_identity_provider: 'projects/1046198160504/locations/global/workloadIdentityPools/github-actions-pool/providers/github-actions-provider' service_account: 'kokoro-system-test@long-door-651.iam.gserviceaccount.com' create_credentials_file: 'true' - credentials_json: '${{ secrets.GOOGLE_CREDENTIALS }}' access_token_lifetime: 600s - - uses: actions/setup-node@v3 + - uses: actions/setup-node@v3.5.1 with: - node-version: 14 + node-version: 16 - run: npm install working-directory: auth - run: npm test @@ -61,7 +64,7 @@ jobs: throw e; } } - - if: ${{ github.event_name == 'schedule' && always() }} + - if: ${{ github.event_name == 'schedule'}} run: | curl https://github.com/googleapis/repo-automation-bots/releases/download/flakybot-1.1.0/flakybot -o flakybot -s -L chmod +x ./flakybot diff --git a/.github/workflows/cloud-tasks-tutorial-gcf-app.yaml b/.github/workflows/cloud-tasks-tutorial-gcf-app.yaml new file mode 100644 index 0000000000..fa79772cf7 --- /dev/null +++ b/.github/workflows/cloud-tasks-tutorial-gcf-app.yaml @@ -0,0 +1,67 @@ +name: cloud-tasks-tutorial-gcf-app +on: + push: + branches: + - main + paths: + - 'cloud-tasks/tutorial-gcf/app/**' + pull_request: + paths: + - 'cloud-tasks/tutorial-gcf/app/**' + pull_request_target: + types: [labeled] + schedule: + - cron: '0 0 * * 0' +jobs: + test: + if: ${{ github.event.action != 'labeled' || github.event.label.name == 'actions:force-run' }} + runs-on: ubuntu-latest + timeout-minutes: 60 + permissions: + contents: 'write' + pull-requests: 'write' + id-token: 'write' + steps: + - uses: actions/checkout@v3.1.0 + with: + ref: ${{github.event.pull_request.head.ref}} + repository: ${{github.event.pull_request.head.repo.full_name}} + - uses: 'google-github-actions/auth@v0.8.3' + with: + workload_identity_provider: 'projects/1046198160504/locations/global/workloadIdentityPools/github-actions-pool/providers/github-actions-provider' + service_account: 'kokoro-system-test@long-door-651.iam.gserviceaccount.com' + create_credentials_file: 'true' + access_token_lifetime: 600s + - uses: actions/setup-node@v3.5.1 + with: + node-version: 16 + - run: npm install + working-directory: cloud-tasks/tutorial-gcf/app + - run: npm test + working-directory: cloud-tasks/tutorial-gcf/app + env: + MOCHA_REPORTER_SUITENAME: cloud_tasks_tutorial_gcf_app + MOCHA_REPORTER_OUTPUT: cloud_tasks_tutorial_gcf_app_sponge_log.xml + MOCHA_REPORTER: xunit + - if: ${{ github.event.action == 'labeled' && github.event.label.name == 'actions:force-run' }} + uses: actions/github-script@v6 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + try { + await github.rest.issues.removeLabel({ + name: 'actions:force-run', + owner: 'GoogleCloudPlatform', + repo: 'nodejs-docs-samples', + issue_number: context.payload.pull_request.number + }); + } catch (e) { + if (!e.message.includes('Label does not exist')) { + throw e; + } + } + - if: ${{ github.event_name == 'schedule'}} + run: | + curl https://github.com/googleapis/repo-automation-bots/releases/download/flakybot-1.1.0/flakybot -o flakybot -s -L + chmod +x ./flakybot + ./flakybot --repo GoogleCloudPlatform/nodejs-docs-samples --commit_hash ${{github.sha}} --build_url https://github.com/${{github.repository}}/actions/runs/${{github.run_id}} diff --git a/.github/workflows/cloud-tasks-tutorial-gcf-function.yaml b/.github/workflows/cloud-tasks-tutorial-gcf-function.yaml new file mode 100644 index 0000000000..de35279518 --- /dev/null +++ b/.github/workflows/cloud-tasks-tutorial-gcf-function.yaml @@ -0,0 +1,67 @@ +name: cloud-tasks-tutorial-gcf-function +on: + push: + branches: + - main + paths: + - 'cloud-tasks/tutorial-gcf/function/**' + pull_request: + paths: + - 'cloud-tasks/tutorial-gcf/function/**' + pull_request_target: + types: [labeled] + schedule: + - cron: '0 0 * * 0' +jobs: + test: + if: ${{ github.event.action != 'labeled' || github.event.label.name == 'actions:force-run' }} + runs-on: ubuntu-latest + timeout-minutes: 60 + permissions: + contents: 'write' + pull-requests: 'write' + id-token: 'write' + steps: + - uses: actions/checkout@v3.1.0 + with: + ref: ${{github.event.pull_request.head.ref}} + repository: ${{github.event.pull_request.head.repo.full_name}} + - uses: 'google-github-actions/auth@v0.8.3' + with: + workload_identity_provider: 'projects/1046198160504/locations/global/workloadIdentityPools/github-actions-pool/providers/github-actions-provider' + service_account: 'kokoro-system-test@long-door-651.iam.gserviceaccount.com' + create_credentials_file: 'true' + access_token_lifetime: 600s + - uses: actions/setup-node@v3.5.1 + with: + node-version: 16 + - run: npm install + working-directory: cloud-tasks/tutorial-gcf/function + - run: npm test + working-directory: cloud-tasks/tutorial-gcf/function + env: + MOCHA_REPORTER_SUITENAME: cloud_tasks_tutorial_gcf_function + MOCHA_REPORTER_OUTPUT: cloud_tasks_tutorial_gcf_function_sponge_log.xml + MOCHA_REPORTER: xunit + - if: ${{ github.event.action == 'labeled' && github.event.label.name == 'actions:force-run' }} + uses: actions/github-script@v6 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + try { + await github.rest.issues.removeLabel({ + name: 'actions:force-run', + owner: 'GoogleCloudPlatform', + repo: 'nodejs-docs-samples', + issue_number: context.payload.pull_request.number + }); + } catch (e) { + if (!e.message.includes('Label does not exist')) { + throw e; + } + } + - if: ${{ github.event_name == 'schedule'}} + run: | + curl https://github.com/googleapis/repo-automation-bots/releases/download/flakybot-1.1.0/flakybot -o flakybot -s -L + chmod +x ./flakybot + ./flakybot --repo GoogleCloudPlatform/nodejs-docs-samples --commit_hash ${{github.sha}} --build_url https://github.com/${{github.repository}}/actions/runs/${{github.run_id}} diff --git a/.github/workflows/composer-functions-composer-storage-trigger.yaml b/.github/workflows/composer-functions-composer-storage-trigger.yaml index 0998b7c0f0..43574e0735 100644 --- a/.github/workflows/composer-functions-composer-storage-trigger.yaml +++ b/.github/workflows/composer-functions-composer-storage-trigger.yaml @@ -22,19 +22,23 @@ jobs: pull-requests: 'write' id-token: 'write' steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v3.1.0 with: ref: ${{github.event.pull_request.head.ref}} repository: ${{github.event.pull_request.head.repo.full_name}} +<<<<<<< HEAD + - uses: 'google-github-actions/auth@v0.8.3' +======= - uses: google-github-actions/auth@v1.0.0 +>>>>>>> main with: workload_identity_provider: 'projects/1046198160504/locations/global/workloadIdentityPools/github-actions-pool/providers/github-actions-provider' service_account: 'kokoro-system-test@long-door-651.iam.gserviceaccount.com' create_credentials_file: 'true' access_token_lifetime: 600s - - uses: actions/setup-node@v3 + - uses: actions/setup-node@v3.5.1 with: - node-version: 14 + node-version: 16 - run: npm install working-directory: composer/functions/composer-storage-trigger - run: npm test @@ -60,7 +64,7 @@ jobs: throw e; } } - - if: ${{ github.event_name == 'schedule' && always() }} + - if: ${{ github.event_name == 'schedule'}} run: | curl https://github.com/googleapis/repo-automation-bots/releases/download/flakybot-1.1.0/flakybot -o flakybot -s -L chmod +x ./flakybot diff --git a/.github/workflows/composer.yaml b/.github/workflows/composer.yaml index a348450de7..b950825f32 100644 --- a/.github/workflows/composer.yaml +++ b/.github/workflows/composer.yaml @@ -22,19 +22,23 @@ jobs: pull-requests: 'write' id-token: 'write' steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v3.1.0 with: ref: ${{github.event.pull_request.head.ref}} repository: ${{github.event.pull_request.head.repo.full_name}} +<<<<<<< HEAD + - uses: 'google-github-actions/auth@v0.8.3' +======= - uses: google-github-actions/auth@v1.0.0 +>>>>>>> main with: workload_identity_provider: 'projects/1046198160504/locations/global/workloadIdentityPools/github-actions-pool/providers/github-actions-provider' service_account: 'kokoro-system-test@long-door-651.iam.gserviceaccount.com' create_credentials_file: 'true' access_token_lifetime: 600s - - uses: actions/setup-node@v3 + - uses: actions/setup-node@v3.5.1 with: - node-version: 14 + node-version: 16 - run: npm install working-directory: composer - run: npm test @@ -60,7 +64,7 @@ jobs: throw e; } } - - if: ${{ github.event_name == 'schedule' && always() }} + - if: ${{ github.event_name == 'schedule'}} run: | curl https://github.com/googleapis/repo-automation-bots/releases/download/flakybot-1.1.0/flakybot -o flakybot -s -L chmod +x ./flakybot diff --git a/.github/workflows/containerengine-hello-world.yaml b/.github/workflows/containerengine-hello-world.yaml index eab4d76d1d..8b4bfd501e 100644 --- a/.github/workflows/containerengine-hello-world.yaml +++ b/.github/workflows/containerengine-hello-world.yaml @@ -22,19 +22,23 @@ jobs: pull-requests: 'write' id-token: 'write' steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v3.1.0 with: ref: ${{github.event.pull_request.head.ref}} repository: ${{github.event.pull_request.head.repo.full_name}} +<<<<<<< HEAD + - uses: 'google-github-actions/auth@v0.8.3' +======= - uses: google-github-actions/auth@v1.0.0 +>>>>>>> main with: workload_identity_provider: 'projects/1046198160504/locations/global/workloadIdentityPools/github-actions-pool/providers/github-actions-provider' service_account: 'kokoro-system-test@long-door-651.iam.gserviceaccount.com' create_credentials_file: 'true' access_token_lifetime: 600s - - uses: actions/setup-node@v3 + - uses: actions/setup-node@v3.5.1 with: - node-version: 14 + node-version: 16 - run: npm install working-directory: containerengine/hello-world - run: npm test @@ -60,7 +64,7 @@ jobs: throw e; } } - - if: ${{ github.event_name == 'schedule' && always() }} + - if: ${{ github.event_name == 'schedule'}} run: | curl https://github.com/googleapis/repo-automation-bots/releases/download/flakybot-1.1.0/flakybot -o flakybot -s -L chmod +x ./flakybot diff --git a/.github/workflows/datacatalog-cloud-client.yaml b/.github/workflows/datacatalog-cloud-client.yaml index 894bfc72a1..0199e6896f 100644 --- a/.github/workflows/datacatalog-cloud-client.yaml +++ b/.github/workflows/datacatalog-cloud-client.yaml @@ -22,19 +22,23 @@ jobs: pull-requests: 'write' id-token: 'write' steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v3.1.0 with: ref: ${{github.event.pull_request.head.ref}} repository: ${{github.event.pull_request.head.repo.full_name}} +<<<<<<< HEAD + - uses: 'google-github-actions/auth@v0.8.3' +======= - uses: google-github-actions/auth@v1.0.0 +>>>>>>> main with: workload_identity_provider: 'projects/1046198160504/locations/global/workloadIdentityPools/github-actions-pool/providers/github-actions-provider' service_account: 'kokoro-system-test@long-door-651.iam.gserviceaccount.com' create_credentials_file: 'true' access_token_lifetime: 600s - - uses: actions/setup-node@v3 + - uses: actions/setup-node@v3.5.1 with: - node-version: 14 + node-version: 16 - run: npm install working-directory: datacatalog/cloud-client - run: npm test @@ -60,7 +64,7 @@ jobs: throw e; } } - - if: ${{ github.event_name == 'schedule' && always() }} + - if: ${{ github.event_name == 'schedule'}} run: | curl https://github.com/googleapis/repo-automation-bots/releases/download/flakybot-1.1.0/flakybot -o flakybot -s -L chmod +x ./flakybot diff --git a/.github/workflows/datacatalog-quickstart.yaml b/.github/workflows/datacatalog-quickstart.yaml index 7f1d6ee500..892ccbe224 100644 --- a/.github/workflows/datacatalog-quickstart.yaml +++ b/.github/workflows/datacatalog-quickstart.yaml @@ -22,19 +22,23 @@ jobs: pull-requests: 'write' id-token: 'write' steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v3.1.0 with: ref: ${{github.event.pull_request.head.ref}} repository: ${{github.event.pull_request.head.repo.full_name}} +<<<<<<< HEAD + - uses: 'google-github-actions/auth@v0.8.3' +======= - uses: google-github-actions/auth@v1.0.0 +>>>>>>> main with: workload_identity_provider: 'projects/1046198160504/locations/global/workloadIdentityPools/github-actions-pool/providers/github-actions-provider' service_account: 'kokoro-system-test@long-door-651.iam.gserviceaccount.com' create_credentials_file: 'true' access_token_lifetime: 600s - - uses: actions/setup-node@v3 + - uses: actions/setup-node@v3.5.1 with: - node-version: 14 + node-version: 16 - run: npm install working-directory: datacatalog/quickstart - run: npm test @@ -60,7 +64,7 @@ jobs: throw e; } } - - if: ${{ github.event_name == 'schedule' && always() }} + - if: ${{ github.event_name == 'schedule'}} run: | curl https://github.com/googleapis/repo-automation-bots/releases/download/flakybot-1.1.0/flakybot -o flakybot -s -L chmod +x ./flakybot diff --git a/.github/workflows/datalabeling.yaml b/.github/workflows/datalabeling.yaml index d460568769..d7ec04ff1c 100644 --- a/.github/workflows/datalabeling.yaml +++ b/.github/workflows/datalabeling.yaml @@ -2,26 +2,64 @@ name: datalabeling on: push: branches: - - main + - main paths: - - "datalabeling/**" + - 'datalabeling/**' pull_request: paths: - - "datalabeling/**" + - 'datalabeling/**' pull_request_target: types: [labeled] schedule: - - cron: "0 0 * * 0" + - cron: '0 0 * * 0' jobs: test: if: ${{ github.event.action != 'labeled' || github.event.label.name == 'actions:force-run' }} runs-on: ubuntu-latest timeout-minutes: 60 permissions: - contents: "write" - pull-requests: "write" - id-token: "write" + contents: 'write' + pull-requests: 'write' + id-token: 'write' steps: +<<<<<<< HEAD + - uses: actions/checkout@v3.1.0 + with: + ref: ${{github.event.pull_request.head.ref}} + repository: ${{github.event.pull_request.head.repo.full_name}} + - uses: 'google-github-actions/auth@v0.8.3' + with: + workload_identity_provider: 'projects/1046198160504/locations/global/workloadIdentityPools/github-actions-pool/providers/github-actions-provider' + service_account: 'kokoro-system-test@long-door-651.iam.gserviceaccount.com' + create_credentials_file: 'true' + access_token_lifetime: 600s + - uses: actions/setup-node@v3.5.1 + with: + node-version: 16 + - run: npm install + working-directory: datalabeling + - run: npm test + working-directory: datalabeling + env: + MOCHA_REPORTER_SUITENAME: datalabeling + MOCHA_REPORTER_OUTPUT: datalabeling_sponge_log.xml + MOCHA_REPORTER: xunit + - if: ${{ github.event.action == 'labeled' && github.event.label.name == 'actions:force-run' }} + uses: actions/github-script@v6 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + try { + await github.rest.issues.removeLabel({ + name: 'actions:force-run', + owner: 'GoogleCloudPlatform', + repo: 'nodejs-docs-samples', + issue_number: context.payload.pull_request.number + }); + } catch (e) { + if (!e.message.includes('Label does not exist')) { + throw e; +======= - uses: actions/checkout@v3.1.0 with: ref: ${{github.event.pull_request.head.ref}} @@ -59,9 +97,11 @@ jobs: if (!e.message.includes('Label does not exist')) { throw e; } +>>>>>>> main } - - if: ${{ github.event_name == 'schedule'}} - run: | - curl https://github.com/googleapis/repo-automation-bots/releases/download/flakybot-1.1.0/flakybot -o flakybot -s -L - chmod +x ./flakybot - ./flakybot --repo GoogleCloudPlatform/nodejs-docs-samples --commit_hash ${{github.sha}} --build_url https://github.com/${{github.repository}}/actions/runs/${{github.run_id}} + } + - if: ${{ github.event_name == 'schedule'}} + run: | + curl https://github.com/googleapis/repo-automation-bots/releases/download/flakybot-1.1.0/flakybot -o flakybot -s -L + chmod +x ./flakybot + ./flakybot --repo GoogleCloudPlatform/nodejs-docs-samples --commit_hash ${{github.sha}} --build_url https://github.com/${{github.repository}}/actions/runs/${{github.run_id}} diff --git a/.github/workflows/datastore-functions.yaml b/.github/workflows/datastore-functions.yaml index 5a651d395f..ad64e7f085 100644 --- a/.github/workflows/datastore-functions.yaml +++ b/.github/workflows/datastore-functions.yaml @@ -22,19 +22,23 @@ jobs: pull-requests: 'write' id-token: 'write' steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v3.1.0 with: ref: ${{github.event.pull_request.head.ref}} repository: ${{github.event.pull_request.head.repo.full_name}} +<<<<<<< HEAD + - uses: 'google-github-actions/auth@v0.8.3' +======= - uses: google-github-actions/auth@v1.0.0 +>>>>>>> main with: workload_identity_provider: 'projects/1046198160504/locations/global/workloadIdentityPools/github-actions-pool/providers/github-actions-provider' service_account: 'kokoro-system-test@long-door-651.iam.gserviceaccount.com' create_credentials_file: 'true' access_token_lifetime: 600s - - uses: actions/setup-node@v3 + - uses: actions/setup-node@v3.5.1 with: - node-version: 14 + node-version: 16 - run: npm install working-directory: datastore/functions - run: npm test @@ -60,7 +64,7 @@ jobs: throw e; } } - - if: ${{ github.event_name == 'schedule' && always() }} + - if: ${{ github.event_name == 'schedule'}} run: | curl https://github.com/googleapis/repo-automation-bots/releases/download/flakybot-1.1.0/flakybot -o flakybot -s -L chmod +x ./flakybot diff --git a/.github/workflows/endpoints-getting-started-grpc.yaml b/.github/workflows/endpoints-getting-started-grpc.yaml index 971fe19d38..27feb87e7f 100644 --- a/.github/workflows/endpoints-getting-started-grpc.yaml +++ b/.github/workflows/endpoints-getting-started-grpc.yaml @@ -22,19 +22,23 @@ jobs: pull-requests: 'write' id-token: 'write' steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v3.1.0 with: ref: ${{github.event.pull_request.head.ref}} repository: ${{github.event.pull_request.head.repo.full_name}} +<<<<<<< HEAD + - uses: 'google-github-actions/auth@v0.8.3' +======= - uses: google-github-actions/auth@v1.0.0 +>>>>>>> main with: workload_identity_provider: 'projects/1046198160504/locations/global/workloadIdentityPools/github-actions-pool/providers/github-actions-provider' service_account: 'kokoro-system-test@long-door-651.iam.gserviceaccount.com' create_credentials_file: 'true' access_token_lifetime: 600s - - uses: actions/setup-node@v3 + - uses: actions/setup-node@v3.5.1 with: - node-version: 14 + node-version: 16 - run: npm install working-directory: endpoints/getting-started-grpc - run: npm test @@ -60,7 +64,7 @@ jobs: throw e; } } - - if: ${{ github.event_name == 'schedule' && always() }} + - if: ${{ github.event_name == 'schedule'}} run: | curl https://github.com/googleapis/repo-automation-bots/releases/download/flakybot-1.1.0/flakybot -o flakybot -s -L chmod +x ./flakybot diff --git a/.github/workflows/endpoints-getting-started.yaml b/.github/workflows/endpoints-getting-started.yaml index 137d976d70..09e13bb841 100644 --- a/.github/workflows/endpoints-getting-started.yaml +++ b/.github/workflows/endpoints-getting-started.yaml @@ -22,19 +22,23 @@ jobs: pull-requests: 'write' id-token: 'write' steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v3.1.0 with: ref: ${{github.event.pull_request.head.ref}} repository: ${{github.event.pull_request.head.repo.full_name}} +<<<<<<< HEAD + - uses: 'google-github-actions/auth@v0.8.3' +======= - uses: google-github-actions/auth@v1.0.0 +>>>>>>> main with: workload_identity_provider: 'projects/1046198160504/locations/global/workloadIdentityPools/github-actions-pool/providers/github-actions-provider' service_account: 'kokoro-system-test@long-door-651.iam.gserviceaccount.com' create_credentials_file: 'true' access_token_lifetime: 600s - - uses: actions/setup-node@v3 + - uses: actions/setup-node@v3.5.1 with: - node-version: 14 + node-version: 16 - run: npm install working-directory: endpoints/getting-started - run: npm test @@ -60,7 +64,7 @@ jobs: throw e; } } - - if: ${{ github.event_name == 'schedule' && always() }} + - if: ${{ github.event_name == 'schedule'}} run: | curl https://github.com/googleapis/repo-automation-bots/releases/download/flakybot-1.1.0/flakybot -o flakybot -s -L chmod +x ./flakybot diff --git a/.github/workflows/functions-firebase.yaml b/.github/workflows/functions-firebase.yaml index 8c2f2c405d..fe6e432212 100644 --- a/.github/workflows/functions-firebase.yaml +++ b/.github/workflows/functions-firebase.yaml @@ -14,18 +14,6 @@ on: - cron: '0 0 * * 0' jobs: test: - strategy: - matrix: - # Each package in this list will be tested independently. - # New packages must be manually added to this list. - package: - - 'functions/firebase' - - 'functions/firebase/helloAnalytics' - - 'functions/firebase/helloAuth' - - 'functions/firebase/helloFirestore' - - 'functions/firebase/helloRTDB' - - 'functions/firebase/helloRemoteConfig' - - 'functions/firebase/makeUpperCase' if: ${{ github.event.action != 'labeled' || github.event.label.name == 'actions:force-run' }} runs-on: ubuntu-latest timeout-minutes: 60 @@ -34,24 +22,30 @@ jobs: pull-requests: 'write' id-token: 'write' steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v3.1.0 with: ref: ${{github.event.pull_request.head.ref}} repository: ${{github.event.pull_request.head.repo.full_name}} +<<<<<<< HEAD + - uses: 'google-github-actions/auth@v0.8.3' +======= - uses: google-github-actions/auth@v1.0.0 +>>>>>>> main with: workload_identity_provider: 'projects/1046198160504/locations/global/workloadIdentityPools/github-actions-pool/providers/github-actions-provider' service_account: 'kokoro-system-test@long-door-651.iam.gserviceaccount.com' create_credentials_file: 'true' access_token_lifetime: 600s - - uses: actions/setup-node@v3 + - uses: actions/setup-node@v3.5.1 with: - node-version: 14 + node-version: 16 - run: npm install - working-directory: ${{ matrix.package }} - - run: npm test -- --reporter xunit --reporter-option output=sponge_log.xml --reporter-option suiteName="${{ matrix.package }}" - working-directory: ${{ matrix.package }} + working-directory: functions/firebase + - run: npm test + working-directory: functions/firebase env: + MOCHA_REPORTER_SUITENAME: functions_firebase + MOCHA_REPORTER_OUTPUT: functions_firebase_sponge_log.xml MOCHA_REPORTER: xunit - if: ${{ github.event.action == 'labeled' && github.event.label.name == 'actions:force-run' }} uses: actions/github-script@v6 @@ -70,7 +64,7 @@ jobs: throw e; } } - - if: ${{ github.event_name == 'schedule' && always() }} + - if: ${{ github.event_name == 'schedule'}} run: | curl https://github.com/googleapis/repo-automation-bots/releases/download/flakybot-1.1.0/flakybot -o flakybot -s -L chmod +x ./flakybot diff --git a/.github/workflows/functions-helloworld.yaml b/.github/workflows/functions-helloworld.yaml index 018ec45526..94ec330f87 100644 --- a/.github/workflows/functions-helloworld.yaml +++ b/.github/workflows/functions-helloworld.yaml @@ -14,17 +14,6 @@ on: - cron: '0 0 * * 0' jobs: test: - strategy: - matrix: - # Each package in this list will be tested independently. - # New packages must be manually added to this list. - package: - - 'functions/helloworld' - - 'functions/helloworld/helloError' - - 'functions/helloworld/helloGCS' - - 'functions/helloworld/helloPubSub' - - 'functions/helloworld/helloworldGet' - - 'functions/helloworld/helloworldHttp' if: ${{ github.event.action != 'labeled' || github.event.label.name == 'actions:force-run' }} runs-on: ubuntu-latest timeout-minutes: 60 @@ -33,23 +22,31 @@ jobs: pull-requests: 'write' id-token: 'write' steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v3.1.0 with: ref: ${{github.event.pull_request.head.ref}} repository: ${{github.event.pull_request.head.repo.full_name}} +<<<<<<< HEAD + - uses: 'google-github-actions/auth@v0.8.3' +======= - uses: google-github-actions/auth@v1.0.0 +>>>>>>> main with: workload_identity_provider: 'projects/1046198160504/locations/global/workloadIdentityPools/github-actions-pool/providers/github-actions-provider' service_account: 'kokoro-system-test@long-door-651.iam.gserviceaccount.com' create_credentials_file: 'true' access_token_lifetime: 600s - - uses: actions/setup-node@v3 + - uses: actions/setup-node@v3.5.1 with: - node-version: 14 + node-version: 16 - run: npm install - working-directory: ${{ matrix.package }} - - run: npm test -- --reporter xunit --reporter-option output=sponge_log.xml --reporter-option suiteName="${{ matrix.package }}" - working-directory: ${{ matrix.package }} + working-directory: functions/helloworld + - run: npm test + working-directory: functions/helloworld + env: + MOCHA_REPORTER_SUITENAME: functions_helloworld + MOCHA_REPORTER_OUTPUT: functions_helloworld_sponge_log.xml + MOCHA_REPORTER: xunit - if: ${{ github.event.action == 'labeled' && github.event.label.name == 'actions:force-run' }} uses: actions/github-script@v6 with: @@ -67,7 +64,7 @@ jobs: throw e; } } - - if: ${{ github.event_name == 'schedule' && always() }} + - if: ${{ github.event_name == 'schedule'}} run: | curl https://github.com/googleapis/repo-automation-bots/releases/download/flakybot-1.1.0/flakybot -o flakybot -s -L chmod +x ./flakybot diff --git a/.github/workflows/functions-http-httpMethods.yaml b/.github/workflows/functions-http-httpMethods.yaml new file mode 100644 index 0000000000..d8efdad4d1 --- /dev/null +++ b/.github/workflows/functions-http-httpMethods.yaml @@ -0,0 +1,67 @@ +name: functions-http-httpMethods +on: + push: + branches: + - main + paths: + - 'functions/http/httpMethods/**' + pull_request: + paths: + - 'functions/http/httpMethods/**' + pull_request_target: + types: [labeled] + schedule: + - cron: '0 0 * * 0' +jobs: + test: + if: ${{ github.event.action != 'labeled' || github.event.label.name == 'actions:force-run' }} + runs-on: ubuntu-latest + timeout-minutes: 60 + permissions: + contents: 'write' + pull-requests: 'write' + id-token: 'write' + steps: + - uses: actions/checkout@v3.1.0 + with: + ref: ${{github.event.pull_request.head.ref}} + repository: ${{github.event.pull_request.head.repo.full_name}} + - uses: 'google-github-actions/auth@v0.8.3' + with: + workload_identity_provider: 'projects/1046198160504/locations/global/workloadIdentityPools/github-actions-pool/providers/github-actions-provider' + service_account: 'kokoro-system-test@long-door-651.iam.gserviceaccount.com' + create_credentials_file: 'true' + access_token_lifetime: 600s + - uses: actions/setup-node@v3.5.1 + with: + node-version: 16 + - run: npm install + working-directory: functions/http/httpMethods + - run: npm test + working-directory: functions/http/httpMethods + env: + MOCHA_REPORTER_SUITENAME: functions_http_httpMethods + MOCHA_REPORTER_OUTPUT: functions_http_httpMethods_sponge_log.xml + MOCHA_REPORTER: xunit + - if: ${{ github.event.action == 'labeled' && github.event.label.name == 'actions:force-run' }} + uses: actions/github-script@v6 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + try { + await github.rest.issues.removeLabel({ + name: 'actions:force-run', + owner: 'GoogleCloudPlatform', + repo: 'nodejs-docs-samples', + issue_number: context.payload.pull_request.number + }); + } catch (e) { + if (!e.message.includes('Label does not exist')) { + throw e; + } + } + - if: ${{ github.event_name == 'schedule'}} + run: | + curl https://github.com/googleapis/repo-automation-bots/releases/download/flakybot-1.1.0/flakybot -o flakybot -s -L + chmod +x ./flakybot + ./flakybot --repo GoogleCloudPlatform/nodejs-docs-samples --commit_hash ${{github.sha}} --build_url https://github.com/${{github.repository}}/actions/runs/${{github.run_id}} diff --git a/.github/workflows/functions-http.yaml b/.github/workflows/functions-http.yaml index 136ae187b2..f7eb10d71c 100644 --- a/.github/workflows/functions-http.yaml +++ b/.github/workflows/functions-http.yaml @@ -14,18 +14,6 @@ on: - cron: '0 0 * * 0' jobs: test: - strategy: - matrix: - # Each package in this list will be tested independently. - # New packages must be manually added to this list. - package: - - 'functions/http' - - 'functions/http/corsEnabledFunction' - - 'functions/http/corsEnabledFunctionAuth' - - 'functions/http/httpContent' - - 'functions/http/httpMethods' - - 'functions/http/parseXML' - - 'functions/http/uploadFile' if: ${{ github.event.action != 'labeled' || github.event.label.name == 'actions:force-run' }} runs-on: ubuntu-latest timeout-minutes: 60 @@ -34,24 +22,30 @@ jobs: pull-requests: 'write' id-token: 'write' steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v3.1.0 with: ref: ${{github.event.pull_request.head.ref}} repository: ${{github.event.pull_request.head.repo.full_name}} +<<<<<<< HEAD + - uses: 'google-github-actions/auth@v0.8.3' +======= - uses: google-github-actions/auth@v1.0.0 +>>>>>>> main with: workload_identity_provider: 'projects/1046198160504/locations/global/workloadIdentityPools/github-actions-pool/providers/github-actions-provider' service_account: 'kokoro-system-test@long-door-651.iam.gserviceaccount.com' create_credentials_file: 'true' access_token_lifetime: 600s - - uses: actions/setup-node@v3 + - uses: actions/setup-node@v3.5.1 with: - node-version: 14 + node-version: 16 - run: npm install - working-directory: ${{ matrix.package }} - - run: npm test -- --reporter xunit --reporter-option output=sponge_log.xml --reporter-option suiteName="${{ matrix.package }}" - working-directory: ${{ matrix.package }} + working-directory: functions/http + - run: npm test + working-directory: functions/http env: + MOCHA_REPORTER_SUITENAME: functions_http + MOCHA_REPORTER_OUTPUT: functions_http_sponge_log.xml MOCHA_REPORTER: xunit - if: ${{ github.event.action == 'labeled' && github.event.label.name == 'actions:force-run' }} uses: actions/github-script@v6 @@ -70,7 +64,7 @@ jobs: throw e; } } - - if: ${{ github.event_name == 'schedule' && always() }} + - if: ${{ github.event_name == 'schedule'}} run: | curl https://github.com/googleapis/repo-automation-bots/releases/download/flakybot-1.1.0/flakybot -o flakybot -s -L chmod +x ./flakybot diff --git a/.github/workflows/functions-scheduleinstance.yaml b/.github/workflows/functions-scheduleinstance.yaml index 9c7a441bff..0e0b3f6415 100644 --- a/.github/workflows/functions-scheduleinstance.yaml +++ b/.github/workflows/functions-scheduleinstance.yaml @@ -22,19 +22,23 @@ jobs: pull-requests: 'write' id-token: 'write' steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v3.1.0 with: ref: ${{github.event.pull_request.head.ref}} repository: ${{github.event.pull_request.head.repo.full_name}} +<<<<<<< HEAD + - uses: 'google-github-actions/auth@v0.8.3' +======= - uses: google-github-actions/auth@v1.0.0 +>>>>>>> main with: workload_identity_provider: 'projects/1046198160504/locations/global/workloadIdentityPools/github-actions-pool/providers/github-actions-provider' service_account: 'kokoro-system-test@long-door-651.iam.gserviceaccount.com' create_credentials_file: 'true' access_token_lifetime: 600s - - uses: actions/setup-node@v3 + - uses: actions/setup-node@v3.5.1 with: - node-version: 14 + node-version: 16 - run: npm install working-directory: functions/scheduleinstance - run: npm test @@ -60,7 +64,7 @@ jobs: throw e; } } - - if: ${{ github.event_name == 'schedule' && always() }} + - if: ${{ github.event_name == 'schedule'}} run: | curl https://github.com/googleapis/repo-automation-bots/releases/download/flakybot-1.1.0/flakybot -o flakybot -s -L chmod +x ./flakybot diff --git a/.github/workflows/functions-security.yaml b/.github/workflows/functions-security.yaml index a9ed6da645..f2408174ca 100644 --- a/.github/workflows/functions-security.yaml +++ b/.github/workflows/functions-security.yaml @@ -22,19 +22,23 @@ jobs: pull-requests: 'write' id-token: 'write' steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v3.1.0 with: ref: ${{github.event.pull_request.head.ref}} repository: ${{github.event.pull_request.head.repo.full_name}} +<<<<<<< HEAD + - uses: 'google-github-actions/auth@v0.8.3' +======= - uses: google-github-actions/auth@v1.0.0 +>>>>>>> main with: workload_identity_provider: 'projects/1046198160504/locations/global/workloadIdentityPools/github-actions-pool/providers/github-actions-provider' service_account: 'kokoro-system-test@long-door-651.iam.gserviceaccount.com' create_credentials_file: 'true' access_token_lifetime: 600s - - uses: actions/setup-node@v3 + - uses: actions/setup-node@v3.5.1 with: - node-version: 14 + node-version: 16 - run: npm install working-directory: functions/security - run: npm test @@ -60,7 +64,7 @@ jobs: throw e; } } - - if: ${{ github.event_name == 'schedule' && always() }} + - if: ${{ github.event_name == 'schedule'}} run: | curl https://github.com/googleapis/repo-automation-bots/releases/download/flakybot-1.1.0/flakybot -o flakybot -s -L chmod +x ./flakybot diff --git a/.github/workflows/functions-slack.yaml b/.github/workflows/functions-slack.yaml index c1e598eefc..10fb701aac 100644 --- a/.github/workflows/functions-slack.yaml +++ b/.github/workflows/functions-slack.yaml @@ -22,25 +22,23 @@ jobs: pull-requests: 'write' id-token: 'write' steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v3.1.0 with: ref: ${{github.event.pull_request.head.ref}} repository: ${{github.event.pull_request.head.repo.full_name}} +<<<<<<< HEAD + - uses: 'google-github-actions/auth@v0.8.3' +======= - uses: google-github-actions/auth@v1.0.0 +>>>>>>> main with: workload_identity_provider: 'projects/1046198160504/locations/global/workloadIdentityPools/github-actions-pool/providers/github-actions-provider' service_account: 'kokoro-system-test@long-door-651.iam.gserviceaccount.com' create_credentials_file: 'true' access_token_lifetime: 600s - - id: secrets - uses: 'google-github-actions/get-secretmanager-secrets@v0' + - uses: actions/setup-node@v3.5.1 with: - secrets: |- - slack_secret:nodejs-docs-samples-tests/nodejs-docs-samples-slack-secret - kg_api_key:nodejs-docs-samples-tests/nodejs-docs-samples-kg-api-key - - uses: actions/setup-node@v3 - with: - node-version: 14 + node-version: 16 - run: npm install working-directory: functions/slack - run: npm test @@ -49,8 +47,6 @@ jobs: MOCHA_REPORTER_SUITENAME: functions_slack MOCHA_REPORTER_OUTPUT: functions_slack_sponge_log.xml MOCHA_REPORTER: xunit - SLACK_SECRET: ${{ steps.secrets.outputs.slack_secret }} - API_KEY: ${{ steps.secrets.outputs.kg_api_key }} - if: ${{ github.event.action == 'labeled' && github.event.label.name == 'actions:force-run' }} uses: actions/github-script@v6 with: @@ -68,7 +64,7 @@ jobs: throw e; } } - - if: ${{ github.event_name == 'schedule' && always() }} + - if: ${{ github.event_name == 'schedule'}} run: | curl https://github.com/googleapis/repo-automation-bots/releases/download/flakybot-1.1.0/flakybot -o flakybot -s -L chmod +x ./flakybot diff --git a/.github/workflows/functions-spanner.yaml b/.github/workflows/functions-spanner.yaml index 421ab2e97b..03b7dfcfcc 100644 --- a/.github/workflows/functions-spanner.yaml +++ b/.github/workflows/functions-spanner.yaml @@ -22,19 +22,23 @@ jobs: pull-requests: 'write' id-token: 'write' steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v3.1.0 with: ref: ${{github.event.pull_request.head.ref}} repository: ${{github.event.pull_request.head.repo.full_name}} +<<<<<<< HEAD + - uses: 'google-github-actions/auth@v0.8.3' +======= - uses: google-github-actions/auth@v1.0.0 +>>>>>>> main with: workload_identity_provider: 'projects/1046198160504/locations/global/workloadIdentityPools/github-actions-pool/providers/github-actions-provider' service_account: 'kokoro-system-test@long-door-651.iam.gserviceaccount.com' create_credentials_file: 'true' access_token_lifetime: 600s - - uses: actions/setup-node@v3 + - uses: actions/setup-node@v3.5.1 with: - node-version: 14 + node-version: 16 - run: npm install working-directory: functions/spanner - run: npm test @@ -60,7 +64,7 @@ jobs: throw e; } } - - if: ${{ github.event_name == 'schedule' && always() }} + - if: ${{ github.event_name == 'schedule'}} run: | curl https://github.com/googleapis/repo-automation-bots/releases/download/flakybot-1.1.0/flakybot -o flakybot -s -L chmod +x ./flakybot diff --git a/.github/workflows/healthcare-datasets.yaml b/.github/workflows/healthcare-datasets.yaml index b9d012ac4c..fe98cbc953 100644 --- a/.github/workflows/healthcare-datasets.yaml +++ b/.github/workflows/healthcare-datasets.yaml @@ -11,7 +11,7 @@ on: pull_request_target: types: [labeled] schedule: - - cron: '0 2 * * *' + - cron: '0 0 * * 0' jobs: test: if: ${{ github.event.action != 'labeled' || github.event.label.name == 'actions:force-run' }} @@ -22,19 +22,23 @@ jobs: pull-requests: 'write' id-token: 'write' steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v3.1.0 with: ref: ${{github.event.pull_request.head.ref}} repository: ${{github.event.pull_request.head.repo.full_name}} +<<<<<<< HEAD + - uses: 'google-github-actions/auth@v0.8.3' +======= - uses: google-github-actions/auth@v1.0.0 +>>>>>>> main with: workload_identity_provider: 'projects/1046198160504/locations/global/workloadIdentityPools/github-actions-pool/providers/github-actions-provider' service_account: 'kokoro-system-test@long-door-651.iam.gserviceaccount.com' create_credentials_file: 'true' access_token_lifetime: 600s - - uses: actions/setup-node@v3 + - uses: actions/setup-node@v3.5.1 with: - node-version: 14 + node-version: 16 - run: npm install working-directory: healthcare/datasets - run: npm test @@ -60,7 +64,7 @@ jobs: throw e; } } - - if: ${{ github.event_name == 'schedule' && always() }} + - if: ${{ github.event_name == 'schedule'}} run: | curl https://github.com/googleapis/repo-automation-bots/releases/download/flakybot-1.1.0/flakybot -o flakybot -s -L chmod +x ./flakybot diff --git a/.github/workflows/healthcare-dicom.yaml b/.github/workflows/healthcare-dicom.yaml index f2be90d360..9e610846ca 100644 --- a/.github/workflows/healthcare-dicom.yaml +++ b/.github/workflows/healthcare-dicom.yaml @@ -11,7 +11,7 @@ on: pull_request_target: types: [labeled] schedule: - - cron: '0 2 * * *' + - cron: '0 0 * * 0' jobs: test: if: ${{ github.event.action != 'labeled' || github.event.label.name == 'actions:force-run' }} @@ -22,19 +22,23 @@ jobs: pull-requests: 'write' id-token: 'write' steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v3.1.0 with: ref: ${{github.event.pull_request.head.ref}} repository: ${{github.event.pull_request.head.repo.full_name}} +<<<<<<< HEAD + - uses: 'google-github-actions/auth@v0.8.3' +======= - uses: google-github-actions/auth@v1.0.0 +>>>>>>> main with: workload_identity_provider: 'projects/1046198160504/locations/global/workloadIdentityPools/github-actions-pool/providers/github-actions-provider' service_account: 'kokoro-system-test@long-door-651.iam.gserviceaccount.com' create_credentials_file: 'true' access_token_lifetime: 600s - - uses: actions/setup-node@v3 + - uses: actions/setup-node@v3.5.1 with: - node-version: 14 + node-version: 16 - run: npm install working-directory: healthcare/dicom - run: npm test @@ -60,7 +64,7 @@ jobs: throw e; } } - - if: ${{ github.event_name == 'schedule' && always() }} + - if: ${{ github.event_name == 'schedule'}} run: | curl https://github.com/googleapis/repo-automation-bots/releases/download/flakybot-1.1.0/flakybot -o flakybot -s -L chmod +x ./flakybot diff --git a/.github/workflows/healthcare-fhir.yaml b/.github/workflows/healthcare-fhir.yaml index e865de960d..af80985487 100644 --- a/.github/workflows/healthcare-fhir.yaml +++ b/.github/workflows/healthcare-fhir.yaml @@ -11,7 +11,7 @@ on: pull_request_target: types: [labeled] schedule: - - cron: '0 2 * * *' + - cron: '0 0 * * 0' jobs: test: if: ${{ github.event.action != 'labeled' || github.event.label.name == 'actions:force-run' }} @@ -22,19 +22,23 @@ jobs: pull-requests: 'write' id-token: 'write' steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v3.1.0 with: ref: ${{github.event.pull_request.head.ref}} repository: ${{github.event.pull_request.head.repo.full_name}} +<<<<<<< HEAD + - uses: 'google-github-actions/auth@v0.8.3' +======= - uses: google-github-actions/auth@v1.0.0 +>>>>>>> main with: workload_identity_provider: 'projects/1046198160504/locations/global/workloadIdentityPools/github-actions-pool/providers/github-actions-provider' service_account: 'kokoro-system-test@long-door-651.iam.gserviceaccount.com' create_credentials_file: 'true' access_token_lifetime: 600s - - uses: actions/setup-node@v3 + - uses: actions/setup-node@v3.5.1 with: - node-version: 14 + node-version: 16 - run: npm install working-directory: healthcare/fhir - run: npm test @@ -60,7 +64,7 @@ jobs: throw e; } } - - if: ${{ github.event_name == 'schedule' && always() }} + - if: ${{ github.event_name == 'schedule'}} run: | curl https://github.com/googleapis/repo-automation-bots/releases/download/flakybot-1.1.0/flakybot -o flakybot -s -L chmod +x ./flakybot diff --git a/.github/workflows/healthcare-hl7v2.yaml b/.github/workflows/healthcare-hl7v2.yaml index 898c69fe19..ab4b5384a9 100644 --- a/.github/workflows/healthcare-hl7v2.yaml +++ b/.github/workflows/healthcare-hl7v2.yaml @@ -11,7 +11,7 @@ on: pull_request_target: types: [labeled] schedule: - - cron: '0 2 * * *' + - cron: '0 0 * * 0' jobs: test: if: ${{ github.event.action != 'labeled' || github.event.label.name == 'actions:force-run' }} @@ -22,19 +22,23 @@ jobs: pull-requests: 'write' id-token: 'write' steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v3.1.0 with: ref: ${{github.event.pull_request.head.ref}} repository: ${{github.event.pull_request.head.repo.full_name}} +<<<<<<< HEAD + - uses: 'google-github-actions/auth@v0.8.3' +======= - uses: google-github-actions/auth@v1.0.0 +>>>>>>> main with: workload_identity_provider: 'projects/1046198160504/locations/global/workloadIdentityPools/github-actions-pool/providers/github-actions-provider' service_account: 'kokoro-system-test@long-door-651.iam.gserviceaccount.com' create_credentials_file: 'true' access_token_lifetime: 600s - - uses: actions/setup-node@v3 + - uses: actions/setup-node@v3.5.1 with: - node-version: 14 + node-version: 16 - run: npm install working-directory: healthcare/hl7v2 - run: npm test @@ -60,7 +64,7 @@ jobs: throw e; } } - - if: ${{ github.event_name == 'schedule' && always() }} + - if: ${{ github.event_name == 'schedule'}} run: | curl https://github.com/googleapis/repo-automation-bots/releases/download/flakybot-1.1.0/flakybot -o flakybot -s -L chmod +x ./flakybot diff --git a/.github/workflows/monitoring-opencensus.yaml b/.github/workflows/monitoring-opencensus.yaml index 4833097ef9..d1dd810236 100644 --- a/.github/workflows/monitoring-opencensus.yaml +++ b/.github/workflows/monitoring-opencensus.yaml @@ -11,7 +11,7 @@ on: pull_request_target: types: [labeled] schedule: - - cron: '0 2 * * *' + - cron: '0 0 * * 0' jobs: test: if: ${{ github.event.action != 'labeled' || github.event.label.name == 'actions:force-run' }} @@ -22,19 +22,23 @@ jobs: pull-requests: 'write' id-token: 'write' steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v3.1.0 with: ref: ${{github.event.pull_request.head.ref}} repository: ${{github.event.pull_request.head.repo.full_name}} +<<<<<<< HEAD + - uses: 'google-github-actions/auth@v0.8.3' +======= - uses: google-github-actions/auth@v1.0.0 +>>>>>>> main with: workload_identity_provider: 'projects/1046198160504/locations/global/workloadIdentityPools/github-actions-pool/providers/github-actions-provider' service_account: 'kokoro-system-test@long-door-651.iam.gserviceaccount.com' create_credentials_file: 'true' access_token_lifetime: 600s - - uses: actions/setup-node@v3 + - uses: actions/setup-node@v3.5.1 with: - node-version: 14 + node-version: 16 - run: npm install working-directory: monitoring/opencensus - run: npm test @@ -60,7 +64,7 @@ jobs: throw e; } } - - if: ${{ github.event_name == 'schedule' && always() }} + - if: ${{ github.event_name == 'schedule'}} run: | curl https://github.com/googleapis/repo-automation-bots/releases/download/flakybot-1.1.0/flakybot -o flakybot -s -L chmod +x ./flakybot diff --git a/.github/workflows/monitoring-prometheus.yaml b/.github/workflows/monitoring-prometheus.yaml index 9d2f61bb98..caec8907a9 100644 --- a/.github/workflows/monitoring-prometheus.yaml +++ b/.github/workflows/monitoring-prometheus.yaml @@ -11,7 +11,7 @@ on: pull_request_target: types: [labeled] schedule: - - cron: '0 2 * * *' + - cron: '0 0 * * 0' jobs: test: if: ${{ github.event.action != 'labeled' || github.event.label.name == 'actions:force-run' }} @@ -22,19 +22,23 @@ jobs: pull-requests: 'write' id-token: 'write' steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v3.1.0 with: ref: ${{github.event.pull_request.head.ref}} repository: ${{github.event.pull_request.head.repo.full_name}} +<<<<<<< HEAD + - uses: 'google-github-actions/auth@v0.8.3' +======= - uses: google-github-actions/auth@v1.0.0 +>>>>>>> main with: workload_identity_provider: 'projects/1046198160504/locations/global/workloadIdentityPools/github-actions-pool/providers/github-actions-provider' service_account: 'kokoro-system-test@long-door-651.iam.gserviceaccount.com' create_credentials_file: 'true' access_token_lifetime: 600s - - uses: actions/setup-node@v3 + - uses: actions/setup-node@v3.5.1 with: - node-version: 14 + node-version: 16 - run: npm install working-directory: monitoring/prometheus - run: npm test @@ -60,7 +64,7 @@ jobs: throw e; } } - - if: ${{ github.event_name == 'schedule' && always() }} + - if: ${{ github.event_name == 'schedule'}} run: | curl https://github.com/googleapis/repo-automation-bots/releases/download/flakybot-1.1.0/flakybot -o flakybot -s -L chmod +x ./flakybot diff --git a/game-servers/snippets/create_cluster.js b/game-servers/snippets/create_cluster.js new file mode 100644 index 0000000000..71b177fe07 --- /dev/null +++ b/game-servers/snippets/create_cluster.js @@ -0,0 +1,86 @@ +// Copyright 2020, Google LLC. +// 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. + +'use strict'; + +/** + * Create a Game Servers cluster. + * @param {string} projectId string project identifier + * @param {string} location Compute Engine region + * @param {string} realmId the realm to use + * @param {string} gameClusterId unique identifier for the new Game Cluster + * @param {string} gkeClusterName The full resource name of the GKE cluster to use + */ +async function main( + projectId = 'YOUR_PROJECT_ID', + location = 'LOCATION_ID', + realmId = 'REALM_ID', + gameClusterId = 'GAME_CLUSTER_ID', + gkeClusterName = 'GKE_CLUSTER_NAME' +) { + // [START cloud_game_servers_cluster_create] + const { + GameServerClustersServiceClient, + } = require('@google-cloud/game-servers'); + + const client = new GameServerClustersServiceClient(); + + async function createGameServerCluster() { + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + // const projectId = 'Your Google Cloud Project ID'; + // const location = 'A Compute Engine region, e.g. "us-central1"'; + // const realmId = 'The ID of the realm to locate this cluster in'; + // const gameClusterId = 'A unique ID for this Game Server Cluster'; + // const gkeClusterName= 'The full resource name of the GKE cluster to use'; + const request = { + // Provide full resource name of a Game Server Realm + parent: client.realmPath(projectId, location, realmId), + gameServerClusterId: gameClusterId, + gameServerCluster: { + description: 'My Game Server Cluster', + connectionInfo: { + gkeClusterReference: { + // Provide full resource name of a Kubernetes Engine cluster + // In the form of 'projects//locations//clusters/' + cluster: gkeClusterName, + }, + namespace: 'default', + }, + }, + }; + + const [operation] = await client.createGameServerCluster(request); + const [result] = await operation.promise(); + + console.log('Game Server Cluster created:'); + console.log(`\tCluster name: ${result.name}`); + console.log(`\tCluster description: ${result.description}`); + console.log( + `\tGKE cluster: ${result.connectionInfo.gkeClusterReference.cluster}` + ); + } + + createGameServerCluster(); + // [END cloud_game_servers_cluster_create] +} + +main(...process.argv.slice(2)).catch(err => { + console.error(err.message); + process.exitCode = 1; +}); +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); diff --git a/game-servers/snippets/create_config.js b/game-servers/snippets/create_config.js new file mode 100644 index 0000000000..db1b526157 --- /dev/null +++ b/game-servers/snippets/create_config.js @@ -0,0 +1,144 @@ +// Copyright 2020, Google LLC. +// 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. + +'use strict'; + +/** + * Create a Game Servers Config. + * @param {string} projectId string project identifier + * @param {string} deploymentId unique identifier for the parent Game Server Deployment + * @param {string} configId unique identifier for the new Game Server Config + * @param {string} fleetName fleet name to be stored in Agones + */ +async function main( + projectId = 'YOUR_PROJECT_ID', + deploymentId = 'DEPLOYMENT_ID', + configId = 'CONFIG_ID', + fleetName = 'FLEET_NAME' +) { + // [START cloud_game_servers_config_create] + const { + GameServerConfigsServiceClient, + } = require('@google-cloud/game-servers'); + + const client = new GameServerConfigsServiceClient(); + + async function createGameServerConfig() { + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + // const projectId = 'Your Google Cloud Project ID'; + // const deploymentId = 'A unique ID for the Game Server Deployment'; + // const configId = 'A unique ID for the Game Server Config'; + // const fleetName = 'The fleet name to be stored in Agones'; + // fleet is the spec portion of an agones Fleet. It must be in JSON format. + // See https://agones.dev/site/docs/reference/fleet/ for more on fleets. + const fleet = ` +{ + "replicas": 10, + "scheduling": "Packed", + "strategy": { + "type": "RollingUpdate", + "rollingUpdate": { + "maxSurge": "25%", + "maxUnavailable": "25%" + } + }, + "template": { + "metadata": { + "labels": { + "gameName": "udp-server" + } + }, + "spec": { + "ports": [ + { + "name": "default", + "portPolicy": "Dynamic", + "containerPort": 2156, + "protocol": "TCP" + } + ], + "health": { + "initialDelaySeconds": 30, + "periodSeconds": 60 + }, + "sdkServer": { + "logLevel": "Info", + "grpcPort": 9357, + "httpPort": 9358 + }, + "template": { + "spec": { + "containers": [ + { + "name": "dedicated", + "image": "gcr.io/agones-images/udp-server:0.17", + "imagePullPolicy": "Always", + "resources": { + "requests": { + "memory": "200Mi", + "cpu": "500m" + }, + "limits": { + "memory": "200Mi", + "cpu": "500m" + } + } + } + ] + } + } + } + } +} +`; + const request = { + parent: client.gameServerDeploymentPath( + projectId, + 'global', + deploymentId + ), + configId: configId, + gameServerConfig: { + fleetConfigs: [ + { + name: fleetName, + fleetSpec: fleet, + }, + ], + description: 'nodejs test config', + }, + }; + + const [operation] = await client.createGameServerConfig(request); + const [result] = await operation.promise(); + + console.log('Game Server Config created:'); + console.log(`\t Config name: ${result.name}`); + console.log(`\t Config description: ${result.description}`); + } + + createGameServerConfig(); + + // [END cloud_game_servers_config_create] +} + +main(...process.argv.slice(2)).catch(err => { + console.error(err.message); + process.exitCode = 1; +}); +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); diff --git a/game-servers/snippets/create_deployment.js b/game-servers/snippets/create_deployment.js new file mode 100644 index 0000000000..4b057352f7 --- /dev/null +++ b/game-servers/snippets/create_deployment.js @@ -0,0 +1,66 @@ +// Copyright 2020, Google LLC. +// 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. + +'use strict'; + +/** + * Create a Game Servers Deployment. + * @param {string} projectId string project identifier + * @param {string} deploymentId unique identifier for the new Game Server Deployment + */ +async function main( + projectId = 'YOUR_PROJECT_ID', + deploymentId = 'DEPLOYMENT_ID' +) { + // [START cloud_game_servers_deployment_create] + const { + GameServerDeploymentsServiceClient, + } = require('@google-cloud/game-servers'); + + const client = new GameServerDeploymentsServiceClient(); + + async function createGameServerDeployment() { + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + // const projectId = 'Your Google Cloud Project ID'; + // const deploymentId = 'A unique ID for the Game Server Deployment'; + const request = { + parent: `projects/${projectId}/locations/global`, + deploymentId: deploymentId, + gameServerDeployment: { + description: 'nodejs test deployment', + }, + }; + + const [operation] = await client.createGameServerDeployment(request); + const [result] = await operation.promise(); + + console.log('Game Server Deployment created:'); + console.log(`\t Deployment name: ${result.name}`); + console.log(`\t Deployment description: ${result.description}`); + } + + createGameServerDeployment(); + + // [END cloud_game_servers_deployment_create] +} + +main(...process.argv.slice(2)).catch(err => { + console.error(err.message); + process.exitCode = 1; +}); +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); diff --git a/game-servers/snippets/create_realm.js b/game-servers/snippets/create_realm.js new file mode 100644 index 0000000000..456de890f7 --- /dev/null +++ b/game-servers/snippets/create_realm.js @@ -0,0 +1,72 @@ +// Copyright 2020, Google LLC. +// 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. + +'use strict'; + +/** + * Create a Game Servers realm. + * @param {string} projectId string project identifier. + * @param {string} location Compute Engine region. + * @param {string} realmId a unique identifier for the new realm + */ +async function main( + projectId = 'YOUR_PROJECT_ID', + location = 'LOCATION_ID', + realmId = 'REALM_ID' +) { + // [START cloud_game_servers_realm_create] + const {RealmsServiceClient} = require('@google-cloud/game-servers'); + + const client = new RealmsServiceClient(); + + async function createRealm() { + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + // const projectId = 'Your Google Cloud Project ID'; + // const location = 'A Compute Engine region, e.g. "us-central1"'; + // const realmId = 'A unique identifier for the realm'; + const request = { + parent: `projects/${projectId}/locations/${location}`, + realmId: realmId, + realm: { + // Must use a supported time zone name. + // See https://cloud.google.com/dataprep/docs/html/Supported-Time-Zone-Values_66194188 + timeZone: 'US/Pacific', + description: 'My Game Server realm', + }, + }; + + const [operation] = await client.createRealm(request); + const results = await operation.promise(); + const [realm] = results; + + console.log('Realm created:'); + + console.log(`\tRealm name: ${realm.name}`); + console.log(`\tRealm description: ${realm.description}`); + console.log(`\tRealm time zone: ${realm.timeZone}`); + } + + createRealm(); + // [END cloud_game_servers_realm_create] +} + +main(...process.argv.slice(2)).catch(err => { + console.error(err.message); + process.exitCode = 1; +}); +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); diff --git a/game-servers/snippets/delete_cluster.js b/game-servers/snippets/delete_cluster.js new file mode 100644 index 0000000000..ec1266bc88 --- /dev/null +++ b/game-servers/snippets/delete_cluster.js @@ -0,0 +1,71 @@ +// Copyright 2020, Google LLC. +// 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. + +'use strict'; + +/** + * Delete a Game Server cluster + * @param {string} projectId string project identifier + * @param {string} location Compute Engine region + * @param {string} realmId the realm to use + * @param {string} gameClusterId the game cluster to delete + */ +async function main( + projectId = 'YOUR_PROJECT_ID', + location = 'LOCATION_ID', + realmId = 'REALM_ID', + gameClusterId = 'GAME_CLUSTER_ID' +) { + // [START cloud_game_servers_cluster_delete] + const { + GameServerClustersServiceClient, + } = require('@google-cloud/game-servers'); + + const client = new GameServerClustersServiceClient(); + + async function deleteGameServerCluster() { + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + // const projectId = 'Your Google Cloud Project ID'; + // const location = 'A Compute Engine region, e.g. "us-central1"'; + // const realmId = 'The ID of the realm to locate this cluster in'; + // const gameClusterId = 'The unique ID for this Game Server Cluster'; + const request = { + // Provide full resource name of a Game Server Realm + name: client.gameServerClusterPath( + projectId, + location, + realmId, + gameClusterId + ), + }; + + const [operation] = await client.deleteGameServerCluster(request); + await operation.promise(); + + console.log('Game Server cluster deleted'); + } + + deleteGameServerCluster(); + // [END cloud_game_servers_cluster_delete] +} + +main(...process.argv.slice(2)).catch(err => { + console.error(err.message); + process.exitCode = 1; +}); +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); diff --git a/game-servers/snippets/delete_config.js b/game-servers/snippets/delete_config.js new file mode 100644 index 0000000000..b083f29813 --- /dev/null +++ b/game-servers/snippets/delete_config.js @@ -0,0 +1,68 @@ +// Copyright 2020, Google LLC. +// 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. + +'use strict'; + +/** + * Delete a Game Servers Config. + * @param {string} projectId string project identifier + * @param {string} deploymentId unique identifier for the new Game Server Deployment + * @param {string} configId unique identifier for the new Game Server Config + */ +async function main( + projectId = 'YOUR_PROJECT_ID', + deploymentId = 'DEPLOYMENT_ID', + configId = 'CONFIG_ID' +) { + // [START cloud_game_servers_config_delete] + const { + GameServerConfigsServiceClient, + } = require('@google-cloud/game-servers'); + + const client = new GameServerConfigsServiceClient(); + + async function deleteGameServerConfig() { + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + // const projectId = 'Your Google Cloud Project ID'; + // const deploymentId = 'A unique ID for the Game Server Deployment'; + // const configId = 'A unique ID for the Game Server Config'; + const request = { + // The full resource name + name: client.gameServerConfigPath( + projectId, + 'global', + deploymentId, + configId + ), + }; + + const [operation] = await client.deleteGameServerConfig(request); + await operation.promise(); + console.log(`Config with name ${request.name} deleted.`); + } + + deleteGameServerConfig(); + + // [END cloud_game_servers_config_delete] +} + +main(...process.argv.slice(2)).catch(err => { + console.error(err.message); + process.exitCode = 1; +}); +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); diff --git a/game-servers/snippets/delete_deployment.js b/game-servers/snippets/delete_deployment.js new file mode 100644 index 0000000000..e45b144f50 --- /dev/null +++ b/game-servers/snippets/delete_deployment.js @@ -0,0 +1,61 @@ +// Copyright 2020, Google LLC. +// 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. + +'use strict'; + +/** + * Delete a Game Servers Deployment. + * @param {string} projectId string project identifier + * @param {string} deploymentId unique identifier for the new Game Server Deployment + */ +async function main( + projectId = 'YOUR_PROJECT_ID', + deploymentId = 'DEPLOYMENT_ID' +) { + // [START cloud_game_servers_deployment_delete] + const { + GameServerDeploymentsServiceClient, + } = require('@google-cloud/game-servers'); + + const client = new GameServerDeploymentsServiceClient(); + + async function deleteGameServerDeployment() { + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + // const projectId = 'Your Google Cloud Project ID'; + // const deploymentId = 'A unique ID for the Game Server Deployment'; + const request = { + // The full resource name + name: client.gameServerDeploymentPath(projectId, 'global', deploymentId), + }; + + const [operation] = await client.deleteGameServerDeployment(request); + await operation.promise(); + + console.log(`Deployment with name ${request.name} deleted.`); + } + + deleteGameServerDeployment(); + + // [END cloud_game_servers_deployment_delete] +} + +main(...process.argv.slice(2)).catch(err => { + console.error(err.message); + process.exitCode = 1; +}); +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); diff --git a/game-servers/snippets/delete_realm.js b/game-servers/snippets/delete_realm.js new file mode 100644 index 0000000000..da1f98ba19 --- /dev/null +++ b/game-servers/snippets/delete_realm.js @@ -0,0 +1,61 @@ +// Copyright 2020, Google LLC. +// 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. + +'use strict'; + +/** + * Delete a realm by ID + * @param {string} projectId string project identifier. + * @param {string} location Compute Engine region. + * @param {string} realmId the unique ID of the realm + */ +async function main( + projectId = 'YOUR_PROJECT_ID', + location = 'LOCATION_ID', + realmId = 'REALM_ID' +) { + // [START cloud_game_servers_realm_delete] + const {RealmsServiceClient} = require('@google-cloud/game-servers'); + + const client = new RealmsServiceClient(); + + async function deleteRealm() { + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + // const projectId = 'Your Google Cloud Project ID'; + // const location = 'A Compute Engine region, e.g. "us-central1"'; + // const realmId = 'Unique identifier of the realm'; + const request = { + // Realm name is the full resource name including project ID,location, + // and the realm ID. + name: client.realmPath(projectId, location, realmId), + }; + + const [operation] = await client.deleteRealm(request); + await operation.promise(); + console.log(`Realm with ID ${realmId} deleted.`); + } + + deleteRealm(); + // [END cloud_game_servers_realm_delete] +} + +main(...process.argv.slice(2)).catch(err => { + console.error(err.message); + process.exitCode = 1; +}); +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); diff --git a/game-servers/snippets/get_cluster.js b/game-servers/snippets/get_cluster.js new file mode 100644 index 0000000000..8701ac805b --- /dev/null +++ b/game-servers/snippets/get_cluster.js @@ -0,0 +1,85 @@ +// Copyright 2020, Google LLC. +// 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. + +'use strict'; + +/** + * Get a Game Server cluster + * @param {string} projectId string project identifier + * @param {string} location Compute Engine region + * @param {string} realmId the realm to use + * @param {string} gameClusterId the game cluster to get + */ +async function main( + projectId = 'YOUR_PROJECT_ID', + location = 'LOCATION_ID', + realmId = 'REALM_ID', + gameClusterId = 'GAME_CLUSTER_ID' +) { + // [START cloud_game_servers_cluster_get] + const { + GameServerClustersServiceClient, + } = require('@google-cloud/game-servers'); + + const client = new GameServerClustersServiceClient(); + + async function getGameServerCluster() { + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + // const projectId = 'Your Google Cloud Project ID'; + // const location = 'A Compute Engine region, e.g. "us-central1"'; + // const realmId = 'The ID of the realm to locate this cluster in'; + // const gameClusterId = 'The unique ID for this Game Server Cluster'; + const request = { + // Provide full resource name of a Game Server Realm + name: client.gameServerClusterPath( + projectId, + location, + realmId, + gameClusterId + ), + view: 'FULL', + }; + + const [cluster] = await client.getGameServerCluster(request); + + console.log('Game Server Cluster:'); + console.log(`\tCluster name: ${cluster.name}`); + console.log(`\tCluster description: ${cluster.description}`); + console.log( + `\tCluster installed Agones version: ${cluster.clusterState.agonesVersionInstalled}` + ); + console.log( + `\tCluster installed Kubernetes version: ${cluster.clusterState.kubernetesVersionInstalled}` + ); + console.log( + `\tCluster installation state: ${cluster.clusterState.installationState}` + ); + console.log( + `\tGKE cluster: ${cluster.connectionInfo.gkeClusterReference.cluster}` + ); + } + + getGameServerCluster(); + // [END cloud_game_servers_cluster_get] +} + +main(...process.argv.slice(2)).catch(err => { + console.error(err.message); + process.exitCode = 1; +}); +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); diff --git a/game-servers/snippets/get_config.js b/game-servers/snippets/get_config.js new file mode 100644 index 0000000000..1272918fec --- /dev/null +++ b/game-servers/snippets/get_config.js @@ -0,0 +1,72 @@ +// Copyright 2020, Google LLC. +// 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. + +'use strict'; + +/** + * Get a Game Servers Config. + * @param {string} projectId string project identifier + * @param {string} deploymentId unique identifier for the new Game Server Deployment + * @param {string} configId unique identifier for the new Game Server Config + */ +async function main( + projectId = 'YOUR_PROJECT_ID', + deploymentId = 'DEPLOYMENT_ID', + configId = 'CONFIG_ID' +) { + // [START cloud_game_servers_config_get] + const { + GameServerConfigsServiceClient, + } = require('@google-cloud/game-servers'); + + const client = new GameServerConfigsServiceClient(); + + async function getGameServerConfig() { + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + // const projectId = 'Your Google Cloud Project ID'; + // const deploymentId = 'A unique ID for the Game Server Deployment'; + // const configId = 'A unique ID for the Game Server Config'; + const request = { + // The full resource name + name: client.gameServerConfigPath( + projectId, + 'global', + deploymentId, + configId + ), + }; + + const [config] = await client.getGameServerConfig(request); + console.log(`Config name: ${config.name}`); + console.log(`Config description: ${config.description}`); + + const createTime = config.createTime; + const createDate = new Date(createTime.seconds * 1000); + console.log(`Config created on: ${createDate.toLocaleDateString()}\n`); + } + + getGameServerConfig(); + + // [END cloud_game_servers_config_get] +} + +main(...process.argv.slice(2)).catch(err => { + console.error(err.message); + process.exitCode = 1; +}); +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); diff --git a/game-servers/snippets/get_deployment.js b/game-servers/snippets/get_deployment.js new file mode 100644 index 0000000000..d1b65c936f --- /dev/null +++ b/game-servers/snippets/get_deployment.js @@ -0,0 +1,64 @@ +// Copyright 2020, Google LLC. +// 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. + +'use strict'; + +/** + * Get a Game Servers Deployment. + * @param {string} projectId string project identifier + * @param {string} deploymentId unique identifier for the new Game Server Deployment + */ +async function main( + projectId = 'YOUR_PROJECT_ID', + deploymentId = 'DEPLOYMENT_ID' +) { + // [START cloud_game_servers_deployment_get] + const { + GameServerDeploymentsServiceClient, + } = require('@google-cloud/game-servers'); + + const client = new GameServerDeploymentsServiceClient(); + + async function getGameServerDeployment() { + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + // const projectId = 'Your Google Cloud Project ID'; + // const deploymentId = 'A unique ID for the Game Server Deployment'; + const request = { + // The full resource name + name: client.gameServerDeploymentPath(projectId, 'global', deploymentId), + }; + + const [deployment] = await client.getGameServerDeployment(request); + console.log(`Deployment name: ${deployment.name}`); + console.log(`Deployment description: ${deployment.description}`); + + const createTime = deployment.createTime; + const createDate = new Date(createTime.seconds * 1000); + console.log(`Deployment created on: ${createDate.toLocaleDateString()}\n`); + } + + getGameServerDeployment(); + + // [END cloud_game_servers_deployment_get] +} + +main(...process.argv.slice(2)).catch(err => { + console.error(err.message); + process.exitCode = 1; +}); +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); diff --git a/game-servers/snippets/get_realm.js b/game-servers/snippets/get_realm.js new file mode 100644 index 0000000000..ae35dd99c0 --- /dev/null +++ b/game-servers/snippets/get_realm.js @@ -0,0 +1,66 @@ +// Copyright 2020, Google LLC. +// 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. + +'use strict'; + +/** + * Get a realm by ID + * @param {string} projectId string project identifier. + * @param {string} location Compute Engine region. + * @param {string} realmId the unique ID of the realm + */ +async function main( + projectId = 'YOUR_PROJECT_ID', + location = 'LOCATION_ID', + realmId = 'REALM_ID' +) { + // [START cloud_game_servers_realm_get] + const {RealmsServiceClient} = require('@google-cloud/game-servers'); + + const client = new RealmsServiceClient(); + + async function getRealm() { + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + // const projectId = 'Your Google Cloud Project ID'; + // const location = 'A Compute Engine region, e.g. "us-central1"'; + // const realmId = 'Unique identifier of the realm'; + const request = { + // Realm name is the full resource name including project ID and location + name: client.realmPath(projectId, location, realmId), + }; + + const [realm] = await client.getRealm(request); + console.log(`Realm name: ${realm.name}`); + console.log(`Realm description: ${realm.description}`); + console.log(`Realm time zone: ${realm.timeZone}`); + + const createTime = realm.createTime; + const createDate = new Date(createTime.seconds * 1000); + + console.log(`Realm created on: ${createDate.toLocaleDateString()}`); + } + + getRealm(); + // [END cloud_game_servers_realm_get] +} + +main(...process.argv.slice(2)).catch(err => { + console.error(err.message); + process.exitCode = 1; +}); +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); diff --git a/game-servers/snippets/get_rollout.js b/game-servers/snippets/get_rollout.js new file mode 100644 index 0000000000..72ba1ff80c --- /dev/null +++ b/game-servers/snippets/get_rollout.js @@ -0,0 +1,70 @@ +// Copyright 2020, Google LLC. +// 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. + +'use strict'; + +/** + * Get a Game Servers Rollout. + * @param {string} projectId string project identifier + * @param {string} deploymentId unique identifier for the new Game Server Deployment + */ +async function main( + projectId = 'YOUR_PROJECT_ID', + deploymentId = 'DEPLOYMENT_ID' +) { + // [START cloud_game_servers_rollout_get] + const { + GameServerDeploymentsServiceClient, + } = require('@google-cloud/game-servers'); + + const client = new GameServerDeploymentsServiceClient(); + + async function getGameServerDeploymentRollout() { + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + // const projectId = 'Your Google Cloud Project ID'; + // const deploymentId = 'A unique ID for the Game Server Deployment'; + const request = { + // The full resource name + name: client.gameServerDeploymentPath(projectId, 'global', deploymentId), + }; + + const [rollout] = await client.getGameServerDeploymentRollout(request); + console.log(`Rollout name: ${rollout.name}`); + console.log(`Rollout default: ${rollout.defaultGameServerConfig}`); + for (const override of rollout.gameServerConfigOverrides) { + console.log(`Rollout config overrides: ${override.configVersion}`); + console.log( + `Rollout realm overrides: ${JSON.stringify(override.realmsSelector)}` + ); + } + + const updateTime = rollout.updateTime; + const updateDate = new Date(updateTime.seconds * 1000); + console.log(`Rollout updated on: ${updateDate.toLocaleDateString()}\n`); + } + + getGameServerDeploymentRollout(); + + // [END cloud_game_servers_rollout_get] +} + +main(...process.argv.slice(2)).catch(err => { + console.error(err.message); + process.exitCode = 1; +}); +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); diff --git a/game-servers/snippets/list_clusters.js b/game-servers/snippets/list_clusters.js new file mode 100644 index 0000000000..c73a7f0d26 --- /dev/null +++ b/game-servers/snippets/list_clusters.js @@ -0,0 +1,80 @@ +// Copyright 2020, Google LLC. +// 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. + +'use strict'; + +/** + * List Game Server clusters + * @param {string} projectId string project identifier + * @param {string} location Compute Engine region + * @param {string} realmId the realm to use + */ +async function main( + projectId = 'YOUR_PROJECT_ID', + location = 'LOCATION_ID', + realmId = 'REALM_ID' +) { + // [START cloud_game_servers_cluster_list] + const { + GameServerClustersServiceClient, + } = require('@google-cloud/game-servers'); + + const client = new GameServerClustersServiceClient(); + + async function listGameServerClusters() { + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + // const projectId = 'Your Google Cloud Project ID'; + // const location = 'A Compute Engine region, e.g. "us-central1"'; + // const realmId = 'The ID of the realm to locate this cluster in'; + const request = { + // Provide full resource name of a Game Server Realm + parent: client.realmPath(projectId, location, realmId), + view: 'FULL', + }; + + const results = await client.listGameServerClusters(request); + const [clusters] = results; + + for (const cluster of clusters) { + console.log('Game Server Cluster:'); + console.log(`\tCluster name: ${cluster.name}`); + console.log(`\tCluster description: ${cluster.description}`); + console.log( + `\tCluster installed Agones version: ${cluster.clusterState.agonesVersionInstalled}` + ); + console.log( + `\tCluster installed Kubernetes version: ${cluster.clusterState.kubernetesVersionInstalled}` + ); + console.log( + `\tCluster installation state: ${cluster.clusterState.installationState}` + ); + console.log( + `\tGKE cluster: ${cluster.connectionInfo.gkeClusterReference.cluster}` + ); + } + } + + listGameServerClusters(); + // [END cloud_game_servers_cluster_list] +} + +main(...process.argv.slice(2)).catch(err => { + console.error(err.message); + process.exitCode = 1; +}); +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); diff --git a/game-servers/snippets/list_configs.js b/game-servers/snippets/list_configs.js new file mode 100644 index 0000000000..f6a844b50c --- /dev/null +++ b/game-servers/snippets/list_configs.js @@ -0,0 +1,69 @@ +// Copyright 2020, Google LLC. +// 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. + +'use strict'; + +/** + * List all the Game Servers Configs. + * @param {string} projectId string project identifier + * @param {string} deploymentId unique identifier for the new Game Server Deployment + */ +async function main( + projectId = 'YOUR_PROJECT_ID', + deploymentId = 'DEPLOYMENT_ID' +) { + // [START cloud_game_servers_config_list] + const { + GameServerConfigsServiceClient, + } = require('@google-cloud/game-servers'); + + const client = new GameServerConfigsServiceClient(); + + async function listGameServerConfigs() { + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + // const projectId = 'Your Google Cloud Project ID'; + // const deploymentId = 'A unique ID for the Game Server Deployment'; + const request = { + parent: client.gameServerDeploymentPath( + projectId, + 'global', + deploymentId + ), + }; + + const [results] = await client.listGameServerConfigs(request); + for (const config of results) { + console.log(`Config name: ${config.name}`); + console.log(`Config description: ${config.description}`); + + const createTime = config.createTime; + const createDate = new Date(createTime.seconds * 1000); + console.log(`Config created on: ${createDate.toLocaleDateString()}\n`); + } + } + + listGameServerConfigs(); + + // [END cloud_game_servers_config_list] +} + +main(...process.argv.slice(2)).catch(err => { + console.error(err.message); + process.exitCode = 1; +}); +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); diff --git a/game-servers/snippets/list_deployments.js b/game-servers/snippets/list_deployments.js new file mode 100644 index 0000000000..d79534ecd0 --- /dev/null +++ b/game-servers/snippets/list_deployments.js @@ -0,0 +1,62 @@ +// Copyright 2020, Google LLC. +// 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. + +'use strict'; + +/** + * List all the Game Servers Deployments. + * @param {string} projectId string project identifier + */ +async function main(projectId = 'YOUR_PROJECT_ID') { + // [START cloud_game_servers_deployment_list] + const { + GameServerDeploymentsServiceClient, + } = require('@google-cloud/game-servers'); + + const client = new GameServerDeploymentsServiceClient(); + + async function listGameServerDeployments() { + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + // const projectId = 'Your Google Cloud Project ID'; + const request = { + parent: `projects/${projectId}/locations/global`, + }; + + const [results] = await client.listGameServerDeployments(request); + for (const deployment of results) { + console.log(`Deployment name: ${deployment.name}`); + console.log(`Deployment description: ${deployment.description}`); + + const createTime = deployment.createTime; + const createDate = new Date(createTime.seconds * 1000); + console.log( + `Deployment created on: ${createDate.toLocaleDateString()}\n` + ); + } + } + + listGameServerDeployments(); + + // [END cloud_game_servers_deployment_list] +} + +main(...process.argv.slice(2)).catch(err => { + console.error(err.message); + process.exitCode = 1; +}); +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); diff --git a/game-servers/snippets/list_realms.js b/game-servers/snippets/list_realms.js new file mode 100644 index 0000000000..ded96df687 --- /dev/null +++ b/game-servers/snippets/list_realms.js @@ -0,0 +1,60 @@ +// Copyright 2020, Google LLC. +// 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. + +'use strict'; + +/** + * List all of the realms in a project. + * @param {string} projectId string project identifier. + * @param {string} location Compute Engine region. + */ +async function main(projectId = 'YOUR_PROJECT_ID', location = 'LOCATION_ID') { + // [START cloud_game_servers_realm_list] + const {RealmsServiceClient} = require('@google-cloud/game-servers'); + + const client = new RealmsServiceClient(); + + async function listRealms() { + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + // const projectId = 'Your Google Cloud Project ID'; + // const location = 'A Compute Engine region, e.g. "us-central1"'; + const request = { + parent: `projects/${projectId}/locations/${location}`, + }; + + const [results] = await client.listRealms(request); + for (const realm of results) { + console.log(`Realm name: ${realm.name}`); + console.log(`Realm description: ${realm.description}`); + console.log(`Realm time zone: ${realm.timeZone}`); + + const createTime = realm.createTime; + const createDate = new Date(createTime.seconds * 1000); + console.log(`Realm created on: ${createDate.toLocaleDateString()}\n`); + } + } + + listRealms(); + // [END cloud_game_servers_realm_list] +} + +main(...process.argv.slice(2)).catch(err => { + console.error(err.message); + process.exitCode = 1; +}); +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); diff --git a/game-servers/snippets/package.json b/game-servers/snippets/package.json new file mode 100644 index 0000000000..e9d4c3a6e8 --- /dev/null +++ b/game-servers/snippets/package.json @@ -0,0 +1,24 @@ +{ + "name": "nodejs-game-server-samples", + "private": true, + "license": "Apache-2.0", + "author": "Google LLC", + "engines": { + "node": ">=12.0.0" + }, + "files": [ + "*.js" + ], + "scripts": { + "test": "c8 mocha --timeout 600000 test/*.js" + }, + "dependencies": { + "@google-cloud/game-servers": "^3.1.2" + }, + "devDependencies": { + "c8": "^7.2.1", + "chai": "^4.2.0", + "mocha": "^8.0.0", + "uuid": "^9.0.0" + } +} diff --git a/game-servers/snippets/quickstart.js b/game-servers/snippets/quickstart.js new file mode 100644 index 0000000000..3a9c542322 --- /dev/null +++ b/game-servers/snippets/quickstart.js @@ -0,0 +1,67 @@ +// Copyright 2020, Google LLC. +// 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. + +'use strict'; + +// sample-metadata: +// title: Create Game Server Realm +// description: Creates a new Realm within Cloud Game Servers +// usage: node quickstart.js + +/** + * Create a Game Servers realm. + * @param {string} projectId string project identifier. + * @param {string} location Compute Engine region. + * @param {string} realmId unique identifier for the realm. + */ +async function main(projectId, location, realmId) { + // [START cloud_game_servers_quickstart] + const {RealmsServiceClient} = require('@google-cloud/game-servers'); + + async function quickstart() { + const client = new RealmsServiceClient(); + + // TODO(developer): uncomment the following section, and add values + // const projectId = 'YOUR_PROJECT_ID'; + // const location = 'us-central1; + // const realmId = 'DESIRED_REALM_ID'; + + const request = { + parent: `projects/${projectId}/locations/${location}`, + realmId, + realm: { + // Must use a valid support time zone. + // See https://cloud.google.com/dataprep/docs/html/Supported-Time-Zone-Values_66194188 + timeZone: 'US/Pacific', + description: 'My Game Server realm', + }, + }; + + const [operation] = await client.createRealm(request); + const results = await operation.promise(); + const [realm] = results; + + console.log('Realm created:'); + + console.log(`\tRealm name: ${realm.name}`); + console.log(`\tRealm description: ${realm.description}`); + console.log(`\tRealm time zone: ${realm.timeZone}`); + } + quickstart(); + // [END cloud_game_servers_quickstart] +} + +main(...process.argv.slice(2)).catch(err => { + console.error(err); + process.exitCode = 1; +}); diff --git a/game-servers/snippets/test/clean.js b/game-servers/snippets/test/clean.js new file mode 100644 index 0000000000..bed48b96ca --- /dev/null +++ b/game-servers/snippets/test/clean.js @@ -0,0 +1,71 @@ +// Copyright 2020 Google LLC +// +// 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 +// +// https://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. + +const {GameServerClustersServiceClient} = require('@google-cloud/game-servers'); +const {RealmsServiceClient} = require('@google-cloud/game-servers'); + +const gameServerClusterClient = new GameServerClustersServiceClient(); +const realmsClient = new RealmsServiceClient(); + +/** + * Utility function for removing unneeded realms from project. + */ +module.exports = async () => { + const projectId = await realmsClient.getProjectId(); + const location = 'us-central1'; + + const request = { + parent: `projects/${projectId}/locations/${location}`, + }; + + const MAX_REALM_LIFESPAN = 3600000; // One hour (in milliseconds) + const NOW = new Date(); + + const [results] = await realmsClient.listRealms(request); + for (const realm of results) { + // Check age of realm. If older than maximum life span, delete. + const ageOfRealm = new Date(realm.createTime.seconds * 1000); + if (NOW - ageOfRealm > MAX_REALM_LIFESPAN) { + // First, delete all clusters associated with this realm. + const clustersRequest = { + parent: realm.name, + }; + + const clustersResult = + await gameServerClusterClient.listGameServerClusters(clustersRequest); + const [clusters] = clustersResult; + for (const cluster of clusters) { + const deleteClusterRequest = { + name: cluster.name, + }; + + const [deleteClusterOperation] = + await gameServerClusterClient.deleteGameServerCluster( + deleteClusterRequest + ); + await deleteClusterOperation.promise(); + } + + // Then delete the realm itself. + const realmDeleteRequest = { + name: realm.name, + }; + + const [deleteRealmOperation] = await realmsClient.deleteRealm( + realmDeleteRequest + ); + await deleteRealmOperation.promise(); + } + } +}; diff --git a/game-servers/snippets/test/create_cluster.test.js b/game-servers/snippets/test/create_cluster.test.js new file mode 100644 index 0000000000..a13ea88e66 --- /dev/null +++ b/game-servers/snippets/test/create_cluster.test.js @@ -0,0 +1,91 @@ +// Copyright 2020 Google LLC +// +// 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 +// +// https://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. + +'use strict'; + +const {assert} = require('chai'); +const cleanup = require('./clean.js'); +const {describe, it, before, after} = require('mocha'); +const { + RealmsServiceClient, + GameServerClustersServiceClient, +} = require('@google-cloud/game-servers'); + +const cp = require('child_process'); +const uuid = require('uuid'); + +const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); + +const LOCATION = 'us-central1'; +const GKE_CLUSTER_NAME = + process.env.SAMPLE_CLUSTER_NAME || + 'projects/217093627905/locations/us-central1/clusters/gke-shared-default'; + +describe('Game Servers Create Cluster Test', () => { + const realmsClient = new RealmsServiceClient(); + const gameClustersClient = new GameServerClustersServiceClient(); + let realmId, gameClusterId; + + before(async () => { + await cleanup(); + + // Create a realm + const projectId = await realmsClient.getProjectId(); + realmId = `create-realm-${uuid.v4()}`; + gameClusterId = `test-${uuid.v4()}`; + + const request = { + parent: `projects/${projectId}/locations/${LOCATION}`, + realmId: realmId, + realm: { + timeZone: 'US/Pacific', + description: 'Test Game Server realm', + }, + }; + + const [operation] = await realmsClient.createRealm(request); + await operation.promise(); + }); + + it('should create a Game Server cluster', async () => { + const projectId = await realmsClient.getProjectId(); + gameClusterId = `test-${uuid.v4()}`; + + const create_output = execSync( + `node create_cluster.js ${projectId} ${LOCATION} ${realmId} ${gameClusterId} ${GKE_CLUSTER_NAME}` + ); + assert.match(create_output, /Cluster name:/); + }); + + after(async () => { + const projectId = await realmsClient.getProjectId(); + + // Delete the Game Server cluster + const deleteClusterRequest = { + // Provide full resource name of a Game Server Realm + name: `projects/${projectId}/locations/${LOCATION}/realms/${realmId}/gameServerClusters/${gameClusterId}`, + }; + const [operation1] = await gameClustersClient.deleteGameServerCluster( + deleteClusterRequest + ); + await operation1.promise(); + + // Delete the realm + const deleteRealmRequest = { + name: `projects/${projectId}/locations/${LOCATION}/realms/${realmId}`, + }; + const [operation2] = await realmsClient.deleteRealm(deleteRealmRequest); + await operation2.promise(); + }); +}); diff --git a/game-servers/snippets/test/create_realm.test.js b/game-servers/snippets/test/create_realm.test.js new file mode 100644 index 0000000000..93a49344e7 --- /dev/null +++ b/game-servers/snippets/test/create_realm.test.js @@ -0,0 +1,55 @@ +// Copyright 2020 Google LLC +// +// 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 +// +// https://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. + +'use strict'; + +const {assert} = require('chai'); +const cleanup = require('./clean.js'); +const {describe, before, it, after} = require('mocha'); +const {RealmsServiceClient} = require('@google-cloud/game-servers'); + +const cp = require('child_process'); +const uuid = require('uuid'); + +const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); + +const LOCATION = 'us-central1'; + +describe('Game Servers Create Realm Test', () => { + const client = new RealmsServiceClient(); + let realmId; + + before(async () => { + await cleanup(); + }); + + it('should create a realm', async () => { + const projectId = await client.getProjectId(); + realmId = `test-${uuid.v4()}`; + + const create_output = execSync( + `node create_realm.js ${projectId} ${LOCATION} ${realmId}` + ); + assert.match(create_output, /Realm time zone:/); + }); + + after(async () => { + const projectId = await client.getProjectId(); + const request = { + name: `projects/${projectId}/locations/${LOCATION}/realms/${realmId}`, + }; + const [operation] = await client.deleteRealm(request); + await operation.promise(); + }); +}); diff --git a/game-servers/snippets/test/crud_config.test.js b/game-servers/snippets/test/crud_config.test.js new file mode 100644 index 0000000000..d5c533c3d1 --- /dev/null +++ b/game-servers/snippets/test/crud_config.test.js @@ -0,0 +1,97 @@ +// Copyright 2020 Google LLC +// +// 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 +// +// https://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. + +'use strict'; + +const {assert} = require('chai'); +const cleanup = require('./clean.js'); +const {describe, before, after, it} = require('mocha'); +const { + GameServerConfigsServiceClient, + GameServerDeploymentsServiceClient, +} = require('@google-cloud/game-servers'); + +const cp = require('child_process'); +const uuid = require('uuid'); + +const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); + +describe('Game Server Config Test', () => { + const client = new GameServerConfigsServiceClient(); + const deploymentClient = new GameServerDeploymentsServiceClient(); + let deploymentId; + let configId; + let projectId; + + before(async () => { + await cleanup(); + + projectId = await client.getProjectId(); + deploymentId = `test-${uuid.v4()}`; + configId = `test-${uuid.v4()}`; + + const request = { + parent: `projects/${projectId}/locations/global`, + deploymentId: deploymentId, + }; + const [operation] = await deploymentClient.createGameServerDeployment( + request + ); + await operation.promise(); + }); + + it('should create a game server config', async () => { + const create_output = execSync( + `node create_config.js ${projectId} ${deploymentId} ${configId} nodejs_fleet_name` + ); + assert.match(create_output, /Config name:/); + }); + + it('should get a game server config', async () => { + const get_output = execSync( + `node get_config.js ${projectId} ${deploymentId} ${configId}` + ); + assert.match(get_output, /Config name:/); + }); + + it('should list a game server config', async () => { + const list_output = execSync( + `node list_configs.js ${projectId} ${deploymentId} ${configId}` + ); + assert.match(list_output, /Config name:/); + }); + + it('should delete a game server config', async () => { + const delete_output = execSync( + `node delete_config.js ${projectId} ${deploymentId} ${configId}` + ); + assert.match(delete_output, /deleted./); + }); + + after(async () => { + // Delete the Game Server Deployment + const request = { + // Provide full resource name of a Game Server Deployment + name: deploymentClient.gameServerDeploymentPath( + projectId, + 'global', + deploymentId + ), + }; + const [operation] = await deploymentClient.deleteGameServerDeployment( + request + ); + await operation.promise(); + }); +}); diff --git a/game-servers/snippets/test/crud_deployment.test.js b/game-servers/snippets/test/crud_deployment.test.js new file mode 100644 index 0000000000..5dd7218b30 --- /dev/null +++ b/game-servers/snippets/test/crud_deployment.test.js @@ -0,0 +1,79 @@ +// Copyright 2020 Google LLC +// +// 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 +// +// https://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. + +'use strict'; + +const {assert} = require('chai'); +const cleanup = require('./clean.js'); +const {describe, before, it} = require('mocha'); +const { + GameServerDeploymentsServiceClient, +} = require('@google-cloud/game-servers'); + +const cp = require('child_process'); +const uuid = require('uuid'); + +const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); + +describe('Game Server Deployment Test', () => { + const client = new GameServerDeploymentsServiceClient(); + let deploymentId; + let projectId; + + before(async () => { + projectId = await client.getProjectId(); + deploymentId = `test-${uuid.v4()}`; + + await cleanup(); + }); + + it('should create a game server deployment', async () => { + const create_output = execSync( + `node create_deployment.js ${projectId} ${deploymentId}` + ); + assert.match(create_output, /Deployment name:/); + }); + + it('should update a game server deployment', async () => { + const update_output = execSync( + `node update_deployment.js ${projectId} ${deploymentId}` + ); + assert.match(update_output, /Deployment updated:/); + }); + + it('should get a game server deployment', async () => { + const get_output = execSync( + `node get_deployment.js ${projectId} ${deploymentId}` + ); + assert.match(get_output, /Deployment name:/); + assert.match( + get_output, + /Deployment description: My updated Game Server deployment/ + ); + }); + + it('should list a game server deployment', async () => { + const list_output = execSync( + `node list_deployments.js ${projectId} ${deploymentId}` + ); + assert.match(list_output, /Deployment name:/); + }); + + it('should delete a game server deployment', async () => { + const delete_output = execSync( + `node delete_deployment.js ${projectId} ${deploymentId}` + ); + assert.match(delete_output, /deleted./); + }); +}); diff --git a/game-servers/snippets/test/delete_cluster.test.js b/game-servers/snippets/test/delete_cluster.test.js new file mode 100644 index 0000000000..d6b2003a41 --- /dev/null +++ b/game-servers/snippets/test/delete_cluster.test.js @@ -0,0 +1,97 @@ +// Copyright 2020 Google LLC +// +// 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 +// +// https://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. + +'use strict'; + +const {assert} = require('chai'); +const cleanup = require('./clean.js'); +const {describe, it, before, after} = require('mocha'); +const { + RealmsServiceClient, + GameServerClustersServiceClient, +} = require('@google-cloud/game-servers'); + +const cp = require('child_process'); +const uuid = require('uuid'); + +const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); + +const LOCATION = 'us-central1'; +const GKE_CLUSTER_NAME = + process.env.SAMPLE_CLUSTER_NAME || + 'projects/217093627905/locations/us-central1/clusters/gke-shared-default'; + +describe('Game Servers Delete Cluster Test', () => { + const realmsClient = new RealmsServiceClient(); + const gameClustersClient = new GameServerClustersServiceClient(); + let projectId, realmId, gameClusterId; + + before(async () => { + await cleanup(); + + // Create a realm + projectId = await realmsClient.getProjectId(); + realmId = `delete-realm-${uuid.v4()}`; + gameClusterId = `test-${uuid.v4()}`; + + const createRealmRequest = { + parent: `projects/${projectId}/locations/${LOCATION}`, + realmId: realmId, + realm: { + timeZone: 'US/Pacific', + description: 'Test Game Server realm', + }, + }; + + const [operation1] = await realmsClient.createRealm(createRealmRequest); + await operation1.promise(); + + // Create a cluster + const createClusterRequest = { + parent: `projects/${projectId}/locations/${LOCATION}/realms/${realmId}`, + gameServerClusterId: gameClusterId, + gameServerCluster: { + description: 'My Game Server Cluster', + connectionInfo: { + gkeClusterReference: { + // Provide full resource name of a Kubernetes Engine cluster + cluster: GKE_CLUSTER_NAME, + }, + namespace: 'default', + }, + }, + }; + + const [operation2] = await gameClustersClient.createGameServerCluster( + createClusterRequest + ); + await operation2.promise(); + }); + + it('should delete a Game Server cluster in a realm', async () => { + const create_output = execSync( + `node delete_cluster.js ${projectId} ${LOCATION} ${realmId} ${gameClusterId}` + ); + assert.match(create_output, /Game Server cluster deleted/); + }); + + after(async () => { + // Delete the realm + const deleteRealmRequest = { + name: `projects/${projectId}/locations/${LOCATION}/realms/${realmId}`, + }; + const [operation] = await realmsClient.deleteRealm(deleteRealmRequest); + await operation.promise(); + }); +}); diff --git a/game-servers/snippets/test/delete_realm.test.js b/game-servers/snippets/test/delete_realm.test.js new file mode 100644 index 0000000000..915aa83b8e --- /dev/null +++ b/game-servers/snippets/test/delete_realm.test.js @@ -0,0 +1,59 @@ +// Copyright 2020 Google LLC +// +// 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 +// +// https://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. + +'use strict'; + +const {assert} = require('chai'); +const cleanup = require('./clean.js'); +const {describe, it, before} = require('mocha'); +const {RealmsServiceClient} = require('@google-cloud/game-servers'); + +const cp = require('child_process'); +const uuid = require('uuid'); + +const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); + +const LOCATION = 'us-central1'; + +describe('Game Servers Delete Realm Test', () => { + const client = new RealmsServiceClient(); + let realmId; + + before(async () => { + const projectId = await client.getProjectId(); + + // Clean up any stray realms + await cleanup(); + + realmId = `test-${uuid.v4()}`; + + await client.createRealm({ + parent: `projects/${projectId}/locations/${LOCATION}`, + realmId: realmId, + realm: { + timeZone: 'US/Pacific', + description: 'Test Game Realm', + }, + }); + }); + + it('should delete a realm', async () => { + const projectId = await client.getProjectId(); + + const delete_output = execSync( + `node delete_realm.js ${projectId} ${LOCATION} ${realmId}` + ); + assert.match(delete_output, /deleted./); + }); +}); diff --git a/game-servers/snippets/test/get_cluster.test.js b/game-servers/snippets/test/get_cluster.test.js new file mode 100644 index 0000000000..d62765c3f5 --- /dev/null +++ b/game-servers/snippets/test/get_cluster.test.js @@ -0,0 +1,111 @@ +// Copyright 2020 Google LLC +// +// 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 +// +// https://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. + +'use strict'; + +const {assert} = require('chai'); +const cleanup = require('./clean.js'); +const {describe, it, before, after} = require('mocha'); +const { + RealmsServiceClient, + GameServerClustersServiceClient, +} = require('@google-cloud/game-servers'); + +const cp = require('child_process'); +const uuid = require('uuid'); + +const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); + +const LOCATION = 'us-central1'; +const GKE_CLUSTER_NAME = + process.env.SAMPLE_CLUSTER_NAME || + 'projects/217093627905/locations/us-central1/clusters/gke-shared-default'; + +describe('Game Servers Get Cluster Test', () => { + const realmsClient = new RealmsServiceClient(); + const gameClustersClient = new GameServerClustersServiceClient(); + let realmId, gameClusterId; + + before(async () => { + await cleanup(); + + // Create a realm + const projectId = await realmsClient.getProjectId(); + realmId = `get-realm-${uuid.v4()}`; + gameClusterId = `test-${uuid.v4()}`; + + const createRealmRequest = { + parent: `projects/${projectId}/locations/${LOCATION}`, + realmId: realmId, + realm: { + timeZone: 'US/Pacific', + description: 'Test Game Server realm', + }, + }; + + const [operation1] = await realmsClient.createRealm(createRealmRequest); + await operation1.promise(); + + // Create a cluster + const createClusterRequest = { + parent: `projects/${projectId}/locations/${LOCATION}/realms/${realmId}`, + gameServerClusterId: gameClusterId, + gameServerCluster: { + description: 'My Game Server Cluster', + connectionInfo: { + gkeClusterReference: { + // Provide full resource name of a Kubernetes Engine cluster + cluster: GKE_CLUSTER_NAME, + }, + namespace: 'default', + }, + }, + }; + + const [operation2] = await gameClustersClient.createGameServerCluster( + createClusterRequest + ); + await operation2.promise(); + }); + + it('should get a Game Server cluster in a realm', async () => { + const projectId = await realmsClient.getProjectId(); + + const create_output = execSync( + `node get_cluster.js ${projectId} ${LOCATION} ${realmId} ${gameClusterId}` + ); + assert.match(create_output, /Cluster name:/); + }); + + after(async () => { + const projectId = await realmsClient.getProjectId(); + + // Delete the Game Server cluster + const deleteClusterRequest = { + // Provide full resource name of a Game Server Realm + name: `projects/${projectId}/locations/${LOCATION}/realms/${realmId}/gameServerClusters/${gameClusterId}`, + }; + const [operation1] = await gameClustersClient.deleteGameServerCluster( + deleteClusterRequest + ); + await operation1.promise(); + + // Delete the realm + const deleteRealmRequest = { + name: `projects/${projectId}/locations/${LOCATION}/realms/${realmId}`, + }; + const [operation2] = await realmsClient.deleteRealm(deleteRealmRequest); + await operation2.promise(); + }); +}); diff --git a/game-servers/snippets/test/get_realm.test.js b/game-servers/snippets/test/get_realm.test.js new file mode 100644 index 0000000000..43b6ecb494 --- /dev/null +++ b/game-servers/snippets/test/get_realm.test.js @@ -0,0 +1,68 @@ +// Copyright 2020 Google LLC +// +// 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 +// +// https://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. + +'use strict'; + +const {assert} = require('chai'); +const cleanup = require('./clean.js'); +const {describe, it, before, after} = require('mocha'); +const {RealmsServiceClient} = require('@google-cloud/game-servers'); + +const cp = require('child_process'); +const uuid = require('uuid'); + +const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); + +const LOCATION = 'us-central1'; + +describe('Game Servers Get Realms Test', () => { + const client = new RealmsServiceClient(); + let realmId; + + before(async () => { + const projectId = await client.getProjectId(); + + // Clean up any stray realms + await cleanup(); + + realmId = `test-${uuid.v4()}`; + + await client.createRealm({ + parent: `projects/${projectId}/locations/${LOCATION}`, + realmId: realmId, + realm: { + timeZone: 'US/Pacific', + description: 'Test Game Realm', + }, + }); + }); + + it('should get a realm', async () => { + const projectId = await client.getProjectId(); + + const get_output = execSync( + `node get_realm.js ${projectId} ${LOCATION} ${realmId}` + ); + assert.match(get_output, /Realm description:/); + }); + + after(async () => { + const projectId = await client.getProjectId(); + const request = { + name: `projects/${projectId}/locations/${LOCATION}/realms/${realmId}`, + }; + const [operation] = await client.deleteRealm(request); + await operation.promise(); + }); +}); diff --git a/game-servers/snippets/test/list_clusters.test.js b/game-servers/snippets/test/list_clusters.test.js new file mode 100644 index 0000000000..b32b7ed245 --- /dev/null +++ b/game-servers/snippets/test/list_clusters.test.js @@ -0,0 +1,111 @@ +// Copyright 2020 Google LLC +// +// 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 +// +// https://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. + +'use strict'; + +const {assert} = require('chai'); +const cleanup = require('./clean.js'); +const {describe, it, before, after} = require('mocha'); +const { + RealmsServiceClient, + GameServerClustersServiceClient, +} = require('@google-cloud/game-servers'); + +const cp = require('child_process'); +const uuid = require('uuid'); + +const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); + +const LOCATION = 'us-central1'; +const GKE_CLUSTER_NAME = + process.env.SAMPLE_CLUSTER_NAME || + 'projects/217093627905/locations/us-central1/clusters/gke-shared-default'; + +describe('Game Servers List Clusters Test', () => { + const realmsClient = new RealmsServiceClient(); + const gameClustersClient = new GameServerClustersServiceClient(); + let realmId, gameClusterId; + + before(async () => { + await cleanup(); + + // Create a realm + const projectId = await realmsClient.getProjectId(); + realmId = `list-realm-${uuid.v4()}`; + gameClusterId = `test-${uuid.v4()}`; + + const createRealmRequest = { + parent: `projects/${projectId}/locations/${LOCATION}`, + realmId: realmId, + realm: { + timeZone: 'US/Pacific', + description: 'Test Game Server realm', + }, + }; + + const [operation1] = await realmsClient.createRealm(createRealmRequest); + await operation1.promise(); + + // Create a cluster + const createClusterRequest = { + parent: `projects/${projectId}/locations/${LOCATION}/realms/${realmId}`, + gameServerClusterId: gameClusterId, + gameServerCluster: { + description: 'My Game Server Cluster', + connectionInfo: { + gkeClusterReference: { + // Provide full resource name of a Kubernetes Engine cluster + cluster: GKE_CLUSTER_NAME, + }, + namespace: 'default', + }, + }, + }; + + const [operation2] = await gameClustersClient.createGameServerCluster( + createClusterRequest + ); + await operation2.promise(); + }); + + it('should list Game Server clusters in a realm', async () => { + const projectId = await realmsClient.getProjectId(); + + const create_output = execSync( + `node list_clusters.js ${projectId} ${LOCATION} ${realmId}` + ); + assert.match(create_output, /Cluster name:/); + }); + + after(async () => { + const projectId = await realmsClient.getProjectId(); + + // Delete the Game Server cluster + const deleteClusterRequest = { + // Provide full resource name of a Game Server Realm + name: `projects/${projectId}/locations/${LOCATION}/realms/${realmId}/gameServerClusters/${gameClusterId}`, + }; + const [operation1] = await gameClustersClient.deleteGameServerCluster( + deleteClusterRequest + ); + await operation1.promise(); + + // Delete the realm + const deleteRealmRequest = { + name: `projects/${projectId}/locations/${LOCATION}/realms/${realmId}`, + }; + const [operation2] = await realmsClient.deleteRealm(deleteRealmRequest); + await operation2.promise(); + }); +}); diff --git a/game-servers/snippets/test/list_realms.test.js b/game-servers/snippets/test/list_realms.test.js new file mode 100644 index 0000000000..574b6a5187 --- /dev/null +++ b/game-servers/snippets/test/list_realms.test.js @@ -0,0 +1,68 @@ +// Copyright 2020 Google LLC +// +// 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 +// +// https://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. + +'use strict'; + +const {assert} = require('chai'); +const cleanup = require('./clean.js'); +const {describe, it, before, after} = require('mocha'); +const {RealmsServiceClient} = require('@google-cloud/game-servers'); + +const cp = require('child_process'); +const uuid = require('uuid'); + +const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); + +const LOCATION = 'us-central1'; + +describe('Game Servers List Realms Test', () => { + const client = new RealmsServiceClient(); + let realmId; + + before(async () => { + const projectId = await client.getProjectId(); + + // Clean up any stray realms + await cleanup(); + + realmId = `test-${uuid.v4()}`; + + await client.createRealm({ + parent: `projects/${projectId}/locations/${LOCATION}`, + realmId: realmId, + realm: { + timeZone: 'US/Pacific', + description: 'Test Game Realm', + }, + }); + }); + + it('should list realms', async () => { + const projectId = await client.getProjectId(); + + const list_output = execSync( + `node list_realms.js ${projectId} ${LOCATION}` + ); + assert.match(list_output, /Realm name:/); + }); + + after(async () => { + const projectId = await client.getProjectId(); + const request = { + name: `projects/${projectId}/locations/${LOCATION}/realms/${realmId}`, + }; + const [operation] = await client.deleteRealm(request); + await operation.promise(); + }); +}); diff --git a/game-servers/snippets/test/quickstart.js b/game-servers/snippets/test/quickstart.js new file mode 100644 index 0000000000..e9faf4f075 --- /dev/null +++ b/game-servers/snippets/test/quickstart.js @@ -0,0 +1,53 @@ +// Copyright 2020 Google LLC +// +// 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +'use strict'; + +const {assert} = require('chai'); +const cp = require('child_process'); +const {describe, it, after, before} = require('mocha'); +const uuid = require('uuid'); +const {RealmsServiceClient} = require('@google-cloud/game-servers'); + +const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); + +describe('Quickstart', () => { + let projectId; + let client; + const location = 'us-central1'; + const realmId = `realm-${uuid.v4().split('-')[0]}`; + + before(async () => { + client = new RealmsServiceClient(); + projectId = await client.getProjectId(); + }); + + it('should run quickstart', async () => { + const stdout = execSync( + `node quickstart.js ${projectId} ${location} ${realmId}` + ); + assert.include(stdout, 'Realm created:'); + }); + + after(async () => { + const [operation] = await client.deleteRealm({ + name: client.realmPath(projectId, location, realmId), + }); + await operation.promise(); + }); +}); diff --git a/game-servers/snippets/test/quickstart.test.js b/game-servers/snippets/test/quickstart.test.js new file mode 100644 index 0000000000..8d370fa7d5 --- /dev/null +++ b/game-servers/snippets/test/quickstart.test.js @@ -0,0 +1,55 @@ +// Copyright 2020 Google LLC +// +// 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 +// +// https://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. + +'use strict'; + +const {assert} = require('chai'); +const cleanup = require('./clean.js'); +const {describe, it, before, after} = require('mocha'); +const {RealmsServiceClient} = require('@google-cloud/game-servers'); + +const cp = require('child_process'); +const uuid = require('uuid'); + +const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); + +const LOCATION = 'us-central1'; + +describe('Game Servers Quickstart Test', () => { + const client = new RealmsServiceClient(); + let realmId; + + before(async () => { + await cleanup(); + }); + + it('should create a realm', async () => { + const projectId = await client.getProjectId(); + realmId = `test-${uuid.v4()}`; + + const quickstart_output = execSync( + `node quickstart.js ${projectId} ${LOCATION} ${realmId}` + ); + assert.match(quickstart_output, /Realm time zone:/); + }); + + after(async () => { + const projectId = await client.getProjectId(); + const request = { + name: `projects/${projectId}/locations/${LOCATION}/realms/${realmId}`, + }; + const [operation] = await client.deleteRealm(request); + await operation.promise(); + }); +}); diff --git a/game-servers/snippets/test/rollout.js b/game-servers/snippets/test/rollout.js new file mode 100644 index 0000000000..c2bbb53c35 --- /dev/null +++ b/game-servers/snippets/test/rollout.js @@ -0,0 +1,216 @@ +// Copyright 2020 Google LLC +// +// 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 +// +// https://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. + +'use strict'; + +const {assert} = require('chai'); +const cleanup = require('./clean.js'); +const {describe, before, after, it} = require('mocha'); +const { + GameServerConfigsServiceClient, + GameServerDeploymentsServiceClient, + RealmsServiceClient, +} = require('@google-cloud/game-servers'); + +const cp = require('child_process'); +const uuid = require('uuid'); + +const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); + +describe('Game Server Rollout Test', () => { + const configClient = new GameServerConfigsServiceClient(); + const deploymentClient = new GameServerDeploymentsServiceClient(); + const realmClient = new RealmsServiceClient(); + let projectId; + const deploymentId = `test-nodejs-${uuid.v4()}`; + const configId = `test-nodejs-${uuid.v4()}`; + const realmId = `test-nodejs-${uuid.v4()}`; + const realmLocation = 'us-central1'; + + before(async () => { + await cleanup(); + + projectId = await deploymentClient.getProjectId(); + + const request = { + parent: `projects/${projectId}/locations/global`, + deploymentId: deploymentId, + }; + const [operation] = await deploymentClient.createGameServerDeployment( + request + ); + await operation.promise(); + + const request2 = { + parent: configClient.gameServerDeploymentPath( + projectId, + 'global', + deploymentId + ), + configId: configId, + }; + const [operation2] = await configClient.createGameServerConfig(request2); + await operation2.promise(); + + const request3 = { + parent: `projects/${projectId}/locations/${realmLocation}`, + realmId: realmId, + realm: { + timeZone: 'US/Pacific', + description: 'Test Game Server realm', + }, + }; + + const [operation3] = await realmClient.createRealm(request3); + await operation3.promise(); + }); + + it('should update rollout default', async () => { + const updateDefaultOutput = execSync( + `node update_rollout_default.js ${projectId} ${deploymentId} ${configId}` + ); + + assert.match(updateDefaultOutput, /Deployment updated:/); + + const getRolloutOutput = execSync( + `node get_rollout.js ${projectId} ${deploymentId} ${configId}` + ); + + const configName = configClient.gameServerConfigPath( + projectId, + 'global', + deploymentId, + configId + ); + assert.match(getRolloutOutput, /Rollout name:/); + assert.match( + getRolloutOutput, + new RegExp(`Rollout default: ${configName}`) + ); + }); + + it('should remove rollout default', async () => { + const removeDefaultOutput = execSync( + `node update_rollout_remove_default.js ${projectId} ${deploymentId} ${configId}` + ); + + assert.match(removeDefaultOutput, /Deployment updated:/); + + const request = { + // The full resource name + name: deploymentClient.gameServerDeploymentPath( + projectId, + 'global', + deploymentId + ), + }; + + const [rollout] = await deploymentClient.getGameServerDeploymentRollout( + request + ); + assert.strictEqual(rollout.defaultGameServerConfig, ''); + }); + + it('should update rollout override', async () => { + const updateOverrideOutput = execSync( + `node update_rollout_override.js ${projectId} ${deploymentId} ${configId} ${realmId} ${realmLocation}` + ); + assert.match(updateOverrideOutput, /Deployment updated:/); + + const getRolloutOutput = execSync( + `node get_rollout.js ${projectId} ${deploymentId} ${configId}` + ); + + const configName = configClient.gameServerConfigPath( + projectId, + 'global', + deploymentId, + configId + ); + const realmName = realmClient.realmPath(projectId, realmLocation, realmId); + assert.match( + getRolloutOutput, + new RegExp(`Rollout config overrides: .*${configName}`) + ); + assert.match(getRolloutOutput, new RegExp(realmName)); + }); + + it('should remove rollout override', async () => { + const removeOverrideOutput = execSync( + `node update_rollout_remove_override.js ${projectId} ${deploymentId}` + ); + + assert.match(removeOverrideOutput, /Deployment updated:/); + + const request = { + // The full resource name + name: deploymentClient.gameServerDeploymentPath( + projectId, + 'global', + deploymentId + ), + }; + + let rollout; + try { + [rollout] = await deploymentClient.getGameServerDeploymentRollout( + request + ); + } catch (err) { + if (err.message.includes(/The service is currently unavailable/)) { + return; + } + throw err; + } + + assert.strictEqual(rollout.gameServerConfigOverrides.length, 0); + }); + + after(async () => { + // Delete the Game Server Config + const request = { + // Provide full resource name of a Game Server Config + name: configClient.gameServerConfigPath( + projectId, + 'global', + deploymentId, + configId + ), + }; + const [operation] = await configClient.deleteGameServerConfig(request); + await operation.promise(); + + // Delete the Game Server Deployment + const request2 = { + // Provide full resource name of a Game Server Deployment + name: deploymentClient.gameServerDeploymentPath( + projectId, + 'global', + deploymentId + ), + }; + const [operation2] = await deploymentClient.deleteGameServerDeployment( + request2 + ); + await operation2.promise(); + + // Delete the Realm + const request3 = { + // Provide full resource name of a Realm + name: realmClient.realmPath(projectId, realmLocation, realmId), + }; + const [operation3] = await realmClient.deleteRealm(request3); + await operation3.promise(); + }); +}); diff --git a/game-servers/snippets/test/update_cluster_test.js b/game-servers/snippets/test/update_cluster_test.js new file mode 100644 index 0000000000..7eadb4b428 --- /dev/null +++ b/game-servers/snippets/test/update_cluster_test.js @@ -0,0 +1,115 @@ +// Copyright 2021 Google LLC +// +// 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 +// +// https://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. + +'use strict'; + +const {assert} = require('chai'); +const cleanup = require('./clean.js'); +const {describe, it, before, after} = require('mocha'); +const { + RealmsServiceClient, + GameServerClustersServiceClient, +} = require('@google-cloud/game-servers'); + +const cp = require('child_process'); +const uuid = require('uuid'); + +const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); + +const LOCATION = 'us-central1'; +const GKE_CLUSTER_NAME = + process.env.SAMPLE_CLUSTER_NAME || + 'projects/217093627905/locations/us-central1/clusters/gke-shared-default'; + +describe('Game Servers Update Cluster Test', () => { + const realmsClient = new RealmsServiceClient(); + const gameClustersClient = new GameServerClustersServiceClient(); + let realmId, gameClusterId, projectId; + + before(async () => { + await cleanup(); + + // Create a realm + projectId = await realmsClient.getProjectId(); + realmId = `update-realm-${uuid.v4()}`; + gameClusterId = `test-${uuid.v4()}`; + + const createRealmRequest = { + parent: `projects/${projectId}/locations/${LOCATION}`, + realmId: realmId, + realm: { + timeZone: 'US/Pacific', + description: 'Test Game Server realm', + }, + }; + + const [operation1] = await realmsClient.createRealm(createRealmRequest); + await operation1.promise(); + + // Create a cluster + const createClusterRequest = { + parent: `projects/${projectId}/locations/${LOCATION}/realms/${realmId}`, + gameServerClusterId: gameClusterId, + gameServerCluster: { + description: 'My Game Server Cluster', + connectionInfo: { + gkeClusterReference: { + // Provide full resource name of a Kubernetes Engine cluster + cluster: GKE_CLUSTER_NAME, + }, + namespace: 'default', + }, + }, + }; + + const [operation2] = await gameClustersClient.createGameServerCluster( + createClusterRequest + ); + await operation2.promise(); + }); + + it('should update a Game Server cluster in a realm', async () => { + const update_output = execSync( + `node update_cluster.js ${projectId} ${LOCATION} ${realmId} ${gameClusterId}` + ); + assert.match(update_output, /Cluster updated:/); + + const get_output = execSync( + `node get_cluster.js ${projectId} ${LOCATION} ${realmId} ${gameClusterId}` + ); + assert.match( + get_output, + /Cluster description: My updated Game Server Cluster/ + ); + }); + + after(async () => { + // Delete the Game Server cluster + const deleteClusterRequest = { + // Provide full resource name of a Game Server Realm + name: `projects/${projectId}/locations/${LOCATION}/realms/${realmId}/gameServerClusters/${gameClusterId}`, + }; + const [operation1] = await gameClustersClient.deleteGameServerCluster( + deleteClusterRequest + ); + await operation1.promise(); + + // Delete the realm + const deleteRealmRequest = { + name: `projects/${projectId}/locations/${LOCATION}/realms/${realmId}`, + }; + const [operation2] = await realmsClient.deleteRealm(deleteRealmRequest); + await operation2.promise(); + }); +}); diff --git a/game-servers/snippets/test/update_realm_test.js b/game-servers/snippets/test/update_realm_test.js new file mode 100644 index 0000000000..f55ae28291 --- /dev/null +++ b/game-servers/snippets/test/update_realm_test.js @@ -0,0 +1,70 @@ +// Copyright 2021 Google LLC +// +// 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 +// +// https://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. + +'use strict'; + +const {assert} = require('chai'); +const cleanup = require('./clean.js'); +const {describe, it, before, after} = require('mocha'); +const {RealmsServiceClient} = require('@google-cloud/game-servers'); + +const cp = require('child_process'); +const uuid = require('uuid'); + +const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); + +const LOCATION = 'us-central1'; + +describe('Game Servers Update Realms Test', () => { + const client = new RealmsServiceClient(); + let realmId, projectId; + + before(async () => { + projectId = await client.getProjectId(); + + // Clean up any stray realms + await cleanup(); + + realmId = `test-${uuid.v4()}`; + + await client.createRealm({ + parent: `projects/${projectId}/locations/${LOCATION}`, + realmId: realmId, + realm: { + timeZone: 'US/Pacific', + description: 'Test Game Realm', + }, + }); + }); + + it('should update a realm', async () => { + const update_output = execSync( + `node update_realm.js ${projectId} ${LOCATION} ${realmId}` + ); + assert.match(update_output, /Realm updated:/); + + const get_output = execSync( + `node get_realm.js ${projectId} ${LOCATION} ${realmId}` + ); + assert.match(get_output, /Realm description: My updated Game Server realm/); + }); + + after(async () => { + const request = { + name: `projects/${projectId}/locations/${LOCATION}/realms/${realmId}`, + }; + const [operation] = await client.deleteRealm(request); + await operation.promise(); + }); +}); diff --git a/game-servers/snippets/update_cluster.js b/game-servers/snippets/update_cluster.js new file mode 100644 index 0000000000..b07342fc39 --- /dev/null +++ b/game-servers/snippets/update_cluster.js @@ -0,0 +1,80 @@ +// Copyright 2021, Google LLC. +// 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. + +'use strict'; + +/** + * Update a Game Servers cluster. + * @param {string} projectId string project identifier + * @param {string} location Compute Engine region for the realm + * @param {string} realmId the realm to use + * @param {string} gameClusterId unique identifier for the Game Cluster + */ +async function main( + projectId = 'YOUR_PROJECT_ID', + location = 'LOCATION_ID', + realmId = 'REALM_ID', + gameClusterId = 'GAME_CLUSTER_ID' +) { + // [START cloud_game_servers_cluster_update] + const { + GameServerClustersServiceClient, + } = require('@google-cloud/game-servers'); + + const client = new GameServerClustersServiceClient(); + + async function updateGameServerCluster() { + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + // const projectId = 'Your Google Cloud Project ID'; + // const location = 'A Compute Engine region, e.g. "us-central1"'; + // const realmId = 'The ID of the realm of this cluster'; + // const gameClusterId = 'A unique ID for this Game Server Cluster'; + const request = { + // Provide full resource name of a Game Server Cluster + gameServerCluster: { + name: client.gameServerClusterPath( + projectId, + location, + realmId, + gameClusterId + ), + labels: { + 'label-key-1': 'label-value-1', + }, + description: 'My updated Game Server Cluster', + }, + updateMask: { + paths: ['labels', 'description'], + }, + }; + + const [operation] = await client.updateGameServerCluster(request); + const [result] = await operation.promise(); + + console.log(`Cluster updated: ${result.name}`); + } + + updateGameServerCluster(); + // [END cloud_game_servers_cluster_update] +} + +main(...process.argv.slice(2)).catch(err => { + console.error(err.message); + process.exitCode = 1; +}); +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); diff --git a/game-servers/snippets/update_deployment.js b/game-servers/snippets/update_deployment.js new file mode 100644 index 0000000000..dde260eacf --- /dev/null +++ b/game-servers/snippets/update_deployment.js @@ -0,0 +1,73 @@ +// Copyright 2021, Google LLC. +// 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. + +'use strict'; + +/** + * Update a Game Servers Deployment. + * @param {string} projectId string project identifier + * @param {string} deploymentId unique identifier for the Game Server Deployment + */ +async function main( + projectId = 'YOUR_PROJECT_ID', + deploymentId = 'DEPLOYMENT_ID' +) { + // [START cloud_game_servers_deployment_update] + const { + GameServerDeploymentsServiceClient, + } = require('@google-cloud/game-servers'); + + const client = new GameServerDeploymentsServiceClient(); + + async function updateGameServerDeployment() { + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + // const projectId = 'Your Google Cloud Project ID'; + // const deploymentId = 'The unique ID for the Game Server Deployment'; + const request = { + gameServerDeployment: { + name: client.gameServerDeploymentPath( + projectId, + 'global', + deploymentId + ), + labels: { + 'label-key-1': 'label-value-1', + }, + description: 'My updated Game Server deployment', + }, + updateMask: { + paths: ['labels', 'description'], + }, + }; + + const [operation] = await client.updateGameServerDeployment(request); + const [result] = await operation.promise(); + + console.log(`Deployment updated: ${result.name}`); + } + + updateGameServerDeployment(); + + // [END cloud_game_servers_deployment_update] +} + +main(...process.argv.slice(2)).catch(err => { + console.error(err.message); + process.exitCode = 1; +}); +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); diff --git a/game-servers/snippets/update_realm.js b/game-servers/snippets/update_realm.js new file mode 100644 index 0000000000..ffdd19a817 --- /dev/null +++ b/game-servers/snippets/update_realm.js @@ -0,0 +1,71 @@ +// Copyright 2021, Google LLC. +// 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. + +'use strict'; + +/** + * Update a Game Servers realm. + * @param {string} projectId string project identifier. + * @param {string} location Compute Engine region. + * @param {string} realmId unique identifier for the realm + */ +async function main( + projectId = 'YOUR_PROJECT_ID', + location = 'LOCATION_ID', + realmId = 'REALM_ID' +) { + // [START cloud_game_servers_realm_update] + const {RealmsServiceClient} = require('@google-cloud/game-servers'); + + const client = new RealmsServiceClient(); + + async function updateRealm() { + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + // const projectId = 'Your Google Cloud Project ID'; + // const location = 'A Compute Engine region, e.g. "us-central1"'; + // const realmId = 'The unique identifier for the realm'; + const request = { + realm: { + name: client.realmPath(projectId, location, realmId), + labels: { + 'label-key-1': 'label-value-1', + }, + timeZone: 'US/Pacific', + description: 'My updated Game Server realm', + }, + updateMask: { + paths: ['labels', 'time_zone', 'description'], + }, + }; + + const [operation] = await client.updateRealm(request); + const results = await operation.promise(); + const [realm] = results; + + console.log(`Realm updated: ${realm.name}`); + } + + updateRealm(); + // [END cloud_game_servers_realm_update] +} + +main(...process.argv.slice(2)).catch(err => { + console.error(err.message); + process.exitCode = 1; +}); +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); diff --git a/game-servers/snippets/update_rollout_default.js b/game-servers/snippets/update_rollout_default.js new file mode 100644 index 0000000000..1aa9edf372 --- /dev/null +++ b/game-servers/snippets/update_rollout_default.js @@ -0,0 +1,73 @@ +// Copyright 2020, Google LLC. +// 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. + +'use strict'; + +/** + * Rollout update to add default config. + * @param {string} projectId string project identifier + * @param {string} deploymentId unique identifier for the new Game Server Deployment + * @param {string} configId unique identifier for the new Game Server Config + */ +async function main( + projectId = 'YOUR_PROJECT_ID', + deploymentId = 'DEPLOYMENT_ID', + configId = 'CONFIG_ID' +) { + // [START cloud_game_servers_deployment_rollout_default] + const { + GameServerDeploymentsServiceClient, + } = require('@google-cloud/game-servers'); + + const client = new GameServerDeploymentsServiceClient(); + + async function rolloutDefaultGameServerDeployment() { + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + // const projectId = 'Your Google Cloud Project ID'; + // const deploymentId = 'A unique ID for the Game Server Deployment'; + // const configId = 'A unique ID for the Game Server Config'; + const request = { + rollout: { + name: client.gameServerDeploymentPath( + projectId, + 'global', + deploymentId + ), + defaultGameServerConfig: configId, + }, + updateMask: { + paths: ['default_game_server_config'], + }, + }; + + const [operation] = await client.updateGameServerDeploymentRollout(request); + const [deployment] = await operation.promise(); + + console.log(`Deployment updated: ${deployment.name}`); + } + + rolloutDefaultGameServerDeployment(); + + // [END cloud_game_servers_deployment_rollout_default] +} + +main(...process.argv.slice(2)).catch(err => { + console.error(err.message); + process.exitCode = 1; +}); +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); diff --git a/game-servers/snippets/update_rollout_override.js b/game-servers/snippets/update_rollout_override.js new file mode 100644 index 0000000000..ee27d4b738 --- /dev/null +++ b/game-servers/snippets/update_rollout_override.js @@ -0,0 +1,86 @@ +// Copyright 2020, Google LLC. +// 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. + +'use strict'; + +/** + * Rollout update to add override config. + * @param {string} projectId string project identifier + * @param {string} deploymentId unique identifier for the new Game Server Deployment + * @param {string} configId unique identifier for the new Game Server Config + * @param {string} realmId the unique ID of the realm + * @param {string} realmLocation Compute Engine region for realm location. + */ +async function main( + projectId = 'YOUR_PROJECT_ID', + deploymentId = 'DEPLOYMENT_ID', + configId = 'CONFIG_ID', + realmId = 'REALM_ID', + realmLocation = 'REALM_LOCATION' +) { + // [START cloud_game_servers_deployment_rollout_override] + const { + GameServerDeploymentsServiceClient, + } = require('@google-cloud/game-servers'); + + const client = new GameServerDeploymentsServiceClient(); + + async function rolloutGameServerDeploymentOverride() { + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + // const projectId = 'Your Google Cloud Project ID'; + // const deploymentId = 'A unique ID for the Game Server Deployment'; + // const configId = 'A unique ID for the Game Server Config'; + // const realmId = 'A unique ID for the realm' + // const realmLocation = 'compute engine region for realm location' + const request = { + rollout: { + name: client.gameServerDeploymentPath( + projectId, + 'global', + deploymentId + ), + gameServerConfigOverrides: [ + { + realmsSelector: { + realms: [client.realmPath(projectId, realmLocation, realmId)], + }, + configVersion: configId, + }, + ], + }, + updateMask: { + paths: ['game_server_config_overrides'], + }, + }; + + const [operation] = await client.updateGameServerDeploymentRollout(request); + const [deployment] = await operation.promise(); + + console.log(`Deployment updated: ${deployment.name}`); + } + + rolloutGameServerDeploymentOverride(); + + // [END cloud_game_servers_deployment_rollout_override] +} + +main(...process.argv.slice(2)).catch(err => { + console.error(err.message); + process.exitCode = 1; +}); +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); diff --git a/game-servers/snippets/update_rollout_remove_default.js b/game-servers/snippets/update_rollout_remove_default.js new file mode 100644 index 0000000000..7584a00bfc --- /dev/null +++ b/game-servers/snippets/update_rollout_remove_default.js @@ -0,0 +1,70 @@ +// Copyright 2020, Google LLC. +// 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. + +'use strict'; + +/** + * Rollout update to remove default config. + * @param {string} projectId string project identifier + * @param {string} deploymentId unique identifier for the new Game Server Deployment + */ +async function main( + projectId = 'YOUR_PROJECT_ID', + deploymentId = 'DEPLOYMENT_ID' +) { + // [START cloud_game_servers_deployment_rollout_remove_default] + const { + GameServerDeploymentsServiceClient, + } = require('@google-cloud/game-servers'); + + const client = new GameServerDeploymentsServiceClient(); + + async function removeRolloutDefaultGameServerDeployment() { + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + // const projectId = 'Your Google Cloud Project ID'; + // const deploymentId = 'A unique ID for the Game Server Deployment'; + const request = { + rollout: { + name: client.gameServerDeploymentPath( + projectId, + 'global', + deploymentId + ), + defaultGameServerConfig: '', + }, + updateMask: { + paths: ['default_game_server_config'], + }, + }; + + const [operation] = await client.updateGameServerDeploymentRollout(request); + const [deployment] = await operation.promise(); + + console.log(`Deployment updated: ${deployment.name}`); + } + + removeRolloutDefaultGameServerDeployment(); + + // [END cloud_game_servers_deployment_rollout_remove_default] +} + +main(...process.argv.slice(2)).catch(err => { + console.error(err.message); + process.exitCode = 1; +}); +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); diff --git a/game-servers/snippets/update_rollout_remove_override.js b/game-servers/snippets/update_rollout_remove_override.js new file mode 100644 index 0000000000..031e950c01 --- /dev/null +++ b/game-servers/snippets/update_rollout_remove_override.js @@ -0,0 +1,69 @@ +// Copyright 2020, Google LLC. +// 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. + +'use strict'; + +/** + * Rollout update to remove override config. + * @param {string} projectId string project identifier + * @param {string} deploymentId unique identifier for the new Game Server Deployment + */ +async function main( + projectId = 'YOUR_PROJECT_ID', + deploymentId = 'DEPLOYMENT_ID' +) { + // [START cloud_game_servers_deployment_rollout_remove_override] + const { + GameServerDeploymentsServiceClient, + } = require('@google-cloud/game-servers'); + + const client = new GameServerDeploymentsServiceClient(); + + async function removeRolloutGameServerDeploymentOverride() { + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + // const projectId = 'Your Google Cloud Project ID'; + // const deploymentId = 'A unique ID for the Game Server Deployment'; + const request = { + rollout: { + name: client.gameServerDeploymentPath( + projectId, + 'global', + deploymentId + ), + }, + updateMask: { + paths: ['game_server_config_overrides'], + }, + }; + + const [operation] = await client.updateGameServerDeploymentRollout(request); + const [deployment] = await operation.promise(); + + console.log(`Deployment updated: ${deployment.name}`); + } + + removeRolloutGameServerDeploymentOverride(); + + // [END cloud_game_servers_deployment_rollout_remove_override] +} + +main(...process.argv.slice(2)).catch(err => { + console.error(err.message); + process.exitCode = 1; +}); +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +});