diff --git a/CHANGELOG.md b/CHANGELOG.md index 3060bc4d2..03fbc87c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ ### Bug Fixes: +- fix(compute): add Python starter kit to the static config ([#1877](https://github.com/fastly/cli/pull/1877)) + ### Enhancements: - feat(audit-log): add event-mapping command group ([#1875](https://github.com/fastly/cli/pull/1875)) diff --git a/pkg/commands/compute/language_test.go b/pkg/commands/compute/language_test.go new file mode 100644 index 000000000..38b7cb795 --- /dev/null +++ b/pkg/commands/compute/language_test.go @@ -0,0 +1,40 @@ +package compute_test + +import ( + "testing" + + toml "github.com/pelletier/go-toml" + + "github.com/fastly/cli/pkg/commands/compute" + "github.com/fastly/cli/pkg/config" +) + +// TestStaticConfigStarterKits validates that every language the CLI offers at +// the `compute init` prompt has at least one starter kit in the static config +// embedded into the binary. +// +// The starter kits are injected into the static config at build time by +// ./scripts/config.sh, which holds its own hardcoded list of starter kit +// repositories. Adding a language without also updating that list leaves users +// of the new language unable to init a project (see CDTOOL-1707), and this test +// is here to catch that drift. +// +// NOTE: The static config is generated, not committed, so run `make config` +// before running this test locally. +func TestStaticConfigStarterKits(t *testing.T) { + var f config.File + if err := toml.Unmarshal(config.Static, &f); err != nil { + t.Fatalf("failed to unmarshal the static config: %s", err) + } + + for _, language := range compute.NewLanguages(f.StarterKits) { + // The 'other' language is for users bringing their own Wasm binary and so + // has no starter kits by design. + if language.Name == "other" { + continue + } + if len(language.StarterKits) == 0 { + t.Errorf("no starter kits found in the static config for language %q: add its starter kit repositories to the 'kits' list in ./scripts/config.sh", language.Name) + } + } +} diff --git a/scripts/config.sh b/scripts/config.sh index c9cd2f0dc..667272085 100755 --- a/scripts/config.sh +++ b/scripts/config.sh @@ -21,6 +21,7 @@ kits=( compute-starter-kit-typescript compute-starter-kit-cpp-default compute-starter-kit-cpp-empty + compute-starter-kit-python-default ) function parse() {