From 4b88990bd344c35f6415bbea4afca3425b2d918f Mon Sep 17 00:00:00 2001 From: Joshua Gilman Date: Wed, 15 Jan 2025 15:43:54 -0800 Subject: [PATCH] feat: adds KCL provider (#111) --- actions/setup/action.yml | 45 ++++++++++++++++++++++++- blueprint.cue | 5 +++ lib/project/schema/_embed/schema.cue | 18 ++++++++++ lib/project/schema/providers.go | 18 ++++++++++ lib/project/schema/providers_go_gen.cue | 18 ++++++++++ 5 files changed, 103 insertions(+), 1 deletion(-) diff --git a/actions/setup/action.yml b/actions/setup/action.yml index 430e41c..ef384a1 100644 --- a/actions/setup/action.yml +++ b/actions/setup/action.yml @@ -23,6 +23,10 @@ inputs: description: If true, skip authenticating to GitHub Container Registry required: false default: "false" + skip_kcl: + description: If true, skips installing KCL CLI if the provider is configured + required: false + default: "false" skip_timoni: description: If true, skips installing Timoni CLI if the provider is configured required: false @@ -225,4 +229,43 @@ runs: uses: cue-lang/setup-cue@v1.0.0 if: steps.cue.outputs.install && steps.cue.conclusion == 'success' with: - version: v${{ steps.cue.outputs.version }} \ No newline at end of file + version: v${{ steps.cue.outputs.version }} + + # KCL Provider + - name: Get KCL provider configuration + id: kcl + if: inputs.skip_kcl == 'false' + shell: bash + run: | + echo "==== KCL Setup =====" + BP=$(forge dump .) + + KCL=$(echo "$BP" | jq -r .global.ci.providers.kcl.install) + if [[ "$KCL" == "true" ]]; then + INSTALL=1 + VERSION=$(echo "$BP" | jq -r .global.ci.providers.kcl.version) + echo "install=$INSTALL" >> $GITHUB_OUTPUT + echo "version=$VERSION" >> $GITHUB_OUTPUT + else + echo "Not installing KCL CLI" + fi + - name: Cache KCL + id: cache-kcl + if: steps.kcl.outputs.install && steps.kcl.conclusion == 'success' + uses: actions/cache@v4 + with: + path: /usr/local/bin/kcl + key: ${{ runner.os }}-kcl-${{ steps.kcl.outputs.version }} + - name: Install KCL + if: steps.cache-kcl.outputs.cache-hit == false + shell: bash + run: | + WORKDIR="$(mktemp -d)" + VERSION="${{ steps.kcl.outputs.version }}" + curl -Lo "${WORKDIR}/kcl.tar.gz" https://github.com/kcl-lang/cli/releases/download/$VERSION/kcl-$VERSION-linux-amd64.tar.gz + cd "${WORKDIR}" && tar -xvzf kcl.tar.gz && mv kcl /usr/local/bin/kcl + - name: Check KCL + if: steps.kcl.outputs.install && steps.kcl.conclusion == 'success' + shell: bash + run: | + kcl version \ No newline at end of file diff --git a/blueprint.cue b/blueprint.cue index 1fae11e..aa4c2b9 100644 --- a/blueprint.cue +++ b/blueprint.cue @@ -54,6 +54,11 @@ global: { } registry: "ghcr.io" } + + kcl: { + install: true + version: "v0.11.0" + } } secrets: [ { diff --git a/lib/project/schema/_embed/schema.cue b/lib/project/schema/_embed/schema.cue index cd1920f..f432b89 100644 --- a/lib/project/schema/_embed/schema.cue +++ b/lib/project/schema/_embed/schema.cue @@ -79,6 +79,10 @@ package schema // +optional github?: #ProviderGithub @go(Github) + // KCL contains the configuration for the KCL provider. + // +optional + kcl?: #ProviderKCL @go(KCL) + // Timoni contains the configuration for the Timoni provider. // +optional timoni?: #TimoniProvider @go(Timoni) @@ -166,6 +170,20 @@ package schema // +optional registry?: null | string @go(Registry,*string) } + +// ProviderKCL contains the configuration for the KCL provider. +#ProviderKCL: { + // Install contains whether to install KCL in the CI environment. + // +optional + install?: null | bool @go(Install,*bool) + + // Registries contains the registries to use for publishing KCL modules + registries: [...string] @go(Registries,[]string) + + // The version of KCL to install in the CI environment + // +optional + version?: string @go(Version) +} #TagStrategy: string #enumTagStrategy: #TagStrategyGitCommit #TagStrategyGitCommit: #TagStrategy & { diff --git a/lib/project/schema/providers.go b/lib/project/schema/providers.go index e377226..af8fc74 100644 --- a/lib/project/schema/providers.go +++ b/lib/project/schema/providers.go @@ -26,6 +26,10 @@ type Providers struct { // +optional Github ProviderGithub `json:"github"` + // KCL contains the configuration for the KCL provider. + // +optional + KCL ProviderKCL `json:"kcl"` + // Timoni contains the configuration for the Timoni provider. // +optional Timoni TimoniProvider `json:"timoni"` @@ -115,6 +119,20 @@ type ProviderGithub struct { Registry *string `json:"registry"` } +// ProviderKCL contains the configuration for the KCL provider. +type ProviderKCL struct { + // Install contains whether to install KCL in the CI environment. + // +optional + Install *bool `json:"install"` + + // Registries contains the registries to use for publishing KCL modules + Registries []string `json:"registries"` + + // The version of KCL to install in the CI environment + // +optional + Version string `json:"version"` +} + // TimoniProvider contains the configuration for the Timoni provider. type TimoniProvider struct { // Install contains whether to install Timoni in the CI environment. diff --git a/lib/project/schema/providers_go_gen.cue b/lib/project/schema/providers_go_gen.cue index 4839a5a..dff92b4 100644 --- a/lib/project/schema/providers_go_gen.cue +++ b/lib/project/schema/providers_go_gen.cue @@ -30,6 +30,10 @@ package schema // +optional github?: #ProviderGithub @go(Github) + // KCL contains the configuration for the KCL provider. + // +optional + kcl?: #ProviderKCL @go(KCL) + // Timoni contains the configuration for the Timoni provider. // +optional timoni?: #TimoniProvider @go(Timoni) @@ -119,6 +123,20 @@ package schema registry?: null | string @go(Registry,*string) } +// ProviderKCL contains the configuration for the KCL provider. +#ProviderKCL: { + // Install contains whether to install KCL in the CI environment. + // +optional + install?: null | bool @go(Install,*bool) + + // Registries contains the registries to use for publishing KCL modules + registries: [...string] @go(Registries,[]string) + + // The version of KCL to install in the CI environment + // +optional + version?: string @go(Version) +} + // TimoniProvider contains the configuration for the Timoni provider. #TimoniProvider: { // Install contains whether to install Timoni in the CI environment.