Skip to content
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
42 changes: 42 additions & 0 deletions .github/workflows/renovate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Renovate

# Self-hosted Renovate runner.
# Focused rollout: Renovate owns version updates for the CLI's Go modules (the
# Bluelink dependency chain) via `includePaths` in renovate.json. Dependabot still
# handles the Rust/Node/Python runtime ecosystems (version updates) and security
# updates repo-wide. See RENOVATE.md.
on:
schedule:
# Hourly so the internal-cascade rule (which bypasses the weekly schedule)
# can react promptly to upstream Bluelink lib releases.
- cron: "0 * * * *"
workflow_dispatch:
inputs:
logLevel:
description: "Renovate log level"
required: false
default: "info"
dryRun:
description: "Dry run (full|null)"
required: false
default: "null"

concurrency:
group: renovate
cancel-in-progress: false

jobs:
renovate:
runs-on: ubuntu-latest
steps:
- name: Run Renovate
uses: renovatebot/github-action@v41.0.0
with:
token: ${{ secrets.RENOVATE_TOKEN }}
env:
RENOVATE_PLATFORM: github
RENOVATE_REPOSITORIES: ${{ github.repository }}
RENOVATE_ONBOARDING: "false"
RENOVATE_REQUIRE_CONFIG: "required"
RENOVATE_DRY_RUN: ${{ inputs.dryRun || 'null' }}
LOG_LEVEL: ${{ inputs.logLevel || 'info' }}
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,9 @@ node_modules
**/.claude

blueprint-ls.log

# Design records, implementation plans and working notes. Kept next to the
# project they describe but deliberately unpublished, since the documentation
# that ships lives in the celerity docs site rather than here. One rule covers
# every sub-project, so a new one needs no change to this file.
**/docs/internal/
100 changes: 100 additions & 0 deletions RENOVATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# Dependency automation: Renovate (CLI / Bluelink chain) + Dependabot

Celerity is a mixed monorepo consisting of a Go CLI (`apps/cli`), local dev helper tools (e.g. `apps/local-events`), the Rust runtime libs
(`libs/runtime`), and the Node.js / Python runtime SDKs and wrappers. This is a
**focused Renovate rollout**: Renovate owns version updates for the **CLI's Go
modules only** which is a part of the Bluelink dependency chain, while Dependabot keeps managing
the Rust/Node/Python ecosystems (and security updates repo-wide) as before.

`apps/cli` is a **Bluelink consumer**. Its `go.mod` pulls in the core Bluelink
libs and a sibling module that rides the same release cascade:

- `github.com/newstack-cloud/bluelink/libs/blueprint`
- `github.com/newstack-cloud/bluelink/libs/blueprint-state`
- `github.com/newstack-cloud/bluelink/libs/common`
- `github.com/newstack-cloud/bluelink/libs/deploy-engine-client`
- `github.com/newstack-cloud/deploy-cli-sdk`

So Celerity joins `bluelink`, `celerity-provider-aws`, and `deploy-cli-sdk` as a
repo in the Bluelink graph, and its config is layered exactly like theirs:

```
newstack-cloud/renovate-config//default ← org-wide policy; ALL repos
▲
│ extends
newstack-cloud/bluelink//renovate/bluelink-consumers ← Bluelink cascade only
▲
│ extends
celerity (scoped to apps/cli via includePaths)
```

