From e44aa887519f5d796c1c312056dadafc3ed265a0 Mon Sep 17 00:00:00 2001 From: Nick Cook Date: Wed, 18 Jan 2023 10:28:35 -0800 Subject: [PATCH] add workflows and remove unused quickstart files --- .github/workflows/media-livestream.yaml | 71 +++++++++++++++++++++++ .github/workflows/workflows.json | 1 + media/livestream/quickstart.js | 76 ------------------------- media/livestream/test/quickstart.js | 42 -------------- 4 files changed, 72 insertions(+), 118 deletions(-) create mode 100644 .github/workflows/media-livestream.yaml delete mode 100644 media/livestream/quickstart.js delete mode 100644 media/livestream/test/quickstart.js diff --git a/.github/workflows/media-livestream.yaml b/.github/workflows/media-livestream.yaml new file mode 100644 index 0000000000..8311d16289 --- /dev/null +++ b/.github/workflows/media-livestream.yaml @@ -0,0 +1,71 @@ +name: media-livestream +on: + push: + branches: + - main + paths: + - 'media/livestream/**' + - '.github/workflows/media-livestream.yaml' + pull_request: + paths: + - 'media/livestream/**' + - '.github/workflows/media-livestream.yaml' + pull_request_target: + types: [labeled] + paths: + - 'media/livestream/**' + - '.github/workflows/media-livestream.yaml' + 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.sha}} + - uses: 'google-github-actions/auth@v1.0.0' + 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: media/livestream + - run: npm test + working-directory: media/livestream + env: + MOCHA_REPORTER_SUITENAME: media_livestream + MOCHA_REPORTER_OUTPUT: media_livestream_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' && always() }} + 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/workflows.json b/.github/workflows/workflows.json index a9457d68c3..b224ef1bc2 100644 --- a/.github/workflows/workflows.json +++ b/.github/workflows/workflows.json @@ -69,6 +69,7 @@ "healthcare/hl7v2", "iam", "kms", + "media/livestream", "media/transcoder", "media/video-stitcher", "mediatranslation", diff --git a/media/livestream/quickstart.js b/media/livestream/quickstart.js deleted file mode 100644 index c5f337ba58..0000000000 --- a/media/livestream/quickstart.js +++ /dev/null @@ -1,76 +0,0 @@ -// 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'; - -function main(parent) { - // [START livestream_quickstart] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The parent location for the resource, in the form of: - * `projects/{project}/locations/{location}`. - */ - // const parent = 'abc123' - /** - * The maximum number of items to return. If unspecified, server - * will pick an appropriate default. Server may return fewer items than - * requested. A caller should only rely on response's - * next_page_token google.cloud.video.livestream.v1.ListChannelsResponse.next_page_token to - * determine if there are more items left to be queried. - */ - // const pageSize = 1234 - /** - * The next_page_token value returned from a previous List request, if any. - */ - // const pageToken = 'abc123' - /** - * The filter to apply to list results. - */ - // const filter = 'abc123' - /** - * Specifies the ordering of results following syntax at - * https://cloud.google.com/apis/design/design_patterns#sorting_order. - */ - // const orderBy = 'abc123' - - // Imports the Livestream library - const {LivestreamServiceClient} = require('@google-cloud/livestream').v1; - - // Instantiates a client - const livestreamClient = new LivestreamServiceClient(); - - async function callListChannels() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await livestreamClient.listChannelsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListChannels(); - // [END livestream_quickstart] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/media/livestream/test/quickstart.js b/media/livestream/test/quickstart.js deleted file mode 100644 index 0d0a89be23..0000000000 --- a/media/livestream/test/quickstart.js +++ /dev/null @@ -1,42 +0,0 @@ -// 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'; - -// const path = require('path'); -// const cp = require('child_process'); -const {before, describe, it} = require('mocha'); -// const {LivestreamServiceClient} = require('@google-cloud/vmmigration').v1; - -// const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); - -// const cwd = path.join(__dirname, '..'); - -// const client = new LivestreamServiceClient(); - -describe('Quickstart', () => { - // let projectId; - - before(async () => { - // projectId = await client.getProjectId(); - }); - - it('should run quickstart', async () => { - // API must be allow listed: - // Should have 0 exit code, and therefore not throw: - // execSync(`node ./quickstart.js projects/${projectId}/locations/global`, { - // cwd, - // }); - }); -});