code-foundry 0.21.1 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/CONTRIBUTING.md +1 -1
- package/.github/actions/setup/action.yml +12 -10
- package/.github/code-foundry.yml +25 -0
- package/.github/code-foundry.yml.example +41 -0
- package/.github/scripts/changed-files.sh +1 -1
- package/.github/scripts/ci.sh +6 -2
- package/.github/scripts/codeql-languages.sh +6 -2
- package/.github/scripts/doctor.sh +4 -2
- package/.github/scripts/init-repo.sh +126 -19
- package/.github/scripts/profile.sh +12 -3
- package/.github/scripts/security.sh +6 -2
- package/.github/scripts/sync-protection.sh +5 -3
- package/.github/scripts/sync-template.sh +135 -20
- package/.github/template.yml +3 -16
- package/.github/workflows/reusable-ci.yml +10 -5
- package/.github/workflows/reusable-codeql.yml +11 -6
- package/.github/workflows/reusable-draft-pr.yml +7 -1
- package/.github/workflows/reusable-release-pr.yml +7 -1
- package/.github/workflows/reusable-release.yml +12 -4
- package/.github/workflows/reusable-security.yml +12 -7
- package/.github/workflows/reusable-test.yml +15 -5
- package/CHANGELOG.md +20 -0
- package/README.md +97 -193
- package/docs/CACHING.md +29 -0
- package/docs/CONFIGURATION.md +87 -0
- package/docs/INITIALIZATION.md +67 -0
- package/docs/PUBLISHING.md +49 -0
- package/docs/README.md +21 -0
- package/docs/RELEASES.md +47 -0
- package/docs/WORKFLOWS.md +66 -0
- package/package.json +2 -1
- package/src/cli.mjs +38 -15
- package/.github/template.yml.example +0 -18
package/README.md
CHANGED
|
@@ -3,229 +3,133 @@
|
|
|
3
3
|
[](https://www.npmjs.com/package/code-foundry)
|
|
4
4
|
[](https://www.npmjs.com/package/code-foundry)
|
|
5
5
|
[](../../actions/workflows/ci.yml)
|
|
6
|
-
[](../../releases/latest)
|
|
7
7
|
|
|
8
|
-
`code-foundry` is a repository
|
|
9
|
-
and mixed-language projects. It
|
|
10
|
-
testing, security automation,
|
|
11
|
-
from one
|
|
8
|
+
`code-foundry` is a versioned repository baseline for TypeScript, Rust, Python,
|
|
9
|
+
Solidity, and mixed-language projects. It provides language-aware workflows,
|
|
10
|
+
native testing, security automation, releases, hooks, repository policy, and
|
|
11
|
+
agent instructions from one initializer.
|
|
12
12
|
|
|
13
13
|
## Quick start
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
npx code-foundry init
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
Or select the project profile explicitly:
|
|
20
|
-
|
|
21
|
-
```bash
|
|
22
|
-
npx code-foundry init \
|
|
23
|
-
--languages typescript,python \
|
|
24
|
-
--features all \
|
|
25
|
-
--package-manager bun
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
Use `code-foundry sync` to update an existing repository and
|
|
29
|
-
`code-foundry doctor` to validate it. Add `--dry-run` to preview changes.
|
|
30
|
-
|
|
31
|
-
Choose the license during initialization without editing generated files:
|
|
32
|
-
|
|
33
|
-
```bash
|
|
34
|
-
npx code-foundry init --license mit
|
|
35
|
-
npx code-foundry init --license agpl-3.0-or-later
|
|
36
|
-
npx code-foundry init --license-file ./legal/LICENSE.txt
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
Reusable workflow callers use the source template's runtime automatically. For
|
|
40
|
-
example, initializing from `NiftyLeague/template-repo` selects that fork's
|
|
41
|
-
runtime without extra flags. Use `--runtime-repository OWNER/REPO` (or
|
|
42
|
-
`REPO_FOUNDRY_RUNTIME_REPOSITORY`) only when you want to override it. The
|
|
43
|
-
selected repository is saved in `.github/template.yml` and rendered into the
|
|
44
|
-
small CI, Test, Security, CodeQL, Draft PR, and Release PR wrappers
|
|
45
|
-
automatically. Use `--runtime-ref REF` (or `REPO_FOUNDRY_RUNTIME_REF`) to pin
|
|
46
|
-
those callers to a fork's release tag or branch; the selected ref is persisted
|
|
47
|
-
alongside the runtime repository.
|
|
48
|
-
|
|
49
|
-
Normal synchronization imports only the local hook, agent-facing command,
|
|
50
|
-
profile/release, initializer, doctor, ownership, and protection entrypoints.
|
|
51
|
-
Workflow-only actions and Security/CodeQL analyzers stay in the versioned
|
|
52
|
-
runtime package and are not duplicated in consumer repositories.
|
|
53
|
-
|
|
54
|
-
The standard Security wrapper uses the same runtime contract, so dependency
|
|
55
|
-
audits and the public-only Dependency Review policy can be upgraded centrally
|
|
56
|
-
without copying security scripts into every consumer repository.
|
|
57
|
-
|
|
58
|
-
CodeQL is also independently reusable through the same contract. It retains
|
|
59
|
-
GitHub's native security-event permissions and language-specific analysis while
|
|
60
|
-
keeping CodeQL separate from CI and dependency security checks.
|
|
61
|
-
|
|
62
|
-
Release automation follows the same model: the consumer keeps a short
|
|
63
|
-
main-branch wrapper while the shared runtime handles Release Please, GitHub
|
|
64
|
-
release metadata, optional npm publication, provenance, and token/trusted
|
|
65
|
-
publishing fallback.
|
|
66
|
-
|
|
67
|
-
The promotion runtimes for Draft PR and Release PR are maintained in the same
|
|
68
|
-
versioned repository and are released before their short consumer callers move
|
|
69
|
-
to a new tag, avoiding a bootstrap cycle.
|
|
70
|
-
|
|
71
|
-
Initialization defaults to AGPL for new repositories. Synchronization defaults
|
|
72
|
-
to `--license preserve`, so an existing repository's license is never replaced
|
|
73
|
-
unless you explicitly select a license or provide `--license-file`.
|
|
74
|
-
|
|
75
|
-
The generated Git hook is intentionally a small launcher. It points at the
|
|
76
|
-
package-managed `.github/scripts/pre-commit.sh`, so repositories do not need to
|
|
77
|
-
maintain a second copy of the language-aware hook logic.
|
|
78
|
-
|
|
79
|
-
## Setup
|
|
80
|
-
|
|
81
|
-
1. Install [mise](https://mise.jdx.dev/).
|
|
82
|
-
2. Run `bash .github/scripts/bootstrap.sh` to install the pinned toolchain, enable hooks, and validate the repository.
|
|
83
|
-
3. Add the repository's standard scripts (`format:check`, `lint`, `type-check`, `build`, `test:unit`, `test:integration`, `test:e2e`, and `test:smoke`) when available. The shared scripts also recognize legacy aliases and skip checks that do not apply to the repository's languages or package manager.
|
|
84
|
-
|
|
85
|
-
## Applying the baseline to an existing repository
|
|
86
|
-
|
|
87
|
-
Run the package entrypoint from the repository root. It updates shared
|
|
88
|
-
workflows, GitHub forms, hooks, policy files, and tool configuration while
|
|
89
|
-
preserving the repository's README, `.mise.toml` selections, extra workflows,
|
|
90
|
-
licenses, and application code.
|
|
15
|
+
Run this from the root of a repository:
|
|
91
16
|
|
|
92
17
|
```bash
|
|
93
18
|
npx code-foundry init
|
|
94
19
|
```
|
|
95
20
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
The initializer is intentionally flag-driven so the same baseline can be used as a small repository package. Language selection controls CodeQL and records the repository profile; feature selection controls which standard workflows are installed. `auto` detects supported languages, while `all` enables every standard workflow. The resolver profiles the repository for language, package manager, project shape, release type, runners, and cache policy.
|
|
99
|
-
|
|
100
|
-
Existing authored documentation and issue/PR templates are preserved by
|
|
101
|
-
default. Pass `--force` when intentionally refreshing those files from the
|
|
102
|
-
baseline; repository-specific workflows and application files remain protected.
|
|
21
|
+
Useful variants:
|
|
103
22
|
|
|
104
23
|
```bash
|
|
105
|
-
#
|
|
106
|
-
|
|
107
|
-
--languages typescript,python \
|
|
108
|
-
--features all \
|
|
109
|
-
--dry-run
|
|
110
|
-
|
|
111
|
-
# Initialize a Rust repository with only the core automation
|
|
112
|
-
bash .github/scripts/init-repo.sh \
|
|
113
|
-
--languages rust \
|
|
114
|
-
--features ci,codeql,security,test
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
Supported profiles are `application`, `monorepo`, and `minimal`; use `auto` to detect one. Supported languages are `typescript`, `rust`, `python`, and `solidity`. Supported feature flags are `ci`, `codeql`, `security`, `test`, `draft-pr`, `release-pr`, `release`, and `dependabot`. Use `--prune` only when you explicitly want disabled standard workflows removed; custom workflows are always preserved. The selected profile is stored in `.github/template.yml`, which makes later syncs repeatable and lets workflows consume repository-specific settings without duplicating the template scripts.
|
|
118
|
-
|
|
119
|
-
Profile precedence is consistent everywhere: explicit CLI flags, then `REPO_FOUNDRY_*` GitHub repository variables/environment values, then `.github/template.yml`, then automatic detection and standard defaults. Useful repository variables include `REPO_FOUNDRY_PROFILE`, `REPO_FOUNDRY_LANGUAGES`, `REPO_FOUNDRY_FEATURES`, `REPO_FOUNDRY_PACKAGE_MANAGER`, `REPO_FOUNDRY_RUNTIME_REPOSITORY`, `REPO_FOUNDRY_RUNTIME_REF`, `REPO_FOUNDRY_RUNNER`, `REPO_FOUNDRY_UNIT_RUNNER`, `REPO_FOUNDRY_CACHE_PACKAGES`, `REPO_FOUNDRY_CACHE_BUILD`, `REPO_FOUNDRY_COVERAGE_MINIMUM`, and `REPO_FOUNDRY_TURBO_REMOTE`. Use CLI flags for one-off initialization; use repository variables for local overrides that should not be committed.
|
|
120
|
-
|
|
121
|
-
Inspect the resolved profile at any time with `bash .github/scripts/profile.sh detect`; use `profile.sh get KEY` when another script needs one setting.
|
|
122
|
-
|
|
123
|
-
## Releases and publishing
|
|
124
|
-
|
|
125
|
-
The standard release workflow uses [Release Please](https://github.com/googleapis/release-please) after changes reach `main`. It opens or updates a versioned release pull request, maintains `CHANGELOG.md`, creates the GitHub release after that PR is merged, and applies semantic version bumps from Conventional Commits. The reusable `release-please-config.json` groups feature, fix, performance, dependency, documentation, test, CI, and maintenance changes in generated notes:
|
|
24
|
+
# Choose languages and the package manager
|
|
25
|
+
npx code-foundry init --languages typescript,python --package-manager bun
|
|
126
26
|
|
|
127
|
-
|
|
128
|
-
-
|
|
129
|
-
- `feat!:`, `fix!:`, or `BREAKING CHANGE:` → major, such as `1.2.3` → `2.0.0`
|
|
130
|
-
|
|
131
|
-
Before `1.0.0`, `feat:` intentionally increments the minor version. This keeps pre-1.0 releases useful without treating every feature as a breaking major.
|
|
132
|
-
|
|
133
|
-
Use `Release-As: 2.0.0` in a commit or pull request body when a specific version is required. Existing `CHANGELOG.md` files are preserved by sync and remain repository-owned.
|
|
134
|
-
|
|
135
|
-
Release behavior is configured in `.github/template.yml`:
|
|
27
|
+
# Choose a license
|
|
28
|
+
npx code-foundry init --license mit
|
|
136
29
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
npm_publish: false # true only for a package published to npm
|
|
30
|
+
# Preview without changing files
|
|
31
|
+
npx code-foundry init --dry-run
|
|
140
32
|
```
|
|
141
33
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
34
|
+
For an existing installation, use `npx code-foundry sync`. Run
|
|
35
|
+
`npx code-foundry doctor` to inspect the resulting repository configuration.
|
|
36
|
+
|
|
37
|
+
If `.github/code-foundry.yml` already exists, initialization uses it automatically.
|
|
38
|
+
You can also supply a different file with `--config PATH`; after changing the
|
|
39
|
+
file, run `npx code-foundry sync` to render the selected configuration.
|
|
40
|
+
|
|
41
|
+
## What it installs
|
|
42
|
+
|
|
43
|
+
- Short workflow callers for CI, Test, Security, CodeQL, Draft PR, Release PR,
|
|
44
|
+
and Release.
|
|
45
|
+
- A small `.githooks/pre-commit` launcher with language-aware formatting and
|
|
46
|
+
linting.
|
|
47
|
+
- `.mise.toml`, optional `mise.lock`, repository profile configuration, and
|
|
48
|
+
standard GitHub forms and policy files.
|
|
49
|
+
- AGENTS instructions, CODEOWNERS, license/notice files, and reusable release
|
|
50
|
+
configuration.
|
|
51
|
+
|
|
52
|
+
The workflow implementation lives in the versioned runtime repository. A
|
|
53
|
+
consumer repository keeps only the callers and the small local entrypoints it
|
|
54
|
+
needs. Custom workflows—such as deployment, indexing, Slither, or search—are
|
|
55
|
+
preserved and can coexist with the standard baseline.
|
|
56
|
+
|
|
57
|
+
## Configuration
|
|
58
|
+
|
|
59
|
+
Initialization is flag-driven. The most important options are:
|
|
60
|
+
|
|
61
|
+
```text
|
|
62
|
+
--profile auto|application|monorepo|minimal
|
|
63
|
+
--languages auto|typescript,rust,python,solidity
|
|
64
|
+
--features all|ci,codeql,security,test,draft-pr,release-pr,release,dependabot
|
|
65
|
+
--package-manager auto|bun|pnpm|yarn|npm
|
|
66
|
+
--runtime-repository OWNER/REPO
|
|
67
|
+
--runtime-ref TAG_OR_BRANCH
|
|
68
|
+
--release-type auto|node|python|rust|simple|none
|
|
69
|
+
--license agpl-3.0-or-later|mit|preserve|none
|
|
70
|
+
--license-file PATH
|
|
160
71
|
```
|
|
161
72
|
|
|
162
|
-
The
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
CI and hooks use Prettier and ESLint for JavaScript/TypeScript, default `rustfmt` and Clippy with warnings-as-errors for Rust, and Ruff formatting/linting for Python.
|
|
169
|
-
|
|
170
|
-
The initializer generates a minimal `.mise.toml` from the selected language and package-manager profile instead of installing every supported tool on every runner. TypeScript/Solidity profiles always pin Node and add Bun only for Bun projects; npm, pnpm, and Yarn use Node/Corepack. CI and Security also honor an explicit `package_manager` profile before inspecting lockfiles. Existing `.mise.toml` files are preserved. Initialization also generates a committed `mise.lock` when mise is available; CI then installs exact tool URLs and checksums without repeating registry/API resolution. Workflow setup restores lockfile-keyed package caches for Bun/npm/pnpm/Yarn, Cargo, and pip; cache misses remain safe because dependencies are always re-created from their lockfiles or manifests. Set `REPO_FOUNDRY_CACHE_PACKAGES=true` when a large Bun project has a measured warm-cache win; the default `auto` policy skips oversized archives.
|
|
73
|
+
The selected profile is saved in `.github/code-foundry.yml`. Explicit flags take
|
|
74
|
+
precedence over `REPO_FOUNDRY_*` environment/repository variables, which take
|
|
75
|
+
precedence over that file and automatic detection. See
|
|
76
|
+
[Configuration reference](docs/CONFIGURATION.md) for the visual configuration
|
|
77
|
+
guide and [Initialization and synchronization](docs/INITIALIZATION.md) for
|
|
78
|
+
the safety and precedence rules.
|
|
171
79
|
|
|
172
|
-
|
|
80
|
+
New repositories default to AGPL-3.0-or-later. Synchronization preserves an
|
|
81
|
+
existing license unless a replacement is explicitly selected. Authored
|
|
82
|
+
documentation, application files, custom workflows, and existing `.mise.toml`
|
|
83
|
+
files are preserved by default; use `--force` or `--prune` only intentionally.
|
|
173
84
|
|
|
174
|
-
|
|
85
|
+
## Workflow model
|
|
175
86
|
|
|
176
|
-
|
|
87
|
+
The standard workflow triggers are:
|
|
177
88
|
|
|
178
|
-
|
|
89
|
+
- Pushes to `main` and `staging`.
|
|
90
|
+
- Pull requests targeting `staging`.
|
|
91
|
+
- Draft PR automation for supported feature/fix branches.
|
|
179
92
|
|
|
180
|
-
|
|
93
|
+
Jobs are language-aware and skip irrelevant setup while remaining visible as
|
|
94
|
+
successful required checks. TypeScript uses ESLint, Prettier, and Bun's native
|
|
95
|
+
test runner. Rust uses `rustfmt`, Clippy with warnings as errors, and native
|
|
96
|
+
Cargo tests. Python uses Ruff, uv/pip-compatible setup, and native Python
|
|
97
|
+
tests. Solidity projects retain their native toolchain and test runner.
|
|
181
98
|
|
|
182
|
-
|
|
99
|
+
CodeQL remains separate from CI and Security. Dependency Review is isolated in
|
|
100
|
+
Security and is skipped where GitHub does not support it, while JavaScript,
|
|
101
|
+
Python, and Rust audits remain available without GitHub Advanced Security.
|
|
183
102
|
|
|
184
|
-
|
|
103
|
+
See [Workflow and CI conventions](docs/WORKFLOWS.md) for triggers, required
|
|
104
|
+
checks, runners, coverage, caching, and custom workflow extensions.
|
|
185
105
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
New Python profiles include pinned `uv` as an accelerated, pip-compatible installer and pinned Ruff as the shared formatter/linter. Repositories with `pyproject.toml` and `uv.lock` use `uv sync --frozen` to materialize the exact environment without repeat resolution; requirements-file projects continue using the uv/pip-compatible fallback. Existing repositories without `uv` continue using pip automatically, while existing custom tool selections and dependency-file formats remain supported.
|
|
189
|
-
|
|
190
|
-
Python Security audits use an isolated cache for `uv tool run` environments containing `pip-audit` when uv is available, so application lockfile changes do not redownload the scanner. They retain the same pip fallback used by CI installation. Independent `requirements.txt` and `requirements-dev.txt` audits run concurrently and aggregate failures. JavaScript, Rust, and Python audit jobs run concurrently when their ecosystems are present. The Python matrix is profile-gated so repositories without applicable Python inputs avoid a no-op runner; JavaScript and Rust retain independent detection so active audits start without waiting for the profile job. Every active ecosystem still reports a failure if its audit fails.
|
|
191
|
-
|
|
192
|
-
CI and Test jobs perform a source-only applicability check before setup. Empty integration, E2E, smoke, or language-specific jobs remain visible as successful required checks but skip runner tool installation and dependency setup.
|
|
193
|
-
|
|
194
|
-
On pull requests and ordinary pushes, CI, Test, and Security also recognize governance-only changes (README, license, issue/PR templates, CODEOWNERS, Code of Conduct, CONTRIBUTING, and SECURITY) and leave the required jobs successful without installing tools or running unrelated checks. Any source, dependency, workflow, profile, or build configuration change runs the full applicable checks; an unavailable diff always falls back to running them.
|
|
195
|
-
|
|
196
|
-
Security dependency audits apply the same fail-open change detection per ecosystem: JavaScript, Rust, and Python audits skip setup for source-only pushes and pull requests that do not change that ecosystem's manifests, lockfiles, audit allowlist, or shared tool configuration. Scheduled scans, manual runs, and uncertain diffs always audit normally.
|
|
197
|
-
|
|
198
|
-
The shared setup action accepts `install-javascript`, `install-python`, and `install-rust` switches. They default to `true` for compatibility, while the standard CI jobs disable ecosystems that their task cannot use: formatting skips project Cargo/Python installs, and lint, type-check, and build skip Python dependency installation. Test jobs pass their task profile (`unit`, `integration`, `e2e`, or `smoke`) and disable unrelated ecosystem caches, dependency installs, and mise tools; mixed-language repositories therefore pay only for languages used by that suite. Mise tool installation defaults to `auto`, so each job installs only configured tools for languages actually detected in the repository. Repositories without `.mise.toml` skip mise entirely and use the runner/project environment; callers can use `mise-scope: all` when a task intentionally spans every configured ecosystem.
|
|
199
|
-
|
|
200
|
-
It also accepts `mise-scope` (`auto`, `all`, `javascript`, `python`, or `rust`). Security's parallel ecosystem matrix uses this to install only the active language toolchain and restore only its package caches; callers that omit it get automatic profile-based tool selection, while `all` remains available for tasks that intentionally span every configured ecosystem.
|
|
201
|
-
|
|
202
|
-
Lightweight orchestration jobs use GitHub's `ubuntu-slim` runner: Draft PR, Release PR, release detection, Release Please, npm publication, dependency review, CodeQL language detection, and dependency audits. Build, format, lint, type-check, integration/E2E/smoke tests, and active CodeQL analysis use full `ubuntu-latest` runners because toolchain initialization, native libraries, browsers, and source analysis may benefit from full runner resources. Unit tests default to `ubuntu-slim` for small projects, but dependency-heavy or native suites should set the repository variable `REPO_FOUNDRY_UNIT_RUNNER=ubuntu-latest`; measurements across the maintained monorepos showed materially faster installs and test execution on the full runner.
|
|
203
|
-
|
|
204
|
-
Release and Security metadata jobs also use blobless checkouts where a checkout is needed, reducing source transfer while preserving on-demand manifest access.
|
|
205
|
-
|
|
206
|
-
CodeQL keeps every configured language check visible but skips analyzers whose source, dependencies, or configuration were untouched by a push or pull request. Unchanged analyzer jobs use `ubuntu-slim` and skip both checkout and analysis while remaining visible to branch protection; changed analyzers use full `ubuntu-latest` runners. Its detection job uses a blobless, sparse checkout because it only needs Git paths, metadata, and repository manifests; analyzer jobs still use full checkouts. Scheduled and manually dispatched CodeQL runs remain full scans.
|
|
207
|
-
|
|
208
|
-
CodeQL uploads SARIF findings for GitHub code scanning but does not archive the intermediate database in the reusable baseline; this keeps coverage and alert processing while avoiding an unnecessary database transfer. The required workflow check gates on successful SARIF upload acknowledgment and does not wait for GitHub’s asynchronous post-upload processing, shortening the CI critical path while retaining the uploaded findings.
|
|
209
|
-
|
|
210
|
-
Coverage is enforced at 80% for Python and Bun test suites when those ecosystems expose coverage support. Rust projects must keep their native test suites green; repositories with `cargo-llvm-cov` should enforce the same 80% line target in their Cargo coverage configuration.
|
|
211
|
-
|
|
212
|
-
## Test runner standard
|
|
106
|
+
## Releases and publishing
|
|
213
107
|
|
|
214
|
-
|
|
108
|
+
The standard flow promotes `staging` into `main`, lets Release Please open a
|
|
109
|
+
versioned release PR, and creates a GitHub release after that PR is merged.
|
|
110
|
+
npm publication is opt-in through `npm_publish: true` and supports npm trusted
|
|
111
|
+
publishing or an `NPM_TOKEN` fallback.
|
|
215
112
|
|
|
216
|
-
|
|
113
|
+
Read [Release management](docs/RELEASES.md) and
|
|
114
|
+
[Publishing packages](docs/PUBLISHING.md) before enabling automated
|
|
115
|
+
publishing. They are intentionally written with placeholders so they can be
|
|
116
|
+
copied into other repositories.
|
|
217
117
|
|
|
218
|
-
|
|
118
|
+
## Documentation and extensions
|
|
219
119
|
|
|
220
|
-
|
|
221
|
-
-
|
|
120
|
+
The `docs/` directory contains generalized operational guides. Add
|
|
121
|
+
repository-specific documentation there as well; synchronization does not
|
|
122
|
+
replace files in `docs/`.
|
|
222
123
|
|
|
223
|
-
|
|
124
|
+
- [Documentation index](docs/README.md)
|
|
125
|
+
- [Initialization and synchronization](docs/INITIALIZATION.md)
|
|
126
|
+
- [Workflow and CI conventions](docs/WORKFLOWS.md)
|
|
127
|
+
- [Release management](docs/RELEASES.md)
|
|
128
|
+
- [Publishing packages](docs/PUBLISHING.md)
|
|
129
|
+
- [Caching and remote caching](docs/CACHING.md)
|
|
224
130
|
|
|
225
131
|
## License
|
|
226
132
|
|
|
227
|
-
Unless a repository says otherwise, new material is licensed under the GNU
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
The CodeQL workflow uses GitHub's official CodeQL actions, detects Actions, TypeScript, Python, and Rust automatically, and runs each language in parallel. It runs automatically for public repositories and skips itself for private repositories unless GitHub Code Security is enabled. Dependency Review is isolated in the Security workflow and runs only for public pull requests. If GitHub's Code Scanning default setup is enabled, disable that generated `dynamic/github-code-scanning/codeql` workflow after installing this checked-in workflow; otherwise GitHub will run two CodeQL analyzers. The default setup can be disabled with `gh api --method PATCH repos/OWNER/REPO/code-scanning/default-setup -f state=not-configured` when Code Security is available.
|
|
133
|
+
Unless a repository says otherwise, new material is licensed under the GNU
|
|
134
|
+
Affero General Public License v3.0-or-later. See [LICENSE](LICENSE) and
|
|
135
|
+
[NOTICE](NOTICE).
|
package/docs/CACHING.md
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Caching and remote caching
|
|
2
|
+
|
|
3
|
+
## Local workflow caching
|
|
4
|
+
|
|
5
|
+
The standard runtime uses lockfile- and configuration-keyed caches for package
|
|
6
|
+
stores, Cargo, pip/uv, browser binaries, and applicable build artifacts. Cache
|
|
7
|
+
misses always fall back to a clean locked install. Do not cache credentials,
|
|
8
|
+
generated secrets, or mutable environments without an exact dependency key.
|
|
9
|
+
|
|
10
|
+
Repositories should measure before enabling large installed-tree or build
|
|
11
|
+
caches. Set repository variables such as `REPO_FOUNDRY_CACHE_PACKAGES` and
|
|
12
|
+
`REPO_FOUNDRY_CACHE_BUILD` only when a repeatable warm-cache benefit is proven.
|
|
13
|
+
|
|
14
|
+
## Turborepo and Vercel Remote Caching
|
|
15
|
+
|
|
16
|
+
Turborepo repositories can opt into Vercel Remote Caching with:
|
|
17
|
+
|
|
18
|
+
- Secret: `TURBO_TOKEN`
|
|
19
|
+
- Repository variable: `TURBO_TEAM`
|
|
20
|
+
|
|
21
|
+
Non-Turborepo repositories do not need either setting. Deployment to Vercel is
|
|
22
|
+
not required. Custom workflows can pass these values to Turbo directly when
|
|
23
|
+
the repository's task graph benefits from remote reuse.
|
|
24
|
+
|
|
25
|
+
## Runner selection
|
|
26
|
+
|
|
27
|
+
Lightweight detection, orchestration, audits, and release metadata jobs can use
|
|
28
|
+
`ubuntu-slim`. Toolchain-heavy builds, native compilation, browsers, and active
|
|
29
|
+
CodeQL analysis should use `ubuntu-latest` unless measurements show otherwise.
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# Configuration reference
|
|
2
|
+
|
|
3
|
+
`.github/code-foundry.yml` is the repository's single Code Foundry control plane.
|
|
4
|
+
Initialize from it with:
|
|
5
|
+
|
|
6
|
+
```bash
|
|
7
|
+
npx code-foundry init --config .github/code-foundry.yml
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
After initialization, edit the file and run `npx code-foundry sync` to render
|
|
11
|
+
the selected callers and refresh the local baseline. Existing authored files
|
|
12
|
+
and custom workflows remain protected.
|
|
13
|
+
|
|
14
|
+
## Configuration flow
|
|
15
|
+
|
|
16
|
+
```text
|
|
17
|
+
code-foundry.yml
|
|
18
|
+
|
|
|
19
|
+
+--> profile and language detection
|
|
20
|
+
+--> enabled standard workflow callers
|
|
21
|
+
+--> runtime repository and ref
|
|
22
|
+
+--> workflow runner selection
|
|
23
|
+
+--> release, license, cache, and coverage policy
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Core settings
|
|
27
|
+
|
|
28
|
+
| Key | Values | Purpose |
|
|
29
|
+
| --- | --- | --- |
|
|
30
|
+
| `profile` | `auto`, `application`, `monorepo`, `minimal` | Repository shape |
|
|
31
|
+
| `languages` | `auto` or comma-separated languages | Toolchain and CodeQL scope |
|
|
32
|
+
| `package_manager` | `auto`, `bun`, `pnpm`, `yarn`, `npm` | Locked JavaScript setup |
|
|
33
|
+
| `features` | `all` or comma-separated names | Standard callers to install |
|
|
34
|
+
| `prune_standard` | `true` or `false` | Remove disabled standard callers on sync |
|
|
35
|
+
| `runtime_repository` | `OWNER/REPO` or blank | Reusable workflow source |
|
|
36
|
+
| `runtime_ref` | tag or branch | Reusable workflow version |
|
|
37
|
+
| `release_type` | `auto`, `node`, `python`, `rust`, `simple`, `none` | Release Please strategy |
|
|
38
|
+
| `npm_publish` | `true` or `false` | Opt into npm publication |
|
|
39
|
+
| `license` | license name, `preserve`, `none` | License generation policy |
|
|
40
|
+
| `license_file` | path | Optional exact license source |
|
|
41
|
+
|
|
42
|
+
Supported languages are TypeScript, Rust, Python, and Solidity. Supported
|
|
43
|
+
features are `ci`, `codeql`, `security`, `test`, `draft-pr`, `release-pr`,
|
|
44
|
+
`release`, and `dependabot`.
|
|
45
|
+
|
|
46
|
+
## Workflow runners
|
|
47
|
+
|
|
48
|
+
Each caller can select its default runner without editing workflow YAML:
|
|
49
|
+
|
|
50
|
+
| Key | Default | Controls |
|
|
51
|
+
| --- | --- | --- |
|
|
52
|
+
| `runner` | `ubuntu-latest` | Shared fallback |
|
|
53
|
+
| `unit_runner` | `ubuntu-slim` | Unit tests |
|
|
54
|
+
| `ci_runner` | `ubuntu-latest` | Format, lint, type-check, build |
|
|
55
|
+
| `test_runner` | `ubuntu-latest` | Integration, E2E, smoke |
|
|
56
|
+
| `security_runner` | `ubuntu-slim` | Profile and dependency security jobs |
|
|
57
|
+
| `codeql_runner` | `ubuntu-latest` | CodeQL detection and analyzers |
|
|
58
|
+
| `pr_runner` | `ubuntu-slim` | Draft and Release PR automation |
|
|
59
|
+
| `release_runner` | `ubuntu-slim` | Release and package publication |
|
|
60
|
+
|
|
61
|
+
Use the full runner for native toolchains, browsers, or measured dependency
|
|
62
|
+
workloads. Use `ubuntu-slim` for lightweight orchestration and small projects.
|
|
63
|
+
|
|
64
|
+
## Performance and quality
|
|
65
|
+
|
|
66
|
+
| Key | Default | Purpose |
|
|
67
|
+
| --- | --- | --- |
|
|
68
|
+
| `cache_packages` | `auto` | Package-store caching policy |
|
|
69
|
+
| `cache_build` | `auto` | Build-cache policy |
|
|
70
|
+
| `coverage_minimum` | `80` | Shared Bun/Python coverage target |
|
|
71
|
+
| `turbo_remote` | `auto` | Turborepo remote-cache policy |
|
|
72
|
+
|
|
73
|
+
Turborepo remote caching still requires the repository secret `TURBO_TOKEN` and
|
|
74
|
+
the variable `TURBO_TEAM`; the file controls policy, not credentials.
|
|
75
|
+
|
|
76
|
+
## Precedence
|
|
77
|
+
|
|
78
|
+
The resolved value order is:
|
|
79
|
+
|
|
80
|
+
```text
|
|
81
|
+
explicit CLI flag -> REPO_FOUNDRY_* variable -> code-foundry.yml -> detection/default
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Use variables for temporary CI overrides. Keep durable repository policy in
|
|
85
|
+
`.github/code-foundry.yml` so humans and agents have one discoverable source of
|
|
86
|
+
truth. The example file is a commented starter guide; it is intentionally not
|
|
87
|
+
a second generated configuration.
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# Initialization and synchronization
|
|
2
|
+
|
|
3
|
+
## Commands
|
|
4
|
+
|
|
5
|
+
Run the package from a repository root:
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npx code-foundry init [options]
|
|
9
|
+
npx code-foundry sync [options]
|
|
10
|
+
npx code-foundry doctor
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
When `.github/code-foundry.yml` already exists, `init` treats it as the primary
|
|
14
|
+
configuration and does not replace its values with CLI defaults. To use another
|
|
15
|
+
file, pass it explicitly:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npx code-foundry init --config ./configs/code-foundry.yml
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
The file is copied to `.github/code-foundry.yml`, normalized, and used to render
|
|
22
|
+
the standard callers. Later edits can be applied with `npx code-foundry sync`.
|
|
23
|
+
|
|
24
|
+
Use `--dry-run` to preview changes. Use `--no-bootstrap` when the repository is
|
|
25
|
+
being initialized in CI or on a machine without mise. Run
|
|
26
|
+
`bash .github/scripts/bootstrap.sh` later to install tools, enable hooks, and
|
|
27
|
+
run the repository doctor.
|
|
28
|
+
|
|
29
|
+
## Profiles and features
|
|
30
|
+
|
|
31
|
+
Supported languages are `typescript`, `rust`, `python`, and `solidity`.
|
|
32
|
+
`--languages auto` detects them from manifests and source files. Profiles are
|
|
33
|
+
`auto`, `application`, `monorepo`, and `minimal`.
|
|
34
|
+
|
|
35
|
+
Standard features are `ci`, `codeql`, `security`, `test`, `draft-pr`,
|
|
36
|
+
`release-pr`, `release`, and `dependabot`. `all` enables every standard
|
|
37
|
+
feature. `--prune` removes disabled standard workflows only; it never removes
|
|
38
|
+
custom workflows.
|
|
39
|
+
|
|
40
|
+
## Runtime selection
|
|
41
|
+
|
|
42
|
+
Reusable workflow callers require a literal repository and ref. By default,
|
|
43
|
+
the initializer derives the runtime repository from the source template. Use
|
|
44
|
+
these options for a fork or a staged runtime:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
npx code-foundry init \
|
|
48
|
+
--runtime-repository OWNER/REPO \
|
|
49
|
+
--runtime-ref v1.2.3
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Both values are persisted in `.github/code-foundry.yml` and rendered into the
|
|
53
|
+
standard callers. `REPO_FOUNDRY_RUNTIME_REPOSITORY` and
|
|
54
|
+
`REPO_FOUNDRY_RUNTIME_REF` provide equivalent environment/repository-variable
|
|
55
|
+
overrides.
|
|
56
|
+
|
|
57
|
+
## Safety rules
|
|
58
|
+
|
|
59
|
+
Synchronization preserves authored README and policy documents, existing
|
|
60
|
+
`.mise.toml` selections, application code, custom workflows, and repository
|
|
61
|
+
documentation. Existing licenses are preserved unless a license or license
|
|
62
|
+
file is explicitly selected. Use `--force` only when intentionally refreshing
|
|
63
|
+
protected standard documents.
|
|
64
|
+
|
|
65
|
+
The initializer generates `.github/code-foundry.yml` as the repository-owned
|
|
66
|
+
configuration contract. Keep project-specific settings there rather than
|
|
67
|
+
editing generated workflow callers by hand.
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Publishing packages
|
|
2
|
+
|
|
3
|
+
## npm
|
|
4
|
+
|
|
5
|
+
Set `npm_publish: true` only when the repository owns an npm package. Configure
|
|
6
|
+
npm trusted publishing for the repository's `release.yml` workflow whenever
|
|
7
|
+
possible. An `NPM_TOKEN` secret is the fallback for registries or repositories
|
|
8
|
+
that cannot use trusted publishing.
|
|
9
|
+
|
|
10
|
+
The package should define its intended visibility explicitly:
|
|
11
|
+
|
|
12
|
+
```json
|
|
13
|
+
{
|
|
14
|
+
"publishConfig": {
|
|
15
|
+
"access": "public"
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Publication occurs only from a Release Please tag; ordinary pushes do not
|
|
21
|
+
publish. The release workflow fails clearly when npm publication is enabled but
|
|
22
|
+
neither trusted publishing nor a token is configured.
|
|
23
|
+
|
|
24
|
+
After enabling publication, make one controlled release and verify both the
|
|
25
|
+
registry version and the provenance link before treating the repository as
|
|
26
|
+
fully configured.
|
|
27
|
+
|
|
28
|
+
## GitHub Releases and GitHub Packages
|
|
29
|
+
|
|
30
|
+
A GitHub Release is release metadata attached to a Git tag. It is independent
|
|
31
|
+
of the npm registry and of GitHub Packages.
|
|
32
|
+
|
|
33
|
+
Publishing to npm does not populate the repository's GitHub Packages section.
|
|
34
|
+
If a repository also needs a GitHub Container Registry or npm-compatible
|
|
35
|
+
GitHub Package, add a repository-owned publishing workflow and credentials;
|
|
36
|
+
that is an optional extension rather than part of the universal baseline.
|
|
37
|
+
|
|
38
|
+
## Provenance and verification
|
|
39
|
+
|
|
40
|
+
Prefer trusted publishing because it provides short-lived credentials and
|
|
41
|
+
provenance. After a release, verify:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
npm view PACKAGE_NAME version dist-tags
|
|
45
|
+
gh release view vVERSION
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
For private or non-npm repositories, leave `npm_publish: false` and retain the
|
|
49
|
+
GitHub Release portion of the standard flow if versioned releases are useful.
|
package/docs/README.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Documentation
|
|
2
|
+
|
|
3
|
+
These guides describe the reusable repository baseline in provider-neutral
|
|
4
|
+
terms. They are suitable for copying into another repository and adapting with
|
|
5
|
+
its own names, environments, and deployment details.
|
|
6
|
+
|
|
7
|
+
## Guides
|
|
8
|
+
|
|
9
|
+
- [Initialization and synchronization](INITIALIZATION.md)
|
|
10
|
+
- [Configuration reference](CONFIGURATION.md)
|
|
11
|
+
- [Workflow and CI conventions](WORKFLOWS.md)
|
|
12
|
+
- [Release management](RELEASES.md)
|
|
13
|
+
- [Publishing packages](PUBLISHING.md)
|
|
14
|
+
- [Caching and remote caching](CACHING.md)
|
|
15
|
+
|
|
16
|
+
## Repository-specific documentation
|
|
17
|
+
|
|
18
|
+
Add project-specific guides, architecture notes, runbooks, and deployment
|
|
19
|
+
instructions to this directory. The Code Foundry initializer preserves `docs/`
|
|
20
|
+
files during synchronization. Prefer clear, task-oriented filenames and link
|
|
21
|
+
new documents from this index when they become part of the supported workflow.
|