-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
migrate code from googleapis/nodejs-cloudbuild #2824
Merged
+255
−0
Merged
Changes from all commits
Commits
Show all changes
50 commits
Select commit
Hold shift + click to select a range
5a73471
feat: initial release of cloud build library (#2)
bcoe 0c512cd
feat(docs): add listBuildTriggers sample to README (#5)
bcoe a367efc
feat: moves library to TypeScript code generation (#10)
bcoe 19ed643
chore: release 1.0.0 (#3)
release-please[bot] 1e12e42
chore: release 1.1.0 (#20)
release-please[bot] ac902f3
chore: update license headers
JustinBeckwith 0b3af8f
chore: release 1.2.0 (#25)
release-please[bot] 4e6cbc0
chore: release 1.3.0 (#33)
release-please[bot] 4922427
chore(deps): update dependency c8 to v7 (#38)
renovate-bot c1b675c
refactor: use explicit mocha imports (#40)
JustinBeckwith 2c638c1
chore(deps): update dependency mocha to v7 (#43)
renovate-bot aedda70
chore: release 1.3.1
release-please[bot] 450c95a
chore: release 1.3.2 (#49)
release-please[bot] d8d1c22
chore: release 1.3.3 (#59)
release-please[bot] f1be19e
chore: release 1.4.0 (#63)
release-please[bot] abfae12
chore: release 1.5.0 (#67)
release-please[bot] 5626de2
chore(deps): update dependency mocha to v8 (#122)
renovate-bot 9cd95d5
chore: release 2.0.0 (#92)
release-please[bot] 086df83
chore: release 2.0.1 (#126)
release-please[bot] fc150da
chore: release 2.0.2 (#133)
release-please[bot] b487c52
chore: release 2.0.3 (#143)
release-please[bot] 3b2a639
chore: release 2.0.4 (#179)
release-please[bot] f611d87
chore: release 2.0.5 (#182)
release-please[bot] 492df48
chore: release 2.0.6 (#186)
release-please[bot] f3fbea5
chore: release 2.1.0 (#205)
release-please[bot] 7845fe1
chore: release 2.2.0 (#213)
release-please[bot] d9341ff
chore: release 2.2.1 (#220)
release-please[bot] 7d64856
chore: release 2.2.2 (#227)
release-please[bot] ead65b5
chore: release 2.2.3 (#232)
release-please[bot] ae7646b
chore: release 2.2.4 (#242)
release-please[bot] 0344b08
chore: release 2.2.5 (#247)
release-please[bot] e9be6a8
chore: release 2.2.6 (#250)
release-please[bot] 465f7e0
chore: release 2.2.7 (#252)
release-please[bot] 48a0f4c
chore: release 2.3.0 (#263)
release-please[bot] 266ea93
chore: release 2.3.1 (#266)
release-please[bot] 4441119
chore: release 2.3.2 (#269)
release-please[bot] 30ca483
chore: release 2.4.0 (#270)
release-please[bot] 664118a
chore: release 2.5.0 (#272)
release-please[bot] b36e0f4
chore: release 2.6.0 (#275)
release-please[bot] 10273c0
docs(samples): add example tags to generated samples (#287)
gcf-owl-bot[bot] 790f4da
chore(quickstart): mention private pool caveats (#317)
9ac3f3c
build!: update library to use Node 12 (#325)
alexander-fenster 1b13448
chore(main): release 3.0.0 (#326)
release-please[bot] 36351f5
chore(main): release 3.0.1 (#328)
release-please[bot] 651e4f9
chore(main): release 3.1.0 (#334)
release-please[bot] a82f019
chore(main): release 3.1.1 (#340)
release-please[bot] bd527c1
chore(main): release 3.1.2 (#345)
release-please[bot] 200a250
testing(cloudbuild): Add GitHub Workflows integration for test running
grayside 7572697
chore(CODEOWNERS): Add cloudbuild ownership
grayside 65cecaf
Merge branch 'main' into nodejs-cloudbuild-migration
grayside File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
name: cloudbuild | ||
on: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- 'cloudbuild/**' | ||
pull_request: | ||
paths: | ||
- 'cloudbuild/**' | ||
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: cloudbuild | ||
- run: npm test | ||
working-directory: cloudbuild | ||
env: | ||
MOCHA_REPORTER_SUITENAME: cloudbuild | ||
MOCHA_REPORTER_OUTPUT: cloudbuild_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}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright 2019 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: List Triggers. | ||
// description: List available build triggers. | ||
// usage: node list-build-triggers.js <PROJECT_ID> | ||
|
||
// [START cloudbuild_list_build_triggers] | ||
async function listBuildTriggers( | ||
projectId = 'YOUR_PROJECT_ID' // Your Google Cloud Platform project ID | ||
) { | ||
// Imports the Google Cloud client library | ||
const {CloudBuildClient} = require('@google-cloud/cloudbuild'); | ||
|
||
// Creates a client | ||
const cb = new CloudBuildClient(); | ||
|
||
// What project should we list triggers for? | ||
const request = { | ||
projectId, | ||
}; | ||
|
||
const [result] = await cb.listBuildTriggers(request); | ||
console.info(JSON.stringify(result, null, 2)); | ||
} | ||
// [END cloudbuild_list_build_triggers] | ||
|
||
const args = process.argv.slice(2); | ||
listBuildTriggers(...args).catch(console.error); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"name": "nodejs-cloudbuild-samples", | ||
"private": true, | ||
"license": "Apache-2.0", | ||
"files": [ | ||
"*.js", | ||
"resources" | ||
], | ||
"author": "Google Inc.", | ||
"repository": "googleapis/nodejs-cloudbuild", | ||
"engines": { | ||
"node": ">=12.0.0" | ||
}, | ||
"scripts": { | ||
"test": "c8 mocha system-test --timeout=800000" | ||
}, | ||
"dependencies": { | ||
"@google-cloud/cloudbuild": "^3.1.2" | ||
}, | ||
"devDependencies": { | ||
"c8": "^7.0.0", | ||
"chai": "^4.2.0", | ||
"mocha": "^8.0.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// Copyright 2019 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'; | ||
|
||
// [START cloudbuild_quickstart] | ||
async function quickstart( | ||
projectId = 'YOUR_PROJECT_ID', // Your Google Cloud Platform project ID | ||
triggerId = 'YOUR_TRIGGER_ID', // UUID for build trigger. | ||
branchName = 'BRANCH_TO_BUILD' // Branch to run build against. | ||
) { | ||
// Imports the Google Cloud client library | ||
const {CloudBuildClient} = require('@google-cloud/cloudbuild'); | ||
|
||
// Creates a client | ||
const cb = new CloudBuildClient(); | ||
|
||
// Note: for Private Pools, you'll have to specify an API endpoint value | ||
// For example: | ||
// const cb = new CloudBuildClient({ apiEndpoint: '<YOUR_POOL_REGION>-cloudbuild.googleapis.com' }); | ||
|
||
// Starts a build against the branch provided. | ||
const [resp] = await cb.runBuildTrigger({ | ||
projectId, | ||
triggerId, | ||
source: { | ||
projectId, | ||
dir: './', | ||
branchName, | ||
}, | ||
}); | ||
console.info(`triggered build for ${triggerId}`); | ||
const [build] = await resp.promise(); | ||
|
||
const STATUS_LOOKUP = [ | ||
'UNKNOWN', | ||
'Queued', | ||
'Working', | ||
'Success', | ||
'Failure', | ||
'Error', | ||
'Timeout', | ||
'Cancelled', | ||
]; | ||
for (const step of build.steps) { | ||
console.info( | ||
`step:\n\tname: ${step.name}\n\tstatus: ${STATUS_LOOKUP[build.status]}` | ||
); | ||
} | ||
} | ||
// [END cloudbuild_quickstart] | ||
|
||
const args = process.argv.slice(2); | ||
quickstart(...args).catch(console.error); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--- | ||
rules: | ||
node/no-extraneous-require: off |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Copyright 2019 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 {assert} = require('chai'); | ||
const {describe, it} = require('mocha'); | ||
const cp = require('child_process'); | ||
|
||
const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); | ||
|
||
const cwd = path.join(__dirname, '..'); | ||
|
||
const PROJECT_ID = process.env.GCLOUD_PROJECT; | ||
// Use list-build-triggers.js to figure out the ID of the trigger | ||
// you would like to execute. | ||
const TRIGGER_ID = | ||
process.env.TRIGGER || 'c9033094-51a9-44c5-b3a0-1d882deb4464'; | ||
|
||
describe('Sample Integration Tests', () => { | ||
it('should run quickstart.js', async () => { | ||
const stdout = execSync( | ||
`node ./quickstart.js ${PROJECT_ID} ${TRIGGER_ID} cloud-build-mvp`, | ||
{cwd} | ||
); | ||
// build should have exited with success status. | ||
assert.include(stdout, 'status: Success'); | ||
}); | ||
|
||
it('should run list-build-triggers.js', async () => { | ||
const stdout = execSync( | ||
`node ./listBuildTriggers.js ${PROJECT_ID} ${TRIGGER_ID} cloud-build-mvp`, | ||
{cwd} | ||
); | ||
assert.include(stdout, 'Push-to-any-branch'); | ||
}); | ||
}); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick (feel free to ignore):
Should the folder name be
cloud-build
to be consistent with existingcloud-*
folders in this repo?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm aligning with the the product API name and region tag, and think it's a minor bug where other directories don't but not necessarily worth fixing.