Skip to content

ci(scheduler): migrate to new CI #4006

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

Merged
merged 7 commits into from
Mar 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .github/config/nodejs-dev.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@
"secret-manager",
"security-center/snippets",
"service-directory/snippets",
"scheduler",
"storage-control",
"speech",
"talent",
Expand Down
1 change: 0 additions & 1 deletion .github/config/nodejs-prod.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@
"iam/deny", // PERMISSION_DENIED: Permission iam.googleapis.com/denypolicies.create denied on resource cloudresourcemanager.googleapis.com/projects/long-door-651
"recaptcha_enterprise/snippets", // Cannot use import statement outside a module
"run/idp-sql", // (untested) Error: Invalid contents in the credentials file
"scheduler", // SyntaxError: Cannot use import statement outside a module
"storagetransfer", // CredentialsError: Missing credentials in config, if using AWS_CONFIG_FILE, set AWS_SDK_LOAD_CONFIG=1
"video-intelligence", // PERMISSION_DENIED: The caller does not have permission
"vision", // REDIS: Error: connect ECONNREFUSED 127.0.0.1:6379
Expand Down
60 changes: 25 additions & 35 deletions scheduler/createJob.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,60 +14,50 @@

// This is a generated sample, using the typeless sample bot. Please
// look for the source TypeScript sample (.ts) for modifications.
'use strict';

// 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]

const args = process.argv.slice(2);
const [projectId, locationId, serviceId] = args;

// [START cloudscheduler_create_job]
const {CloudSchedulerClient} = require('@google-cloud/scheduler');

import { CloudSchedulerClient } from '@google-cloud/scheduler';
// TODO(developer): Uncomment and set the following variables
// const projectId = "PROJECT_ID"
// const locationId = "LOCATION_ID"
// const serviceId = "my-serivce"

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

/**
* Create a job with an App Engine target via the Cloud Scheduler API
*/
async function createJob(projectId, locationId, serviceId) {
// 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}`);
// 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}`);
}

createJob(projectId, locationId, serviceId).catch(err => {
console.error(err.message);
process.exitCode = 1;
console.error(err.message);
process.exitCode = 1;
});
// [END cloudscheduler_create_job]
3 changes: 2 additions & 1 deletion scheduler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "nodejs-scheduler-samples",
"private": true,
"main": "quickstart.js",
"type": "module",
"engines": {
"node": ">=16.0.0"
},
Expand All @@ -14,7 +15,7 @@
"build": "tsc -p .",
"fix": "gts fix",
"lint": "gts lint",
"test": "c8 mocha -p -j 2 --loader=ts-node/esm --extension ts --timeout 10000 --exit"
"test": "c8 mocha -p -j 2 --loader=ts-node/esm --extension ts --timeout 20000 --exit"
},
"dependencies": {
"@google-cloud/scheduler": "^4.0.0"
Expand Down
3 changes: 2 additions & 1 deletion scheduler/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"strict": true,
"noImplicitAny": false,
"esModuleInterop": true,
"moduleResolution": "node"
"moduleResolution": "node",
"module": "ESNext"
}
}
Loading