Skip to content

Commit

Permalink
test: add e2e tests for all platforms
Browse files Browse the repository at this point in the history
Signed-off-by: peefy <[email protected]>
  • Loading branch information
Peefy committed Dec 8, 2023
1 parent 4fde9aa commit e2a8ef7
Show file tree
Hide file tree
Showing 7 changed files with 209 additions and 4 deletions.
44 changes: 42 additions & 2 deletions .github/workflows/example-e2e-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,57 @@ on:
branches:
- main
jobs:
example-e2e-test:
ubuntu-example-e2e-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v1
with:
go-version: "1.19"

- name: kcl Installation
- name: KCL Installation
run: go install ./cmd/kcl

- name: Example tests
shell: bash -ieo pipefail {0}
run: PATH=$PATH:$HOME/go/bin ./examples/test.sh

macos-example-e2e-test:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v1
with:
go-version: "1.19"

- name: KCL Installation
run: go install ./cmd/kcl

- name: e2e tests
run: PATH=$PATH:$HOME/go/bin kcl ./examples/kubernetes.k

- name: Example tests
shell: bash -ieo pipefail {0}
run: PATH=$PATH:$HOME/go/bin ./examples/test.sh

windows-example-e2e-test:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3

- name: KCL Installation
shell: powershell
run: |
iwr -useb get.scoop.sh -outfile 'install.ps1'
.\install.ps1 -RunAsAdmin
scoop bucket add kcl-lang https://github.com/kcl-lang/scoop-bucket.git
scoop install kcl-lang/kcl
- name: Install Make
run: choco install make -y

- name: e2e tests
run: kcl.exe .\examples\kubernetes.k

- name: Example tests
run: .\examples\test.ps1
1 change: 1 addition & 0 deletions examples/import/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ run:

test:
make -C crd
make -C jsonschema
5 changes: 5 additions & 0 deletions examples/import/jsonschema/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
run:
kcl import -m jsonschema test.schema.json

test:
make run
101 changes: 101 additions & 0 deletions examples/import/jsonschema/test.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
{
"$id": "https://example.com/monaco.manifest.schema.json",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "Dynatrace Monitoring as Code Manifest File",
"type": "object",
"properties": {
"manifestVersion": {
"type": "string",
"description": "The schema version this manifest conforms to - e.g. 1.0"
},
"projects": {
"type": "array",
"description": "The projects grouped by this manifest",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "The name of this project"
},
"type": {
"type": "string",
"description": "Optional Type of this project. Default: Simple",
"oneOf": [
{
"const": "simple",
"description": "A simple project, directly containing configuration. Default."
},
{
"const": "grouping",
"description": "A grouping project, containing several sub-projects."
}
]
},
"path": {
"type": "string",
"description": "Optional filepath of the project relative to the manifest.yaml location. Defaults to name"
}
},
"required": [
"name"
]
}
},
"environmentGroups": {
"description": "The Environment groups to which projects in this manifest are deployed",
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "The name of this environment group"
},
"environments": {
"description": "The environments in this group",
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "The name of this environment"
},
"url": {
"description": "The URL of this environment",
"type": "object",
"properties": {
"type": {
"description": "Optional Type of URL definition.",
"type": "string",
"oneOf": [
{
"const": "value",
"description": "URL directly defined in the 'value'. Default."
},
{
"const": "environment",
"description": "URL defined by an environment variable name in 'value' to read from."
}
]
},
"value": {
"type": "string",
"description": "The value of the URL, based on type either an URL or environment variable name"
}
}
}
}
}
}
}
}
}
},
"required": [
"manifestVersion",
"projects",
"environmentGroups"
]
}
38 changes: 38 additions & 0 deletions examples/import/jsonschema/test.schema.k
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
"""
This file was generated by the KCL auto-gen tool. DO NOT EDIT.
Editing this file might prove futile when you re-run the KCL auto-gen generate command.
"""

schema MonacoManifestSchema:
"""
MonacoManifestSchema

Attributes
----------
manifest_version : str, required
The schema version this manifest conforms to - e.g. 1.0
projects : [items], required
The projects grouped by this manifest
environment_groups : [items], required
The Environment groups to which projects in this manifest are deployed
"""

manifest_version: str
projects: [items]
environment_groups: [items]

schema Url:
"""
The URL of this environment

Attributes
----------
type : str, optional
Optional Type of URL definition.
value : str, optional
The value of the URL, based on type either an URL or environment variable name
"""

type?: str
value?: str

21 changes: 21 additions & 0 deletions examples/test.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Stop on error.
# Note: Before you start tests, please install kcl and kpm
# kcl Installation: https://kcl-lang.io/docs/user_docs/getting-started/install
# kpm Installation: https://kcl-lang.io/docs/user_docs/guides/package-management/installation
$ErrorActionPreference = "Stop"
$pwd = Split-Path -Parent $MyInvocation.MyCommand.Path

$paths = @("configuration", "validation", "abstraction", "definition", "konfig", "mutation", "data-integration", "automation", "package-management", "kubernetes", "codelab", "server")
foreach ($path in $paths) {
Write-Host "Testing $path ..."
Set-Location -Path "$pwd\$path"
try {
& make windows-test | Out-Host
Write-Host "Test SUCCESSED - $path" -ForegroundColor Green
}
catch {
Write-Host "Test FAILED - $path" -ForegroundColor Red
exit 1
}
Write-Host ""
}
3 changes: 1 addition & 2 deletions examples/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@

# Stop on error.

# Note: Before you start tests, please install kcl and kpm
# Note: Before you start tests, please install kcl
# kcl Installation: https://kcl-lang.io/docs/user_docs/getting-started/install
# kpm Installation: https://kcl-lang.io/docs/user_docs/guides/package-management/installation

set -e

Expand Down

0 comments on commit e2a8ef7

Please sign in to comment.