Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Strip caches
delete task.payload.cache;
// Delete cache scopes
task.scopes = task.scopes.filter(scope => !/^docker-worker:cache:/.test(scope));
// Update maxRunTime
task.payload.maxRunTime = Math.max(
task.payload.maxRunTime,
3 * 60 * 60
);
// Update timestamps
task.deadline = taskcluster.fromNowJSON('12 hours');
task.created = taskcluster.fromNowJSON();
task.expires = taskcluster.fromNowJSON('7 days');
// Set task,retries to 0
task.retries = 0;
return task;
},
task.payload.features = task.payload.features || {};
task.payload.features.interactive = true;
// Strip caches
delete task.payload.caches;
// Update maxRunTime
task.payload.maxRunTime = Math.max(
task.payload.maxRunTime,
3 * 60 * 60
);
// Update timestamps
task.deadline = taskcluster.fromNowJSON('12 hours');
task.created = taskcluster.fromNowJSON();
task.expires = taskcluster.fromNowJSON('7 days');
// Set task.retries to 0
task.retries = 0;
return async dispatch => {
dispatch(taskActionsInProgress(true));
try {
const response = await queue.createTask(taskId, task);
hashHistory.push(`${task.taskGroupId}/${response.status.taskId}`);
window.open(`${location.protocol}//${location.host}/one-click-loaner/connect/#${response.status.taskId}`);
// Update current list of tasks
dispatch(createTask(list, {task, status: response.status}));
dispatch(renderActionSuccess(successMessage));
// Check if meta-data is up-to-date
var lastUsed = new Date(metadata.last_used);
if (metadata.provisioner_id === provisionerId
&& metadata.worker_type === workerType
&& isFinite(lastUsed)
&& lastUsed.getTime() > Date.now() - 23 * 60 * 60 * 1000
) {
return; // We're done as meta-data is present
}
// Update meta-data
return this.client.setMetadata(queue, {
provisioner_id: provisionerId,
worker_type: workerType,
last_used: taskcluster.fromNowJSON(),
});
} catch (err) {
// We handle queue not found exceptions, because getMetadata is a HEA
// request we don't get any error message payload, so we also accept 404
// as implying the same.
if (err.code !== 'QueueNotFound' &&
err.statusCode !== 404) {
throw err;
}
// Create the queue with correct meta-data
try {
await this.client.createQueue(queue, {
provisioner_id: provisionerId,
worker_type: workerType,
last_used: taskcluster.fromNowJSON(),
// Set interactive = true
task.payload.features = task.payload.features || {};
task.payload.features.interactive = true;
// Strip caches
delete task.payload.caches;
// Update maxRunTime
task.payload.maxRunTime = Math.max(
task.payload.maxRunTime,
3 * 60 * 60
);
// Update timestamps
task.deadline = taskcluster.fromNowJSON('12 hours');
task.created = taskcluster.fromNowJSON();
task.expires = taskcluster.fromNowJSON('7 days');
// Set task.retries to 0
task.retries = 0;
return async dispatch => {
dispatch(taskActionsInProgress(true));
try {
const response = await queue.createTask(taskId, task);
hashHistory.push(`${task.taskGroupId}/${response.status.taskId}`);
window.open(`${location.protocol}//${location.host}/one-click-loaner/connect/#${response.status.taskId}`);
// Update current list of tasks
taskForHook(hook, context, options) {
const now = options.created;
let task = jsone(hook.task, _.defaults({}, {now, taskId: options.taskId}, context));
if (!task) {
return;
}
// only apply created, deadline, and expires if they are not set
if (!task.created) {
task.created = now.toJSON();
}
if (!task.deadline) {
task.deadline = taskcluster.fromNowJSON('1 day', now);
}
if (!task.expires) {
task.expires = taskcluster.fromNowJSON('1 month', now);
}
// If the template did not set a taskGroupId, then set the taskGroupId to
// the taskId, thereby creating a new task group and following the
// convention for decision tasks.
if (!task.taskGroupId) {
task.taskGroupId = options.taskId;
}
return task;
}
run: async (requirements, utils) => {
let taskCount = 3;
let taskIds = [];
let queue = new taskcluster.Queue(taskcluster.fromEnvVars());
for (let i = 0; i < taskCount; i++){
let task = {
provisionerId: 'built-in',
workerType: 'succeed',
created: (new Date()).toJSON(),
deadline: taskcluster.fromNowJSON('2 minutes'),
metadata: {
name: 'Smoketest dependencies task Nr' + (taskCount - i),
description: 'built-in/succeed task created during dependency smoketest',
owner: 'smoketest@taskcluster.net',
source: 'https://taskcluster.net',
},
payload: {},
};
task.dependencies = [...taskIds];
taskIds.push(taskcluster.slugid());
await queue.createTask(taskIds[i], task);
utils.status({message: 'Created task ' + taskIds[i]});
}
let pollStartTime = new Date();
while(new Date() - pollStartTime < 1200000){
let statuses = [];
run: async (requirements, utils) => {
let task = {
provisionerId: 'built-in',
workerType: taskType,
created: (new Date()).toJSON(),
deadline: taskcluster.fromNowJSON('2 minutes'),
metadata: {
name: 'Smoketest built-in/' + taskType,
description: 'built-in/' + taskType + ' task created during smoketest',
owner: 'smoketest@taskcluster.net',
source: 'https://taskcluster.net',
},
payload: {},
};
let taskId = taskcluster.slugid();
utils.status({message: 'built-in/' + taskType + ' taskId: ' + taskId});
let queue = new taskcluster.Queue(taskcluster.fromEnvVars());
await queue.createTask(taskId, task);
let pollForStatusStart = new Date();
while((new Date() - pollForStatusStart) < 120000){
let status = await queue.status(taskId);
if (status.status.state === 'pending' || status.status.state === 'running'){
run: async () => {
let secrets = new taskcluster.Secrets(taskcluster.fromEnvVars());
let secretName = taskcluster.slugid();
let secretPrefix = `project/taskcluster/smoketest/${secretName}`;
const payload = {
"expires": taskcluster.fromNowJSON('2 minutes'),
"secret": {
"description": `Secret ${secretName}`,
"type": "object",
},
};
await secrets.set(secretPrefix, payload);
const getSecret = await secrets.get(secretPrefix);
assert.deepEqual(getSecret.secret, payload.secret);
await secrets.remove(secretPrefix);
await assert.rejects(
() => secrets.get(secretPrefix),
err => assert.equal(err.code, 404)
);
},
});
run: async (requirements, utils) => {
let queue = new taskcluster.Queue(taskcluster.fromEnvVars());
let randomId = taskcluster.slugid();
const taskIndex = 'project.taskcluster.smoketest.' + randomId;
let task = {
provisionerId: 'built-in',
workerType: 'succeed',
created: (new Date()).toJSON(),
deadline: taskcluster.fromNowJSON('2 minutes'),
expires: taskcluster.fromNowJSON('60 minutes'),
metadata: {
name: "Smoketest indexTask-find",
description: "built-in/succeed task created during smoketest",
owner: "smoketest@taskcluster.net",
source: "https://taskcluster.net",
},
payload: {},
routes: [`index.${taskIndex}`],
};
utils.status({ message: 'indexTask-find taskId: ' + randomId });
await queue.createTask(randomId, task);
let index = new taskcluster.Index(taskcluster.fromEnvVars());
let pollForStatusStart = new Date();
while ((new Date() - pollForStatusStart) < 120000) {
let status = await queue.status(randomId);
if (status.status.state === 'pending' || status.status.state === 'running') {
statsumToken: async (project) => {
return {
project,
token: Statsum.createToken(project, cfg.app.statsum.secret, '25h'),
baseUrl: cfg.app.statsum.baseUrl,
expires: taskcluster.fromNowJSON('24 hours'),
};
},
sentryDSN: async (project) => {