- **Org layer** ([`newstack-cloud/renovate-config`](https://github.com/newstack-cloud/renovate-config))
— universal, product-agnostic policy: schedule, the `deps` / `ci(deps)` commit
convention, tiered auto-merge (minor/patch/digest auto-merge, majors held), and
the Dependabot-security-only stance.
- **Bluelink layer** ([`bluelink//renovate/bluelink-consumers`](https://github.com/newstack-cloud/bluelink/blob/main/renovate/bluelink-consumers.json))
- the cascade rule: auto-merge internal `github.com/newstack-cloud/*` bumps and
let them bypass the weekly schedule so the chain reacts promptly.
- **Repo layer** ([`renovate.json`](renovate.json)) - `includePaths: ["apps/cli/**"]`
keeps Renovate out of the Rust/Node/Python trees, plus a `deps(cli)` commit
scope and a group so a component's simultaneous bumps land in one PR (no go.sum
conflicts).

## Why scoped to the CLI

The org preset extends `config:recommended`, which would otherwise enable
Renovate across every ecosystem in the repo (cargo, npm, pip) and produce PRs that
compete with Dependabot's existing version updates for those trees. `includePaths`
narrows Renovate to `apps/cli/**` so this rollout is limited to the Bluelink chain.
The matching `gomod` block was removed from
[`.github/dependabot.yml`](.github/dependabot.yml) so only one tool bumps the CLI.

Broadening later (Renovate owns the whole repo, Dependabot → security-only, per
the org policy) is a matter of dropping `includePaths` and retiring the remaining
Dependabot version-update blocks.

## How the cascade works

- **Bump commits keep the `deps(cli): …` prefix** that release-please expects, so
release behaviour is unchanged and only the tool that opens the PR differs.
- **Auto-merge tiers** (all CI-gated by `platformAutomerge`):
- internal `github.com/newstack-cloud/*` bumps → auto-merge, bypassing the
weekly schedule so the cascade reacts promptly;
- third-party minor/patch/digest → auto-merge
- majors → held for manual review (`major-update` label).
- **The human gate is the release PR.** Renovate lands the `deps(cli)` bump on
`main`; release-please then opens the "release cli" PR for a person to review
and merge.

```
bluelink lib (e.g. libs/blueprint) release published
→ deps(cli): bump blueprint (+ blueprint-state, common, deploy-engine-client) [auto-merged]
→ release-please "release cli" PR [human merges] → cli published
deploy-cli-sdk release published
→ deps(cli): bump deploy-cli-sdk [auto-merged] → release PR → ...
```

## One-time setup

1. **`RENOVATE_TOKEN` secret** in this repo, a **GitHub App installation token or
PAT**, *not* `GITHUB_TOKEN`. PRs opened by `GITHUB_TOKEN` don't trigger other
workflows, so CI wouldn't run on Renovate PRs and auto-merge could never
complete. The token needs **read access to `newstack-cloud/renovate-config`**
(org preset) and **`newstack-cloud/bluelink`** (cascade preset). Reuse the
org-level GitHub App already installed on the other Bluelink-graph repos.
2. The [`renovate.yml`](.github/workflows/renovate.yml) workflow runs hourly and on
demand. Trigger a **dry run** first via *Actions → Renovate → Run workflow* with
`dryRun: full` and confirm it only proposes `apps/cli` Go bumps.

## Validate before changes

```bash
npx --yes --package renovate renovate-config-validator renovate.json
```

## Follow-up

Two docs in the `bluelink` repo still list the cascade consumers as
`bluelink · celerity-provider-aws · deploy-cli-sdk` (its `RENOVATE.md` diagram and
the `renovate/bluelink-consumers.json` description). Add `celerity` there so the
consumer list stays accurate.
170 changes: 170 additions & 0 deletions apps/cli/buildmanifest/manifest.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
// Package buildmanifest defines the on-disk build manifest produced by the
// Celerity CLI build step and consumed by the Celerity transformer plugin when
// producing concrete deploy resources (e.g. AWS Lambda function definitions).
//
// It is deliberately a small, dependency-free package (standard library only)
// so it can be shared as the single source of truth for the manifest wire
// format across the CLI and the transformer, instead of each side keeping a
// hand-copied struct that can silently drift.
package buildmanifest

import (
"encoding/json"
"fmt"
"os"
"path/filepath"
)

const (
// Version is the current build manifest schema version.
Version = "1"

// FileName is the repo-relative path the CLI writes the manifest to.
FileName = ".celerity/build-manifest.json"

// ResourceLinksFilename is the name of the blueprint-derived resource
// links JSON file bundled into the Lambda app archive. The SDK reads it
// from the handler's module directory on cold start, removing the need to
// pass the payload through environment variables (which have a tight 4 KB
// total limit on AWS Lambda).
ResourceLinksFilename = "__celerity_resource_links__.json"

// HandlerScopeFilename is the name of the per-handler resource scope file
// bundled alongside the resource links. Resource links describe every
// resource in the application; this records which of them each handler
// uses, and so which resource layers a given handler initialises.
//
// It is a separate file rather than a change to the resource links format
// because the SDK ships in the runtime layer at its published version while
// the CLI writing these files is whatever the developer has installed, so
// the two are routinely out of step. An SDK that predates this file ignores
// it and behaves as before, and a newer SDK falls back when it is absent.
HandlerScopeFilename = "__celerity_handler_scope__.json"

// Artifact type discriminators recorded on Artifact.Type.
ArtifactTypeContainerImage = "container-image"
ArtifactTypeLambdaArchive = "lambda-archive"
ArtifactTypeLambdaLayer = "lambda-layer"
)

// Manifest records build artifacts produced by the build step. Written to
// FileName and referenced by the deploy engine via a context variable pointer.
//
// Target-specific output (AWS Lambda, container, etc.) lives under a dedicated
// typed sub-manifest so adding a new strategy does not require changing the
// top-level shape.
type Manifest struct {
Version string `json:"version"`
Runtime string `json:"runtime"`
Target string `json:"target"`
Handlers map[string]*HandlerArtifacts `json:"handlers"`
// Lambda is populated only when the build target is aws-serverless.
Lambda *LambdaManifest `json:"lambda,omitempty"`
// RemoteURL is the cloud storage URL where the manifest itself has been
// uploaded, set after a successful upload. Populated only in the
// locally-persisted copy; the uploaded object does not contain this field
// (it is set after marshalling for upload). Consumers reading the uploaded
// manifest can ignore it.
RemoteURL string `json:"remoteUrl,omitempty"`
}

// HandlerArtifacts holds per-handler build metadata. Target-specific overrides
// (e.g. a custom dependency layer for Lambda) live under their own sub-struct
// so each strategy owns the shape of its per-handler data.
type HandlerArtifacts struct {
Lambda *LambdaHandlerArtifacts `json:"lambda,omitempty"`
}

// Artifact represents a single build artifact (zip archive or image).
type Artifact struct {
Type string `json:"type"`
LocalPath string `json:"localPath,omitempty"`
S3Bucket string `json:"s3Bucket,omitempty"`
S3Key string `json:"s3Key,omitempty"`
ImageURI string `json:"imageUri,omitempty"`
ContentHash string `json:"contentHash,omitempty"`
Size int64 `json:"size,omitempty"`
}

// LambdaManifest holds AWS Lambda-specific build output referenced by every
// handler's Lambda function. Populated by the CLI's Lambda build strategy and
// read by the Celerity transformer plugin.
type LambdaManifest struct {
// AppCode is the single shared code asset, the whole app source tree plus
// the generated Celerity Lambda entry point file.
AppCode *Artifact `json:"appCode,omitempty"`
// EntryPoint is the Lambda Handler field value, identical for every handler
// in a project (e.g. "__celerity_lambda_entry__.handler").
EntryPoint string `json:"entryPoint,omitempty"`
// SharedLayer is the production dependency layer used by handlers that do
// not opt into a custom per-handler dep layer.
SharedLayer *Artifact `json:"sharedLayer,omitempty"`
// Architecture is the instruction set the archive's code is built for,
// as a GOARCH name ("arm64", "amd64"). Empty for an interpreted runtime,
// where the code is not built for one.
//
// Recorded because a compiled handlers executable and the function it is
// deployed to have to agree. A mismatch is a valid archive that the kernel
// refuses to exec, surfacing as a bare exit status 126. The transformer
// declares the function's architecture from this field.
Architecture string `json:"architecture,omitempty"`
// LambdaRuntime is the concrete Lambda runtime identifier the functions
// need, where the build has determined it. A compiled executable runs on
// a custom runtime ("provided.al2023") rather than on one named by the
// blueprint's portable runtime identifier.
LambdaRuntime string `json:"lambdaRuntime,omitempty"`
// MaintenanceRunner is the database maintenance runner's archive, built
// only when the blueprint has a celerity/sqlDatabase.
//
// It is a compiled Go binary rather than application code, so it is neither
// the app bundle nor a layer. It shares nothing with them and is versioned
// with the CLI rather than with the user's source.
MaintenanceRunner *Artifact `json:"maintenanceRunner,omitempty"`
}

// LambdaHandlerArtifacts holds per-handler Lambda overrides.
type LambdaHandlerArtifacts struct {
// Dependencies is the handler's custom dependency layer, populated only
// when the developer has declared handlerDependencies. Nil handlers fall
// back to LambdaManifest.SharedLayer.
Dependencies *Artifact `json:"dependencies,omitempty"`
}

// Write writes the build manifest to FileName, creating the parent directory
// if needed.
func Write(manifest *Manifest) error {
dir := filepath.Dir(FileName)
if err := os.MkdirAll(dir, 0755); err != nil {
return fmt.Errorf("creating manifest directory: %w", err)
}

data, err := json.MarshalIndent(manifest, "", " ")
if err != nil {
return fmt.Errorf("marshalling build manifest: %w", err)
}

if err := os.WriteFile(FileName, data, 0644); err != nil {
return fmt.Errorf("writing build manifest: %w", err)
}

return nil
}

// Read reads the build manifest from FileName. Returns (nil, nil) if the file
// does not exist.
func Read() (*Manifest, error) {
data, err := os.ReadFile(FileName)
if err != nil {
if os.IsNotExist(err) {
return nil, nil
}
return nil, fmt.Errorf("reading build manifest: %w", err)
}

var manifest Manifest
if err := json.Unmarshal(data, &manifest); err != nil {
return nil, fmt.Errorf("parsing build manifest: %w", err)
}

return &manifest, nil
}
Loading
Loading