Skip to content

Commit

Permalink
docs: Add error-reporting samples
Browse files Browse the repository at this point in the history
  • Loading branch information
kweinmeister authored and Ace Nassri committed Nov 11, 2022
1 parent f41ec8d commit 6511cf0
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 8 deletions.
66 changes: 66 additions & 0 deletions .github/workflows/error-reporting.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: error-reporting
on:
push:
branches:
- main
paths:
- "error-reporting/**"
pull_request:
paths:
- "error-reporting/**"
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.sha}}
- 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: error-reporting
- run: npm test
working-directory: error-reporting
env:
MOCHA_REPORTER_SUITENAME: error_reporting
MOCHA_REPORTER_OUTPUT: error_reporting_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}}
1 change: 1 addition & 0 deletions .github/workflows/workflows.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"datacatalog/quickstart",
"endpoints/getting-started",
"endpoints/getting-started-grpc",
"error-reporting",
"functions/firebase",
"functions/helloworld",
"functions/http",
Expand Down
3 changes: 3 additions & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,6 @@ monitoring/opencensus @GoogleCloudPlatform/nodejs-samples-reviewers
# Data & AI
contact-center-insights @GoogleCloudPlatform/dee-data-ai @GoogleCloudPlatform/nodejs-samples-reviewers
talent @GoogleCloudPlatform/dee-data-ai @GoogleCloudPlatform/nodejs-samples-reviewers

# DEE-PO
error-reporting @GoogleCloudPlatform/dee-platform-ops @GoogleCloudPlatform/nodejs-samples-reviewers
2 changes: 0 additions & 2 deletions error-reporting/explicitSetup.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
'use strict';

function explicitSetup() {
// [START error_reporting_setup_explicit]
// [START error_reporting_setup_nodejs_explicit]
// Imports the Google Cloud client library
const {ErrorReporting} = require('@google-cloud/error-reporting');
Expand All @@ -34,7 +33,6 @@ function explicitSetup() {
// Reports a simple error
errors.report('Something broke!');
// [END error_reporting_setup_nodejs_explicit]
// [END error_reporting_setup_explicit]
}

explicitSetup();
2 changes: 0 additions & 2 deletions error-reporting/express.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
'use strict';

function express() {
// [START error_reporting_express]
// [START error_reporting_setup_nodejs_express]
const express = require('express');

Expand Down Expand Up @@ -51,6 +50,5 @@ function express() {
console.log('Press Ctrl+C to quit.');
});
// [END error_reporting_setup_nodejs_express]
// [END error_reporting_express]
}
express();
2 changes: 0 additions & 2 deletions error-reporting/implicitSetup.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
'use strict';

function setupImplicit() {
// [START error_reporting_setup_implicit]
// [START error_reporting_setup_nodejs_implicit]
// Imports the Google Cloud client library
const {ErrorReporting} = require('@google-cloud/error-reporting');
Expand All @@ -31,7 +30,6 @@ function setupImplicit() {
// Reports a simple error
errors.report('Something broke!');
// [END error_reporting_setup_nodejs_implicit]
// [END error_reporting_setup_implicit]
}

setupImplicit();
2 changes: 0 additions & 2 deletions error-reporting/manual.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
'use strict';

function manual() {
// [START error_reporting_manual]
// [START error_reporting_setup_nodejs_manual]
// Imports the Google Cloud client library
const {ErrorReporting} = require('@google-cloud/error-reporting');
Expand Down Expand Up @@ -50,6 +49,5 @@ function manual() {
console.log('Done reporting error string!');
});
// [END error_reporting_setup_nodejs_manual]
// [END error_reporting_manual]
}
manual();

0 comments on commit 6511cf0

Please sign in to comment.