Skip to content
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-scheduler #2849

Merged
merged 68 commits into from
Nov 15, 2022
Merged
Show file tree
Hide file tree
Changes from 66 commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
d674f05
initial commit
jkwlui Nov 13, 2018
76a7270
chore: clean up lint rules (#2)
JustinBeckwith Nov 21, 2018
540e4e1
Release v0.1.1 (#21)
jkwlui Dec 7, 2018
56ebd5e
Release v0.1.2 (#29)
jkwlui Jan 3, 2019
599a048
docs(samples): Add App Engine Target sample (#33)
averikitsch Jan 25, 2019
04cd748
chore(deps): update dependency mocha to v6
renovate[bot] Feb 19, 2019
8226a66
chore(deps): update dependency supertest to v4
renovate[bot] Mar 9, 2019
0d6c23a
Release v0.2.0 (#61)
JustinBeckwith Mar 11, 2019
db7a2a5
Release v0.3.0 (#71)
jkwlui Apr 4, 2019
2223f1a
refactor: use execSync for tests (#69)
JustinBeckwith Apr 4, 2019
02eaf72
refactor: wrap execSync with encoding: utf-8 (#73)
jkwlui Apr 5, 2019
ff452b5
docs: update to useful quickstart
bcoe Apr 24, 2019
75231ae
test: add a smoke test and perform cleanup (#80)
JustinBeckwith Apr 30, 2019
a483ece
chore: release 1.0.0 (#95)
bcoe May 13, 2019
a1b42b8
chore: release 1.1.0 (#105)
yoshi-automation Jun 5, 2019
872de47
chore(deps): npm audit fix (#106)
JustinBeckwith Jun 11, 2019
93eb955
chore: release 1.1.1 (#109)
yoshi-automation Jun 14, 2019
116cb82
chore: release 1.1.2 (#112)
yoshi-automation Jun 27, 2019
e58e45f
chore: release 1.1.3 (#121)
yoshi-automation Aug 5, 2019
a02e2a6
chore: release 1.1.4 (#123)
yoshi-automation Aug 26, 2019
bca1745
chore: release 1.2.0 (#128)
yoshi-automation Sep 6, 2019
2b7b122
chore: release 1.3.2 (#148)
release-please[bot] Oct 22, 2019
106963c
chore: release 1.3.3 (#157)
release-please[bot] Nov 15, 2019
bc306e8
chore: update license headers (#164)
JustinBeckwith Nov 25, 2019
73bbaab
refactor: use explicit mocha imports (#173)
JustinBeckwith Dec 30, 2019
3aa1106
chore: release 1.4.0
release-please[bot] Jan 6, 2020
bca739b
chore(deps): update dependency mocha to v7 (#175)
renovate-bot Jan 6, 2020
95b33c2
chore: release 1.4.1 (#177)
release-please[bot] Jan 9, 2020
c49a187
fix(samples): delete stale comment from sample (#182)
fhinkel Jan 24, 2020
5b2ff36
chore: release 1.4.2 (#186)
release-please[bot] Jan 30, 2020
8736416
chore: release 1.4.3 (#197)
release-please[bot] Feb 12, 2020
201b5d7
chore: release 1.5.0 (#203)
release-please[bot] Mar 3, 2020
6f954e5
chore: release 1.6.0 (#213)
release-please[bot] Mar 11, 2020
bff5fd5
feat!: drop node8 support, support for async iterators (#227)
alexander-fenster Mar 31, 2020
e96988f
fix: drop unused files from package (#242)
JustinBeckwith Apr 14, 2020
16e46e1
chore: release 2.0.0 (#228)
release-please[bot] Jun 2, 2020
7ab65bf
chore(deps): update dependency mocha to v8 (#259)
renovate-bot Jun 11, 2020
f4cf6b4
chore: release 2.1.0 (#260)
release-please[bot] Jun 16, 2020
47ea524
chore: release 2.1.1 (#264)
release-please[bot] Jul 7, 2020
dc4405f
docs(samples): add sample for updateJob (#265)
kelsk Sep 17, 2020
acbbc52
chore(deps): update dependency supertest to v6 (#308)
renovate-bot Nov 19, 2020
e9ce5fe
chore: release 2.1.2 (#312)
release-please[bot] Dec 2, 2020
55f2a62
chore: release 2.1.3 (#315)
release-please[bot] Dec 9, 2020
c55fe9b
chore: release 2.2.0 (#320)
release-please[bot] Jan 12, 2021
dc2cf99
test: intentional break to test flake bot (#324)
bcoe Jan 26, 2021
a9f2763
Revert "test: intentional break to test flake bot (#324)" (#326)
bcoe Jan 26, 2021
df9a58e
chore: release 2.2.1 (#359)
release-please[bot] May 13, 2021
63c87eb
chore: release 2.2.2 (#368)
release-please[bot] Jun 3, 2021
cf581e5
chore: release 2.2.3 (#378)
release-please[bot] Jun 22, 2021
84e138a
chore: release 2.2.4 (#386)
release-please[bot] Jun 30, 2021
a82721c
test: run system and sample tests with cloud build (#383)
JustinBeckwith Jul 1, 2021
2ea5eda
chore: release 2.2.5 (#389)
release-please[bot] Jul 19, 2021
8174c8f
chore: release 2.2.6 (#398)
release-please[bot] Aug 17, 2021
c1c99c1
chore: release 2.3.0 (#400)
release-please[bot] Sep 10, 2021
0d1e6b7
docs(samples): add auto-generated samples for Node with api short nam…
gcf-owl-bot[bot] Oct 5, 2021
c252b7b
build!: update library to use Node 12 (#452)
sofisl May 20, 2022
430f6fb
chore(main): release 3.0.0 (#453)
release-please[bot] May 26, 2022
511d3ca
chore(main): release 3.0.1 (#458)
release-please[bot] Jun 30, 2022
b249fad
chore(main): release 3.0.2 (#462)
release-please[bot] Aug 2, 2022
3916b61
chore(main): release 3.0.3 (#466)
release-please[bot] Aug 26, 2022
b4eda60
chore(main): release 3.0.4 (#470)
release-please[bot] Sep 22, 2022
e8c2413
chore(main): release 3.0.5 (#482)
release-please[bot] Nov 11, 2022
499ca51
Add workflows config
Nov 14, 2022
f211893
Region tags: rm underscore
Nov 14, 2022
4b5d837
Remove tests for non-migrated samples
Nov 14, 2022
6efad70
Lint
Nov 14, 2022
ec2a135
Add cleanup step to tests
Nov 14, 2022
ac05fc2
Lint
Nov 14, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions .github/workflows/scheduler.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: scheduler
on:
push:
branches:
- main
paths:
- 'scheduler/**'
pull_request:
paths:
- 'scheduler/**'
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@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: scheduler
- run: npm test
working-directory: scheduler
env:
MOCHA_REPORTER_SUITENAME: scheduler
MOCHA_REPORTER_OUTPUT: scheduler_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 @@ -54,6 +54,7 @@
"datacatalog/cloud-client",
"datacatalog/quickstart",
"datastore/functions",
"scheduler",
"talent",
"contact-center-insights",
"workflows"
Expand Down
3 changes: 3 additions & 0 deletions scheduler/.eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
rules:
no-console: off
67 changes: 67 additions & 0 deletions scheduler/createJob.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// Copyright 2018 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.

// sample-metadata:
// title: Create Job
// description: Create a job that posts to /log_payload on an App Engine service.
// usage: node createJob.js [project-id] [location-id] [app-engine-service-id]

/**
* Create a job with an App Engine target via the Cloud Scheduler API
*/
async function createJob(projectId, locationId, serviceId) {
// [START cloudscheduler_create_job]
const scheduler = require('@google-cloud/scheduler');

// Create a client.
const client = new scheduler.CloudSchedulerClient();

// TODO(developer): Uncomment and set the following variables
// const projectId = "PROJECT_ID"
// const locationId = "LOCATION_ID"
// const serviceId = "my-serivce"

// Construct the fully qualified location path.
const parent = client.locationPath(projectId, locationId);

// Construct the request body.
const job = {
appEngineHttpTarget: {
appEngineRouting: {
service: serviceId,
},
relativeUri: '/log_payload',
httpMethod: 'POST',
body: Buffer.from('Hello World'),
},
schedule: '* * * * *',
timeZone: 'America/Los_Angeles',
};

const request = {
parent: parent,
job: job,
};

// Use the client to send the job creation request.
const [response] = await client.createJob(request);
console.log(`Created job: ${response.name}`);
// [END cloudscheduler_create_job]
}

const args = process.argv.slice(2);
createJob(...args).catch(err => {
console.error(err.message);
process.exitCode = 1;
});
25 changes: 25 additions & 0 deletions scheduler/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "nodejs-scheduler-samples",
"private": true,
"main": "quickstart.js",
"engines": {
"node": ">=12.0.0"
},
"files": [
"*.js"
],
"license": "Apache-2.0",
"scripts": {
"start": "node app.js",
"test": "mocha --timeout 10000 --exit"
},
"dependencies": {
"@google-cloud/scheduler": "^3.0.5",
"body-parser": "^1.18.3",
"express": "^4.16.4"
},
"devDependencies": {
"chai": "^4.2.0",
"mocha": "^8.0.0"
}
}
40 changes: 40 additions & 0 deletions scheduler/test/test.samples.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Copyright 2018 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 {CloudSchedulerClient} = require('@google-cloud/scheduler');
const {assert} = require('chai');
const {describe, it, before} = require('mocha');
const cp = require('child_process');

const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'});
const LOCATION_ID = process.env.LOCATION_ID || 'us-central1';
const SERVICE_ID = 'my-service';

describe('Cloud Scheduler Sample Tests', () => {
let PROJECT_ID;

before(async () => {
const client = new CloudSchedulerClient();
PROJECT_ID = await client.getProjectId();
});

it('should create a scheduler job', async () => {
const stdout = execSync(
`node createJob.js ${PROJECT_ID} ${LOCATION_ID} ${SERVICE_ID}`
);
assert.match(stdout, /Created job/);
});
});