Skip to content

Commit

Permalink
feat: adds KCL provider (#111)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmgilman authored Jan 15, 2025
1 parent 2929028 commit 4b88990
Show file tree
Hide file tree
Showing 5 changed files with 103 additions and 1 deletion.
45 changes: 44 additions & 1 deletion actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -225,4 +229,43 @@ runs:
uses: cue-lang/[email protected]
if: steps.cue.outputs.install && steps.cue.conclusion == 'success'
with:
version: v${{ steps.cue.outputs.version }}
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
5 changes: 5 additions & 0 deletions blueprint.cue
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ global: {
}
registry: "ghcr.io"
}

kcl: {
install: true
version: "v0.11.0"
}
}
secrets: [
{
Expand Down
18 changes: 18 additions & 0 deletions lib/project/schema/_embed/schema.cue
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 & {
Expand Down
18 changes: 18 additions & 0 deletions lib/project/schema/providers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down Expand Up @@ -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.
Expand Down
18 changes: 18 additions & 0 deletions lib/project/schema/providers_go_gen.cue
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 4b88990

Please sign in to comment.