Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.
| A comped workspace's usage chart and breakdowns show what runs used at cost, as the free tier's do | 1 | import assert from "node:assert/strict"; |
| Every sandbox on g1t's runners has 20 GB of disk, the most Cloudflare Containers give one, as much or more than a GitHub-hosted ubuntu-latest's 14 GB: the standard machine (ubuntu-latest and every other hosted label, and all other work) becomes a custom instance type of 1 vCPU, 4 GiB and 20 GB, where standard-1 had half a vCPU and 8 GB, and g1t-2core a custom 2 vCPU, 8 GiB and 20 GB, where standard-3 had 16 GB; g1t-4core stays standard-4, which already had 20 GB. 1 vCPU is the smallest a custom type may have, and Cloudflare bills CPU only as it is used, so the doubled vCPU costs only what a job uses of it. The contracts' instance table, its TypeScript mirror and the billing keeper's standard sandbox say the same sizes; the price scales, worked out as before from Cloudflare's list prices with every vCPU busy and the Durable Object behind each, are now 1.9 for g1t-2core and 3.4 for g1t-4core, against the larger standard machine, and the fallbacks for a sandbox second (33 millionths of a dollar with its vCPU busy) and a build second (16) follow it. A test holds wrangler.jsonc's sizes to the contracts', and another the scales to the list prices. The docs' machine tables, the larger machines' prices and the Cloudflare deploy guide say so. | 2 | import { readFileSync } from "node:fs"; |
| A comped workspace's usage chart and breakdowns show what runs used at cost, as the free tier's do | 3 | import { test } from "node:test"; |
| 4 | ||
| 5 | import type { WorkflowDomain } from "@g1t/contracts"; | |
| 6 | ||
| Hosted runner time is charged by the job, in minutes: each job's time on g1t's machines (a workflow job, a check, a merge queue run) is rounded up to the whole minute, so 61 seconds is 2 minutes and any job that ran is at least 1, and charged at a fixed rate for the machine it ran on: $0.004 a minute for the standard machine (2 vCPU, 8 GiB, 16 GB; ubuntu-latest, every other hosted label and g1t-2core) and $0.007 for g1t-4core (4 vCPU, 12 GiB, 20 GB). Each rate is the machine's cost a minute at Cloudflare's list prices with half its vCPUs busy (memory, disk and the Durable Object for every second, CPU as used), plus the 20% margin, rounded up to a tenth of a cent, and never under its cost with every vCPU busy ($0.0038 and $0.0068); should a job ever cost g1t more than its minutes at the rate, it is charged that cost. Jobs on self-hosted runners stay free. | 7 | import { |
| 8 | INSTANCE_TYPES, | |
| 9 | STANDARD_INSTANCE, | |
| 10 | instanceNamed, | |
| 11 | machineNamed, | |
| 12 | machineSize, | |
| 13 | machines, | |
| 14 | priceScale, | |
| 15 | runnerMinutes, | |
| 16 | } from "../../../packages/contracts/src/instances.ts"; | |
| Every sandbox on g1t's runners has 20 GB of disk, the most Cloudflare Containers give one, as much or more than a GitHub-hosted ubuntu-latest's 14 GB: the standard machine (ubuntu-latest and every other hosted label, and all other work) becomes a custom instance type of 1 vCPU, 4 GiB and 20 GB, where standard-1 had half a vCPU and 8 GB, and g1t-2core a custom 2 vCPU, 8 GiB and 20 GB, where standard-3 had 16 GB; g1t-4core stays standard-4, which already had 20 GB. 1 vCPU is the smallest a custom type may have, and Cloudflare bills CPU only as it is used, so the doubled vCPU costs only what a job uses of it. The contracts' instance table, its TypeScript mirror and the billing keeper's standard sandbox say the same sizes; the price scales, worked out as before from Cloudflare's list prices with every vCPU busy and the Durable Object behind each, are now 1.9 for g1t-2core and 3.4 for g1t-4core, against the larger standard machine, and the fallbacks for a sandbox second (33 millionths of a dollar with its vCPU busy) and a build second (16) follow it. A test holds wrangler.jsonc's sizes to the contracts', and another the scales to the list prices. The docs' machine tables, the larger machines' prices and the Cloudflare deploy guide say so. | 17 | |
| Hosted runner time is charged by the job, in minutes: each job's time on g1t's machines (a workflow job, a check, a merge queue run) is rounded up to the whole minute, so 61 seconds is 2 minutes and any job that ran is at least 1, and charged at a fixed rate for the machine it ran on: $0.004 a minute for the standard machine (2 vCPU, 8 GiB, 16 GB; ubuntu-latest, every other hosted label and g1t-2core) and $0.007 for g1t-4core (4 vCPU, 12 GiB, 20 GB). Each rate is the machine's cost a minute at Cloudflare's list prices with half its vCPUs busy (memory, disk and the Durable Object for every second, CPU as used), plus the 20% margin, rounded up to a tenth of a cent, and never under its cost with every vCPU busy ($0.0038 and $0.0068); should a job ever cost g1t more than its minutes at the rate, it is charged that cost. Jobs on self-hosted runners stay free. | 18 | import { SANDBOX_BINDINGS, jobHosts, jobNamespaceOf, sandboxNamespace } from "./egress.ts"; |
| A comped workspace's usage chart and breakdowns show what runs used at cost, as the free tier's do | 19 | |
| 20 | const domains: WorkflowDomain[] = [ | |
| 21 | { domain: "api.cloudflare.com", workflows: ["deploy.yml"], environments: ["production"] }, | |
| 22 | { domain: "*.example.com", workflows: [], environments: [] }, | |
| 23 | ]; | |
| 24 | const policy = { workflowDomains: domains }; | |
| 25 | const deploy = { workflow: ".g1t/workflows/deploy.yml", environment: "production", trusted: true }; | |
| 26 | ||
| 27 | test("a trusted workflow job reaches the workflow-only domains that name it", () => { | |
| 28 | assert.deepEqual(jobHosts(policy, "actions", deploy), ["api.cloudflare.com", "*.example.com"]); | |
| 29 | assert.deepEqual(jobHosts(policy, "actions", { ...deploy, workflow: "DEPLOY.yml", environment: "Production" }), [ | |
| 30 | "api.cloudflare.com", | |
| 31 | "*.example.com", | |
| 32 | ]); | |
| 33 | // Another environment, none, or another workflow: only the open entry. | |
| 34 | assert.deepEqual(jobHosts(policy, "actions", { ...deploy, environment: "staging" }), ["*.example.com"]); | |
| 35 | assert.deepEqual(jobHosts(policy, "actions", { ...deploy, environment: null }), ["*.example.com"]); | |
| 36 | assert.deepEqual(jobHosts(policy, "actions", { ...deploy, workflow: ".g1t/workflows/ci.yml" }), ["*.example.com"]); | |
| 37 | }); | |
| 38 | ||
| 39 | test("nothing else ever reaches them: forks, deploy builds, unknown jobs", () => { | |
| 40 | assert.deepEqual(jobHosts(policy, "actions", { ...deploy, trusted: false }), []); | |
| 41 | assert.deepEqual(jobHosts(policy, "deploy", deploy), []); | |
| 42 | assert.deepEqual(jobHosts(policy, "actions", null), []); | |
| 43 | assert.deepEqual(jobHosts(policy, "actions", { ...deploy, workflow: null }), []); | |
| 44 | // Guardrails from before the list existed. | |
| 45 | assert.deepEqual(jobHosts({}, "actions", deploy), []); | |
| 46 | }); | |
| 47 | ||
| 48 | test("each sandbox class reports to its own namespace", () => { | |
| 49 | const env = { SANDBOX: "standard", SANDBOX_2CORE: "two", SANDBOX_4CORE: "four" } as unknown as object; | |
| 50 | assert.equal(sandboxNamespace(env, "AttemptSandbox"), "standard"); | |
| 51 | assert.equal(sandboxNamespace(env, "Sandbox4Core"), "four"); | |
| 52 | assert.equal(sandboxNamespace(env, "Sandbox2Core"), "two"); | |
| 53 | assert.equal(sandboxNamespace(env, undefined), "standard"); | |
| 54 | assert.equal(sandboxNamespace({ SANDBOX: "standard" }, "Sandbox4Core"), "standard"); | |
| 55 | assert.deepEqual(Object.keys(SANDBOX_BINDINGS), ["AttemptSandbox", "Sandbox2Core", "Sandbox4Core"]); | |
| 56 | }); | |
| Every sandbox on g1t's runners has 20 GB of disk, the most Cloudflare Containers give one, as much or more than a GitHub-hosted ubuntu-latest's 14 GB: the standard machine (ubuntu-latest and every other hosted label, and all other work) becomes a custom instance type of 1 vCPU, 4 GiB and 20 GB, where standard-1 had half a vCPU and 8 GB, and g1t-2core a custom 2 vCPU, 8 GiB and 20 GB, where standard-3 had 16 GB; g1t-4core stays standard-4, which already had 20 GB. 1 vCPU is the smallest a custom type may have, and Cloudflare bills CPU only as it is used, so the doubled vCPU costs only what a job uses of it. The contracts' instance table, its TypeScript mirror and the billing keeper's standard sandbox say the same sizes; the price scales, worked out as before from Cloudflare's list prices with every vCPU busy and the Durable Object behind each, are now 1.9 for g1t-2core and 3.4 for g1t-4core, against the larger standard machine, and the fallbacks for a sandbox second (33 millionths of a dollar with its vCPU busy) and a build second (16) follow it. A test holds wrangler.jsonc's sizes to the contracts', and another the scales to the list prices. The docs' machine tables, the larger machines' prices and the Cloudflare deploy guide say so. | 57 | |
| Hosted runner time is charged by the job, in minutes: each job's time on g1t's machines (a workflow job, a check, a merge queue run) is rounded up to the whole minute, so 61 seconds is 2 minutes and any job that ran is at least 1, and charged at a fixed rate for the machine it ran on: $0.004 a minute for the standard machine (2 vCPU, 8 GiB, 16 GB; ubuntu-latest, every other hosted label and g1t-2core) and $0.007 for g1t-4core (4 vCPU, 12 GiB, 20 GB). Each rate is the machine's cost a minute at Cloudflare's list prices with half its vCPUs busy (memory, disk and the Durable Object for every second, CPU as used), plus the 20% margin, rounded up to a tenth of a cent, and never under its cost with every vCPU busy ($0.0038 and $0.0068); should a job ever cost g1t more than its minutes at the rate, it is charged that cost. Jobs on self-hosted runners stay free. | 58 | test("each label in the machine catalogue runs in its own class, bound and sized as wrangler.jsonc says", () => { |
| Every sandbox on g1t's runners has 20 GB of disk, the most Cloudflare Containers give one, as much or more than a GitHub-hosted ubuntu-latest's 14 GB: the standard machine (ubuntu-latest and every other hosted label, and all other work) becomes a custom instance type of 1 vCPU, 4 GiB and 20 GB, where standard-1 had half a vCPU and 8 GB, and g1t-2core a custom 2 vCPU, 8 GiB and 20 GB, where standard-3 had 16 GB; g1t-4core stays standard-4, which already had 20 GB. 1 vCPU is the smallest a custom type may have, and Cloudflare bills CPU only as it is used, so the doubled vCPU costs only what a job uses of it. The contracts' instance table, its TypeScript mirror and the billing keeper's standard sandbox say the same sizes; the price scales, worked out as before from Cloudflare's list prices with every vCPU busy and the Durable Object behind each, are now 1.9 for g1t-2core and 3.4 for g1t-4core, against the larger standard machine, and the fallbacks for a sandbox second (33 millionths of a dollar with its vCPU busy) and a build second (16) follow it. A test holds wrangler.jsonc's sizes to the contracts', and another the scales to the list prices. The docs' machine tables, the larger machines' prices and the Cloudflare deploy guide say so. | 59 | type Size = { vcpu: number; memory_mib: number; disk_mb: number }; |
| 60 | // wrangler.jsonc's comments are whole lines. | |
| 61 | const text = readFileSync(new URL("../wrangler.jsonc", import.meta.url), "utf8").replace(/^\s*\/\/.*$/gm, ""); | |
| Hosted runner time is charged by the job, in minutes: each job's time on g1t's machines (a workflow job, a check, a merge queue run) is rounded up to the whole minute, so 61 seconds is 2 minutes and any job that ran is at least 1, and charged at a fixed rate for the machine it ran on: $0.004 a minute for the standard machine (2 vCPU, 8 GiB, 16 GB; ubuntu-latest, every other hosted label and g1t-2core) and $0.007 for g1t-4core (4 vCPU, 12 GiB, 20 GB). Each rate is the machine's cost a minute at Cloudflare's list prices with half its vCPUs busy (memory, disk and the Durable Object for every second, CPU as used), plus the 20% margin, rounded up to a tenth of a cent, and never under its cost with every vCPU busy ($0.0038 and $0.0068); should a job ever cost g1t more than its minutes at the rate, it is charged that cost. Jobs on self-hosted runners stay free. | 62 | const config = JSON.parse(text) as { |
| 63 | containers: { class_name: string; instance_type: unknown }[]; | |
| 64 | durable_objects: { bindings: { name: string; class_name: string }[] }; | |
| 65 | }; | |
| g1t's runners use only Cloudflare's named instance types, sized for the least they cost while giving a job what it needs: the standard machine (ubuntu-latest, every other hosted label and all other work) is standard-3, 2 vCPU, 8 GiB and 16 GB of disk, where a custom 1 vCPU, 4 GiB, 20 GB type had been asked for and standard-1's half vCPU, 4 GiB and 8 GB was still being served; g1t-2core is kept as a name of the same machine, so workflows that ask for it keep working, at the same price; and g1t-4core stays standard-4, 4 vCPU, 12 GiB and 20 GB, for heavier jobs. At the classes' max_instances (20, 10, 10) the runners hold at most 100 vCPU, 360 GiB and 680 GB at once, well inside the account's 1,500 vCPU and 6 TiB. The contracts' instance table and its TypeScript mirror say the same sizes; the price scale, worked out as before from Cloudflare's list prices with every vCPU busy and the Durable Object behind each, is 1.8 for g1t-4core against the standard machine. The billing keeper's base is standard-3's memory, disk and Durable Object (22.6825 millionths of a dollar a second, billed whether the CPU is busy or not), and the fallbacks follow it: 63 for a sandbox second with both vCPUs busy, 26 for a build second. Migration 0056 moves the price book to the new base at once rather than after the notice period, so g1t never charges less than a sandbox costs it: sandbox_base_second to 22.6825, and sandbox_second and build_second up by the base's growth of 10.56, replacing any rise still waiting for its date. Tests hold wrangler.jsonc to the contracts' named sizes, the scales to the list prices, and every machine's price scale to at least its base's, so an idle job that does not report its CPU still pays for the memory and disk it held. The docs' machine tables, prices and the Cloudflare deploy guide say so. | 66 | // The named Cloudflare instance types a machine may be, at the sizes |
| Hosted runner time is charged by the job, in minutes: each job's time on g1t's machines (a workflow job, a check, a merge queue run) is rounded up to the whole minute, so 61 seconds is 2 minutes and any job that ran is at least 1, and charged at a fixed rate for the machine it ran on: $0.004 a minute for the standard machine (2 vCPU, 8 GiB, 16 GB; ubuntu-latest, every other hosted label and g1t-2core) and $0.007 for g1t-4core (4 vCPU, 12 GiB, 20 GB). Each rate is the machine's cost a minute at Cloudflare's list prices with half its vCPUs busy (memory, disk and the Durable Object for every second, CPU as used), plus the 20% margin, rounded up to a tenth of a cent, and never under its cost with every vCPU busy ($0.0038 and $0.0068); should a job ever cost g1t more than its minutes at the rate, it is charged that cost. Jobs on self-hosted runners stay free. | 67 | // Cloudflare gives them. A custom type would be a row here once the |
| 68 | // account may use them. | |
| g1t's runners use only Cloudflare's named instance types, sized for the least they cost while giving a job what it needs: the standard machine (ubuntu-latest, every other hosted label and all other work) is standard-3, 2 vCPU, 8 GiB and 16 GB of disk, where a custom 1 vCPU, 4 GiB, 20 GB type had been asked for and standard-1's half vCPU, 4 GiB and 8 GB was still being served; g1t-2core is kept as a name of the same machine, so workflows that ask for it keep working, at the same price; and g1t-4core stays standard-4, 4 vCPU, 12 GiB and 20 GB, for heavier jobs. At the classes' max_instances (20, 10, 10) the runners hold at most 100 vCPU, 360 GiB and 680 GB at once, well inside the account's 1,500 vCPU and 6 TiB. The contracts' instance table and its TypeScript mirror say the same sizes; the price scale, worked out as before from Cloudflare's list prices with every vCPU busy and the Durable Object behind each, is 1.8 for g1t-4core against the standard machine. The billing keeper's base is standard-3's memory, disk and Durable Object (22.6825 millionths of a dollar a second, billed whether the CPU is busy or not), and the fallbacks follow it: 63 for a sandbox second with both vCPUs busy, 26 for a build second. Migration 0056 moves the price book to the new base at once rather than after the notice period, so g1t never charges less than a sandbox costs it: sandbox_base_second to 22.6825, and sandbox_second and build_second up by the base's growth of 10.56, replacing any rise still waiting for its date. Tests hold wrangler.jsonc to the contracts' named sizes, the scales to the list prices, and every machine's price scale to at least its base's, so an idle job that does not report its CPU still pays for the memory and disk it held. The docs' machine tables, prices and the Cloudflare deploy guide say so. | 69 | const named: Record<string, Size> = { |
| 70 | "standard-3": { vcpu: 2, memory_mib: 8 * 1024, disk_mb: 16_000 }, | |
| 71 | "standard-4": { vcpu: 4, memory_mib: 12 * 1024, disk_mb: 20_000 }, | |
| 72 | }; | |
| Hosted runner time is charged by the job, in minutes: each job's time on g1t's machines (a workflow job, a check, a merge queue run) is rounded up to the whole minute, so 61 seconds is 2 minutes and any job that ran is at least 1, and charged at a fixed rate for the machine it ran on: $0.004 a minute for the standard machine (2 vCPU, 8 GiB, 16 GB; ubuntu-latest, every other hosted label and g1t-2core) and $0.007 for g1t-4core (4 vCPU, 12 GiB, 20 GB). Each rate is the machine's cost a minute at Cloudflare's list prices with half its vCPUs busy (memory, disk and the Durable Object for every second, CPU as used), plus the 20% margin, rounded up to a tenth of a cent, and never under its cost with every vCPU busy ($0.0038 and $0.0068); should a job ever cost g1t more than its minutes at the rate, it is charged that cost. Jobs on self-hosted runners stay free. | 73 | // Every class has a label, and every label a class. |
| 74 | assert.deepEqual( | |
| 75 | INSTANCE_TYPES.map((instance) => instance.sandboxClass).sort(), | |
| 76 | config.containers.map((container) => container.class_name).sort(), | |
| 77 | ); | |
| 78 | for (const instance of INSTANCE_TYPES) { | |
| 79 | const type = config.containers.find((c) => c.class_name === instance.sandboxClass)?.instance_type; | |
| g1t's runners use only Cloudflare's named instance types, sized for the least they cost while giving a job what it needs: the standard machine (ubuntu-latest, every other hosted label and all other work) is standard-3, 2 vCPU, 8 GiB and 16 GB of disk, where a custom 1 vCPU, 4 GiB, 20 GB type had been asked for and standard-1's half vCPU, 4 GiB and 8 GB was still being served; g1t-2core is kept as a name of the same machine, so workflows that ask for it keep working, at the same price; and g1t-4core stays standard-4, 4 vCPU, 12 GiB and 20 GB, for heavier jobs. At the classes' max_instances (20, 10, 10) the runners hold at most 100 vCPU, 360 GiB and 680 GB at once, well inside the account's 1,500 vCPU and 6 TiB. The contracts' instance table and its TypeScript mirror say the same sizes; the price scale, worked out as before from Cloudflare's list prices with every vCPU busy and the Durable Object behind each, is 1.8 for g1t-4core against the standard machine. The billing keeper's base is standard-3's memory, disk and Durable Object (22.6825 millionths of a dollar a second, billed whether the CPU is busy or not), and the fallbacks follow it: 63 for a sandbox second with both vCPUs busy, 26 for a build second. Migration 0056 moves the price book to the new base at once rather than after the notice period, so g1t never charges less than a sandbox costs it: sandbox_base_second to 22.6825, and sandbox_second and build_second up by the base's growth of 10.56, replacing any rise still waiting for its date. Tests hold wrangler.jsonc to the contracts' named sizes, the scales to the list prices, and every machine's price scale to at least its base's, so an idle job that does not report its CPU still pays for the memory and disk it held. The docs' machine tables, prices and the Cloudflare deploy guide say so. | 80 | const size = typeof type === "string" ? named[type] : undefined; |
| Hosted runner time is charged by the job, in minutes: each job's time on g1t's machines (a workflow job, a check, a merge queue run) is rounded up to the whole minute, so 61 seconds is 2 minutes and any job that ran is at least 1, and charged at a fixed rate for the machine it ran on: $0.004 a minute for the standard machine (2 vCPU, 8 GiB, 16 GB; ubuntu-latest, every other hosted label and g1t-2core) and $0.007 for g1t-4core (4 vCPU, 12 GiB, 20 GB). Each rate is the machine's cost a minute at Cloudflare's list prices with half its vCPUs busy (memory, disk and the Durable Object for every second, CPU as used), plus the 20% margin, rounded up to a tenth of a cent, and never under its cost with every vCPU busy ($0.0038 and $0.0068); should a job ever cost g1t more than its minutes at the rate, it is charged that cost. Jobs on self-hosted runners stay free. | 81 | assert.ok(size, `${instance.sandboxClass}: ${JSON.stringify(type)}`); |
| g1t's runners use only Cloudflare's named instance types, sized for the least they cost while giving a job what it needs: the standard machine (ubuntu-latest, every other hosted label and all other work) is standard-3, 2 vCPU, 8 GiB and 16 GB of disk, where a custom 1 vCPU, 4 GiB, 20 GB type had been asked for and standard-1's half vCPU, 4 GiB and 8 GB was still being served; g1t-2core is kept as a name of the same machine, so workflows that ask for it keep working, at the same price; and g1t-4core stays standard-4, 4 vCPU, 12 GiB and 20 GB, for heavier jobs. At the classes' max_instances (20, 10, 10) the runners hold at most 100 vCPU, 360 GiB and 680 GB at once, well inside the account's 1,500 vCPU and 6 TiB. The contracts' instance table and its TypeScript mirror say the same sizes; the price scale, worked out as before from Cloudflare's list prices with every vCPU busy and the Durable Object behind each, is 1.8 for g1t-4core against the standard machine. The billing keeper's base is standard-3's memory, disk and Durable Object (22.6825 millionths of a dollar a second, billed whether the CPU is busy or not), and the fallbacks follow it: 63 for a sandbox second with both vCPUs busy, 26 for a build second. Migration 0056 moves the price book to the new base at once rather than after the notice period, so g1t never charges less than a sandbox costs it: sandbox_base_second to 22.6825, and sandbox_second and build_second up by the base's growth of 10.56, replacing any rise still waiting for its date. Tests hold wrangler.jsonc to the contracts' named sizes, the scales to the list prices, and every machine's price scale to at least its base's, so an idle job that does not report its CPU still pays for the memory and disk it held. The docs' machine tables, prices and the Cloudflare deploy guide say so. | 82 | assert.equal(type, instance.container, instance.label); |
| Every sandbox on g1t's runners has 20 GB of disk, the most Cloudflare Containers give one, as much or more than a GitHub-hosted ubuntu-latest's 14 GB: the standard machine (ubuntu-latest and every other hosted label, and all other work) becomes a custom instance type of 1 vCPU, 4 GiB and 20 GB, where standard-1 had half a vCPU and 8 GB, and g1t-2core a custom 2 vCPU, 8 GiB and 20 GB, where standard-3 had 16 GB; g1t-4core stays standard-4, which already had 20 GB. 1 vCPU is the smallest a custom type may have, and Cloudflare bills CPU only as it is used, so the doubled vCPU costs only what a job uses of it. The contracts' instance table, its TypeScript mirror and the billing keeper's standard sandbox say the same sizes; the price scales, worked out as before from Cloudflare's list prices with every vCPU busy and the Durable Object behind each, are now 1.9 for g1t-2core and 3.4 for g1t-4core, against the larger standard machine, and the fallbacks for a sandbox second (33 millionths of a dollar with its vCPU busy) and a build second (16) follow it. A test holds wrangler.jsonc's sizes to the contracts', and another the scales to the list prices. The docs' machine tables, the larger machines' prices and the Cloudflare deploy guide say so. | 83 | assert.deepEqual( |
| 84 | { vcpu: size.vcpu, memoryGib: size.memory_mib / 1024, diskGb: size.disk_mb / 1000 }, | |
| 85 | { vcpu: instance.vcpu, memoryGib: instance.memoryGib, diskGb: instance.diskGb }, | |
| 86 | instance.label, | |
| 87 | ); | |
| Hosted runner time is charged by the job, in minutes: each job's time on g1t's machines (a workflow job, a check, a merge queue run) is rounded up to the whole minute, so 61 seconds is 2 minutes and any job that ran is at least 1, and charged at a fixed rate for the machine it ran on: $0.004 a minute for the standard machine (2 vCPU, 8 GiB, 16 GB; ubuntu-latest, every other hosted label and g1t-2core) and $0.007 for g1t-4core (4 vCPU, 12 GiB, 20 GB). Each rate is the machine's cost a minute at Cloudflare's list prices with half its vCPUs busy (memory, disk and the Durable Object for every second, CPU as used), plus the 20% margin, rounded up to a tenth of a cent, and never under its cost with every vCPU busy ($0.0038 and $0.0068); should a job ever cost g1t more than its minutes at the rate, it is charged that cost. Jobs on self-hosted runners stay free. | 88 | // Its binding, here and in wrangler.jsonc, is what a job starts in. |
| 89 | const binding = SANDBOX_BINDINGS[instance.sandboxClass]; | |
| 90 | assert.ok(binding, `${instance.sandboxClass} has no binding in SANDBOX_BINDINGS`); | |
| 91 | assert.ok( | |
| 92 | config.durable_objects.bindings.some((b) => b.name === binding && b.class_name === instance.sandboxClass), | |
| 93 | binding, | |
| 94 | ); | |
| 95 | assert.equal(jobNamespaceOf({ [binding]: instance.label }, instance), instance.label); | |
| 96 | } | |
| 97 | // A class not deployed here: the job is not started on another machine. | |
| 98 | assert.equal(jobNamespaceOf({ SANDBOX: "standard" }, INSTANCE_TYPES[2]!), null); | |
| 99 | assert.equal(jobNamespaceOf({ SANDBOX: "standard" }, { sandboxClass: "Sandbox64Core" }), null); | |
| 100 | }); | |
| 101 | ||
| 102 | test("runs-on labels are the catalogue's, and a job is charged its minutes rounded up", () => { | |
| 103 | assert.equal(instanceNamed("ubuntu-latest"), STANDARD_INSTANCE); | |
| 104 | assert.equal(instanceNamed("G1T-4Core").machine, "4-core"); | |
| 105 | assert.equal(instanceNamed("g1t-2core").machine, STANDARD_INSTANCE.machine); | |
| 106 | assert.deepEqual( | |
| 107 | machines().map((m) => [m.machine, m.microsPerMinute, machineSize(m)]), | |
| 108 | [ | |
| 109 | ["2-core", 4000, "2 vCPU, 8 GiB, 16 GB"], | |
| 110 | ["4-core", 7000, "4 vCPU, 12 GiB, 20 GB"], | |
| 111 | ], | |
| 112 | ); | |
| 113 | assert.equal(machineNamed("4-core")?.label, "g1t-4core"); | |
| 114 | assert.equal(machineNamed("8-core"), null); | |
| 115 | assert.equal(priceScale(instanceNamed("g1t-4core")), 1.75); | |
| 116 | assert.deepEqual([0, 1, 60, 61, 3600].map(runnerMinutes), [0, 1, 1, 2, 60]); | |
| Every sandbox on g1t's runners has 20 GB of disk, the most Cloudflare Containers give one, as much or more than a GitHub-hosted ubuntu-latest's 14 GB: the standard machine (ubuntu-latest and every other hosted label, and all other work) becomes a custom instance type of 1 vCPU, 4 GiB and 20 GB, where standard-1 had half a vCPU and 8 GB, and g1t-2core a custom 2 vCPU, 8 GiB and 20 GB, where standard-3 had 16 GB; g1t-4core stays standard-4, which already had 20 GB. 1 vCPU is the smallest a custom type may have, and Cloudflare bills CPU only as it is used, so the doubled vCPU costs only what a job uses of it. The contracts' instance table, its TypeScript mirror and the billing keeper's standard sandbox say the same sizes; the price scales, worked out as before from Cloudflare's list prices with every vCPU busy and the Durable Object behind each, are now 1.9 for g1t-2core and 3.4 for g1t-4core, against the larger standard machine, and the fallbacks for a sandbox second (33 millionths of a dollar with its vCPU busy) and a build second (16) follow it. A test holds wrangler.jsonc's sizes to the contracts', and another the scales to the list prices. The docs' machine tables, the larger machines' prices and the Cloudflare deploy guide say so. | 117 | }); |
This file's history is long; its oldest lines are credited to the oldest commit read.