Skip to content

Commit

Permalink
Add more regression testing and compilation steps
Browse files Browse the repository at this point in the history
  • Loading branch information
rquitales committed Sep 12, 2024
1 parent 47670c7 commit 11fff64
Showing 1 changed file with 60 additions and 1 deletion.
61 changes: 60 additions & 1 deletion tests/crds_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,30 @@ func TestCRDsFromFile(t *testing.T) {

// TestCRDsFromUrl pulls the CRD YAML file from a URL and generates it in each language
func TestCRDsFromUrl(t *testing.T) {
validateNodeCompiles := func(t *testing.T, path string) {
withDir(t, path, func() {
runRequireNoError(t, exec.Command("npm", "install"))
runRequireNoError(t, exec.Command("npm", "run", "build"))
})
}

validateGolangCompiles := func(t *testing.T, path string) {
withDir(t, path, func() {
runRequireNoError(t, exec.Command("go", "mod", "init", "fakepackage"))
runRequireNoError(t, exec.Command("go", "mod", "tidy"))
runRequireNoError(t, exec.Command("go", "vet", "./..."))
})
}

// TODO: Also run compilation tests for dotnet, java and python.
compileValidationFn := map[string]func(t *testing.T, path string){
"nodejs": validateNodeCompiles,
"go": validateGolangCompiles,
"python": nil,
"java": nil,
"dotnet": nil,
}

tests := []struct {
name string
url string
Expand All @@ -98,6 +122,41 @@ func TestCRDsFromUrl(t *testing.T) {
name: "Contours",
url: "https://raw.githubusercontent.com/projectcontour/contour-operator/f8c07498803d062e30c255976270cbc82cd619b0/config/crd/bases/operator.projectcontour.io_contours.yaml",
},
{
// https://github.com/pulumi/crd2pulumi/issues/141
name: "ElementDeployment",
url: "https://raw.githubusercontent.com/element-hq/ess-starter-edition-core/d7e792bf8a872f06f02f59d807a1c16ee933862b/roles/elementdeployment/files/elementdeployment-schema.yaml",
},
{
// https://github.com/pulumi/crd2pulumi/issues/142
name: "Keycloak",
url: "https://raw.githubusercontent.com/keycloak/keycloak-k8s-resources/25.0.4/kubernetes/keycloaks.k8s.keycloak.org-v1.yml",
},
{
// https://github.com/pulumi/crd2pulumi/issues/115
name: "CertManager",
url: "https://gist.githubusercontent.com/RouxAntoine/b7dfb9ce327a4ad40a76ff6552c7fd5e/raw/4b5922da11643e14d04e6b52f7a0fca982e4dace/1-crds.yaml",
},
{
// https://github.com/pulumi/crd2pulumi/issues/104
name: "TracingPolicies",
url: "https://raw.githubusercontent.com/cilium/tetragon/v1.2.0/install/kubernetes/tetragon/crds-yaml/cilium.io_tracingpolicies.yaml",
},
{
// https://github.com/pulumi/crd2pulumi/issues/104
name: "Argo Rollouts",
url: "https://raw.githubusercontent.com/argoproj/argo-rollouts/74c1a947ab36670ae01a45993a0c5abb44af4677/manifests/crds/rollout-crd.yaml",
},
{
// https://github.com/pulumi/crd2pulumi/issues/92
name: "Grafana",
url: "https://raw.githubusercontent.com/bitnami/charts/main/bitnami/grafana-operator/crds/grafanas.integreatly.org.yaml",
},
{
// https://github.com/pulumi/crd2pulumi/issues/70
name: "Percona",
url: "https://raw.githubusercontent.com/percona/percona-server-mongodb-operator/main/deploy/crd.yaml",
},
}

for _, tt := range tests {
Expand All @@ -106,7 +165,7 @@ func TestCRDsFromUrl(t *testing.T) {
lang := lang
t.Run(lang, func(t *testing.T) {
t.Parallel()
execCrd2Pulumi(t, lang, tt.url, nil)
execCrd2Pulumi(t, lang, tt.url, compileValidationFn[lang])
})
}
})
Expand Down

0 comments on commit 11fff64

Please sign in to comment.