diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..7828883 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,20 @@ +name: CI +on: + pull_request: + branches: + - main + push: + branches: + - main +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-go@v1 + with: + go-version: "1.21" + + - uses: kcl-lang/actions@main + with: + subcommand: test diff --git a/README.md b/README.md index 477b5a5..c609265 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,14 @@ Flask Demo KCL manifests, we can run the command to get Kubernetes manifests with [KCL](https://kcl-lang.io). +## Run + +```shell +kcl run +``` + +## Test + ```shell -kcl +kcl test ``` diff --git a/app.k b/app.k index 4ef479e..28a8aed 100644 --- a/app.k +++ b/app.k @@ -24,7 +24,7 @@ schema Container: args?: [str] env?: [Env] volumes?: [Volume] - resources: Resource + resources?: Resource ports: [ContainerPort] schema ContainerPort: diff --git a/kcl.mod b/kcl.mod index 8b13789..c51d42c 100644 --- a/kcl.mod +++ b/kcl.mod @@ -1 +1,2 @@ +[package] diff --git a/kcl.mod.lock b/kcl.mod.lock new file mode 100644 index 0000000..e69de29 diff --git a/kubernetes_render_test.k b/kubernetes_render_test.k new file mode 100644 index 0000000..1d0e869 --- /dev/null +++ b/kubernetes_render_test.k @@ -0,0 +1,18 @@ +import manifests + +import app + +# Convert the `App` model into Kubernetes Deployment and Service Manifests +test_kubernetesRender = lambda { + a = app.App { + name = "app" + containers.ngnix = { + image = "ngnix" + ports = [{containerPort = 80}] + } + service.ports = [{ port = 80 }] + } + deployment_got = kubernetesRender(a) + assert deployment_got[0].kind == "Deployment" + assert deployment_got[1].kind == "Service" +}