codefloe/infrastructure-as-code
Watch
1
8
Fork
You've already forked infrastructure-as-code
1

feat(forgejo): sell add-ons through Creem's sandbox on dev #297

Merged
pat-s merged 1 commit from feat/billing-dev into main 2026-09-30 15:34:47 +00:00
Owner

Turn on the fork's paid add-ons (codefloe/forgejo-codefloe#180) on dev.codefloe.com, selling through the sandbox of Creem's codefloe store so nothing is charged.

Changes

  • .envrc: read the sandbox API key from saas/creem/sandbox/api-keys/test as CREEM_API_KEY_DEV.
  • environments/dev/host_vars/git-dev.yaml: add forgejo_billing_* (API key, test mode, webhook id and three products) and render [billing], [billing.creem] and one [billing.product.<key>] per product into forgejo.ini.
    • ci-1000: 1,000 CI minutes per unit on time:ci:all and time:ci:class:linux, EUR 5.00 per unit and month, up to 20 units.
    • git-2g: 2 GiB per unit on size:repos:all, EUR 1.00 per unit and month (EUR 0.50/GiB), up to 25 units.
    • assets-5g: 5 GiB of asset storage per unit, EUR 1.00 per unit and month (EUR 0.20/GiB), up to 20 units. It is a shared pool: it names size:assets:all and each of size:assets:packages:all, size:assets:attachments:all and size:assets:artifacts, so it raises the all-assets rule, which bounds the total, and each per-type cap, and the 5 GiB can go to packages, attachments or artifacts in any mix (tested in forgejo-codefloe#184).
    • The subjects match the existing CI quota (all), CI quota (Linux), git, all-assets, packages, attachments and action-artifacts rules, without which a product is offered to nobody.
  • environments/dev/host_vars/git-dev.yaml: set the all-assets rule from unlimited to 32G, the sum of the packages (20G), attachments (10G) and artifacts (2G) caps, so it never binds on its own and only becomes the pool the asset add-on raises. Wiki edits are checked against it too (Forgejo walks size:wiki up to size:assets:all), so they are refused once all three asset types are full.
    • Storage comes in the smallest steps Creem allows: it refuses a price under EUR 1.00, and its fee (3.9% + USD 0.40) is taken on every monthly payment. Git data sits on triple-replicated Ceph with hourly backups (about EUR 0.02/GiB-month in cash, about EUR 0.12 with the Ceph hosts fully charged); packages sit in Scaleway object storage (about EUR 0.016/GiB-month plus about EUR 0.011/GiB per download). Prices are read from Creem, so changing one needs no deploy.
  • playbooks/tasks/forgejo-billing.yaml, imported by playbook-git.yaml before forgejo.ini is rendered: read the webhook's signing secret from Creem's API, and fail the deploy when a configured product is unknown to the store.
    The secret is read rather than stored in OpenBao so it cannot go stale when the webhook is re-created, and hosts without forgejo_billing_products (prod) skip it.
  • tests/test_forgejo_deploy.py: run the task file against a fake Creem for success, a missing webhook, an unknown product and a missing key, and check neither the key nor the secret reaches the output.

The products (prod_hvcQ0FgYh2azUIxO4qSLE, prod_7QItuJHW1pMLMgWXglSm0A, prod_5KkBsxGix0zi2hELTjBNrn) and the webhook (wh_test_7hvFFFsrrhhqmMW0olYPZi, https://dev.codefloe.com/-/billing/creem/webhook, checkout and subscription events) were created in the sandbox store for this.

Validation

  • Deployed to git-dev from this branch with playbook-git.yaml: ok=120 changed=9 failed=0; the billing pre-tasks read the secret and found both products.
  • End to end on dev.codefloe.com with a throwaway user billing-e2e: bought 2 units of ci-1000 through Creem's sandbox checkout (test card 4111 1111 1111 1111), and the webhook raised CI quota (all) and CI quota (Linux) from 180000 to 300000 seconds.
    Changing the quantity to 3 raised them to 360000, "Manage billing" opened the buyer's Creem portal, and "Cancel subscription" left the add-on counting as scheduled_cancel until 2026-10-29.
    All five Creem webhook deliveries were answered 200.
  • The storage products (the asset one first sold as "5 GiB package storage" on packages only) replaced a first git-10g (10 GiB for EUR 3.00, prod_64cbme5ejjuB10qCDM9mDV) after review, and have not been bought on dev yet.
  • python3 -m unittest discover -s tests passes apart from test_maintenance_strategy, which cannot import ansible on agent-dev's Homebrew Python and is unrelated.
  • prek (ansible-lint, prettier, check yaml, detect secrets) passes.

Not done here

  • Production also needs all-assets: 32G and assets: -1 in every custom quota with an unlimited asset type (packages: -1 for crowci, crow-plugins, pat-s, codefloe, devxy, ricochet), or their registries would be capped at 32G.
  • Production: it needs the live key (saas/creem/prod/api-keys/main), live products, a live webhook, and the keys in the CI deploy's OpenBao mapping (forgejo-deploy-openbao.yaml).
  • The sandbox subscription sub_4FQnnMqxV0H7CEzyvMXM44 of billing-e2e is left to end on its own on 2026-10-29.
Turn on the fork's paid add-ons (codefloe/forgejo-codefloe#180) on dev.codefloe.com, selling through the sandbox of Creem's `codefloe` store so nothing is charged. ## Changes - `.envrc`: read the sandbox API key from `saas/creem/sandbox/api-keys/test` as `CREEM_API_KEY_DEV`. - `environments/dev/host_vars/git-dev.yaml`: add `forgejo_billing_*` (API key, test mode, webhook id and three products) and render `[billing]`, `[billing.creem]` and one `[billing.product.<key>]` per product into `forgejo.ini`. - `ci-1000`: 1,000 CI minutes per unit on `time:ci:all` and `time:ci:class:linux`, EUR 5.00 per unit and month, up to 20 units. - `git-2g`: 2 GiB per unit on `size:repos:all`, EUR 1.00 per unit and month (EUR 0.50/GiB), up to 25 units. - `assets-5g`: 5 GiB of asset storage per unit, EUR 1.00 per unit and month (EUR 0.20/GiB), up to 20 units. It is a shared pool: it names `size:assets:all` and each of `size:assets:packages:all`, `size:assets:attachments:all` and `size:assets:artifacts`, so it raises the `all-assets` rule, which bounds the total, and each per-type cap, and the 5 GiB can go to packages, attachments or artifacts in any mix (tested in forgejo-codefloe#184). - The subjects match the existing `CI quota (all)`, `CI quota (Linux)`, `git`, `all-assets`, `packages`, `attachments` and `action-artifacts` rules, without which a product is offered to nobody. - `environments/dev/host_vars/git-dev.yaml`: set the `all-assets` rule from unlimited to 32G, the sum of the packages (20G), attachments (10G) and artifacts (2G) caps, so it never binds on its own and only becomes the pool the asset add-on raises. Wiki edits are checked against it too (Forgejo walks `size:wiki` up to `size:assets:all`), so they are refused once all three asset types are full. - Storage comes in the smallest steps Creem allows: it refuses a price under EUR 1.00, and its fee (3.9% + USD 0.40) is taken on every monthly payment. Git data sits on triple-replicated Ceph with hourly backups (about EUR 0.02/GiB-month in cash, about EUR 0.12 with the Ceph hosts fully charged); packages sit in Scaleway object storage (about EUR 0.016/GiB-month plus about EUR 0.011/GiB per download). Prices are read from Creem, so changing one needs no deploy. - `playbooks/tasks/forgejo-billing.yaml`, imported by `playbook-git.yaml` before `forgejo.ini` is rendered: read the webhook's signing secret from Creem's API, and fail the deploy when a configured product is unknown to the store. The secret is read rather than stored in OpenBao so it cannot go stale when the webhook is re-created, and hosts without `forgejo_billing_products` (prod) skip it. - `tests/test_forgejo_deploy.py`: run the task file against a fake Creem for success, a missing webhook, an unknown product and a missing key, and check neither the key nor the secret reaches the output. The products (`prod_hvcQ0FgYh2azUIxO4qSLE`, `prod_7QItuJHW1pMLMgWXglSm0A`, `prod_5KkBsxGix0zi2hELTjBNrn`) and the webhook (`wh_test_7hvFFFsrrhhqmMW0olYPZi`, `https://dev.codefloe.com/-/billing/creem/webhook`, checkout and subscription events) were created in the sandbox store for this. ## Validation - Deployed to git-dev from this branch with `playbook-git.yaml`: `ok=120 changed=9 failed=0`; the billing pre-tasks read the secret and found both products. - End to end on dev.codefloe.com with a throwaway user `billing-e2e`: bought 2 units of `ci-1000` through Creem's sandbox checkout (test card 4111 1111 1111 1111), and the webhook raised `CI quota (all)` and `CI quota (Linux)` from 180000 to 300000 seconds. Changing the quantity to 3 raised them to 360000, "Manage billing" opened the buyer's Creem portal, and "Cancel subscription" left the add-on counting as `scheduled_cancel` until 2026-10-29. All five Creem webhook deliveries were answered 200. - The storage products (the asset one first sold as "5 GiB package storage" on packages only) replaced a first `git-10g` (10 GiB for EUR 3.00, `prod_64cbme5ejjuB10qCDM9mDV`) after review, and have not been bought on dev yet. - `python3 -m unittest discover -s tests` passes apart from `test_maintenance_strategy`, which cannot import `ansible` on agent-dev's Homebrew Python and is unrelated. - prek (ansible-lint, prettier, check yaml, detect secrets) passes. ## Not done here - Production also needs `all-assets: 32G` and `assets: -1` in every custom quota with an unlimited asset type (`packages: -1` for crowci, crow-plugins, pat-s, codefloe, devxy, ricochet), or their registries would be capped at 32G. - Production: it needs the live key (`saas/creem/prod/api-keys/main`), live products, a live webhook, and the keys in the CI deploy's OpenBao mapping (`forgejo-deploy-openbao.yaml`). - The sandbox subscription `sub_4FQnnMqxV0H7CEzyvMXM44` of `billing-e2e` is left to end on its own on 2026-10-29.
pat-s force-pushed feat/billing-dev from 8f144ad08b
All checks were successful
ci/crow/pr/check-PR/19 Pipeline was successful
ci/crow/pr/check-PR/21 Pipeline was successful
ci/crow/pr/check-PR/18 Pipeline was successful
ci/crow/pr/tofu/2 Pipeline was successful
ci/crow/pr/maintenance-check Pipeline was successful
ci/crow/pr/tofu/1 Pipeline was successful
ci/crow/pr/install-deps Pipeline was successful
ci/crow/pr/check-PR/3 Pipeline was successful
ci/crow/pr/check-PR/4 Pipeline was successful
ci/crow/pr/check-PR/1 Pipeline was successful
ci/crow/pr/check-PR/6 Pipeline was successful
ci/crow/pr/check-PR/10 Pipeline was successful
ci/crow/pr/check-PR/9 Pipeline was successful
ci/crow/pr/check-PR/11 Pipeline was successful
ci/crow/pr/check-PR/14 Pipeline was successful
ci/crow/pr/check-PR/12 Pipeline was successful
ci/crow/pr/check-PR/2 Pipeline was successful
ci/crow/pr/check-PR/8 Pipeline was successful
ci/crow/pr/check-PR/7 Pipeline was successful
ci/crow/pr/check-PR/13 Pipeline was successful
ci/crow/pr/check-PR/15 Pipeline was successful
ci/crow/pr/check-PR/17 Pipeline was successful
ci/crow/pr/check-PR/22 Pipeline was successful
ci/crow/pr/check-PR/20 Pipeline was successful
ci/crow/pr/check-PR/5 Pipeline was successful
ci/crow/pr/check-PR/16 Pipeline was successful
to 4e31b040a4
All checks were successful
ci/crow/pr/tofu/1 Pipeline was successful
ci/crow/pr/tofu/2 Pipeline was successful
ci/crow/pr/maintenance-check Pipeline was successful
ci/crow/pr/check-PR/2 Pipeline was successful
ci/crow/pr/check-PR/4 Pipeline was successful
ci/crow/pr/check-PR/7 Pipeline was successful
ci/crow/pr/check-PR/11 Pipeline was successful
ci/crow/pr/check-PR/9 Pipeline was successful
ci/crow/pr/check-PR/16 Pipeline was successful
ci/crow/pr/check-PR/1 Pipeline was successful
ci/crow/pr/check-PR/21 Pipeline was successful
ci/crow/pr/check-PR/5 Pipeline was successful
ci/crow/pr/install-deps Pipeline was successful
ci/crow/pr/check-PR/3 Pipeline was successful
ci/crow/pr/check-PR/6 Pipeline was successful
ci/crow/pr/check-PR/13 Pipeline was successful
ci/crow/pr/check-PR/17 Pipeline was successful
ci/crow/pr/check-PR/19 Pipeline was successful
ci/crow/pr/check-PR/8 Pipeline was successful
ci/crow/pr/check-PR/10 Pipeline was successful
ci/crow/pr/check-PR/14 Pipeline was successful
ci/crow/pr/check-PR/12 Pipeline was successful
ci/crow/pr/check-PR/18 Pipeline was successful
ci/crow/pr/check-PR/20 Pipeline was successful
ci/crow/pr/check-PR/15 Pipeline was successful
ci/crow/pr/check-PR/22 Pipeline was successful
2026-09-30 07:25:18 +00:00
Compare
pat-s force-pushed feat/billing-dev from 4e31b040a4
All checks were successful
ci/crow/pr/tofu/1 Pipeline was successful
ci/crow/pr/tofu/2 Pipeline was successful
ci/crow/pr/maintenance-check Pipeline was successful
ci/crow/pr/check-PR/2 Pipeline was successful
ci/crow/pr/check-PR/4 Pipeline was successful
ci/crow/pr/check-PR/7 Pipeline was successful
ci/crow/pr/check-PR/11 Pipeline was successful
ci/crow/pr/check-PR/9 Pipeline was successful
ci/crow/pr/check-PR/16 Pipeline was successful
ci/crow/pr/check-PR/1 Pipeline was successful
ci/crow/pr/check-PR/21 Pipeline was successful
ci/crow/pr/check-PR/5 Pipeline was successful
ci/crow/pr/install-deps Pipeline was successful
ci/crow/pr/check-PR/3 Pipeline was successful
ci/crow/pr/check-PR/6 Pipeline was successful
ci/crow/pr/check-PR/13 Pipeline was successful
ci/crow/pr/check-PR/17 Pipeline was successful
ci/crow/pr/check-PR/19 Pipeline was successful
ci/crow/pr/check-PR/8 Pipeline was successful
ci/crow/pr/check-PR/10 Pipeline was successful
ci/crow/pr/check-PR/14 Pipeline was successful
ci/crow/pr/check-PR/12 Pipeline was successful
ci/crow/pr/check-PR/18 Pipeline was successful
ci/crow/pr/check-PR/20 Pipeline was successful
ci/crow/pr/check-PR/15 Pipeline was successful
ci/crow/pr/check-PR/22 Pipeline was successful
to a1bba6e83c
All checks were successful
ci/crow/pr/maintenance-check Pipeline was successful
ci/crow/pr/install-deps Pipeline was successful
ci/crow/pr/check-PR/1 Pipeline was successful
ci/crow/pr/tofu/1 Pipeline was successful
ci/crow/pr/tofu/2 Pipeline was successful
ci/crow/pr/check-PR/21 Pipeline was successful
ci/crow/pr/check-PR/3 Pipeline was successful
ci/crow/pr/check-PR/6 Pipeline was successful
ci/crow/pr/check-PR/7 Pipeline was successful
ci/crow/pr/check-PR/22 Pipeline was successful
ci/crow/pr/check-PR/8 Pipeline was successful
ci/crow/pr/check-PR/4 Pipeline was successful
ci/crow/pr/check-PR/2 Pipeline was successful
ci/crow/pr/check-PR/10 Pipeline was successful
ci/crow/pr/check-PR/12 Pipeline was successful
ci/crow/pr/check-PR/9 Pipeline was successful
ci/crow/pr/check-PR/19 Pipeline was successful
ci/crow/pr/check-PR/20 Pipeline was successful
ci/crow/pr/check-PR/16 Pipeline was successful
ci/crow/pr/check-PR/11 Pipeline was successful
ci/crow/pr/check-PR/17 Pipeline was successful
ci/crow/pr/check-PR/14 Pipeline was successful
ci/crow/pr/check-PR/15 Pipeline was successful
ci/crow/pr/check-PR/13 Pipeline was successful
ci/crow/pr/check-PR/18 Pipeline was successful
ci/crow/pr/check-PR/5 Pipeline was successful
2026-09-30 08:02:03 +00:00
Compare
pat-s merged commit 002766af16 into main 2026-09-30 15:34:47 +00:00
pat-s deleted branch feat/billing-dev 2026-09-30 15:34:47 +00:00
Sign in to join this conversation.
No description provided.