Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add e2e tests for all platforms #26

Merged
merged 1 commit into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 38 additions & 2 deletions .github/workflows/example-e2e-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,53 @@ on:
branches:
- main
jobs:
example-e2e-test:
ubuntu:
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:
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:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3

- name: Install Make
run: choco install make -y

- name: KCL Installation and Tests
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
kcl.exe .\examples\kubernetes.k
.\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 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
Loading