-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from wings-software/rahulk_cihack
Kotlin changes for maven and gradle
- Loading branch information
Showing
4 changed files
with
162 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// Copyright 2022 Harness Inc. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package harness | ||
|
||
import ( | ||
"io/fs" | ||
|
||
spec "github.com/drone/spec/dist/go" | ||
"github.com/wings-software/autogen-go/utils" | ||
) | ||
|
||
// ConfigureGo configures a Go step. | ||
func ConfigureKotlin(fsys fs.FS, pipeline *spec.Pipeline) error { | ||
stage := pipeline.Stages[0].Spec.(*spec.StageCI) | ||
|
||
// check for the go.mod file. | ||
if !utils.Exists(fsys, "build.gradle.kts") { | ||
return nil | ||
} | ||
|
||
// check if we should use a container-based | ||
// execution environment. | ||
useImage := utils.IsContainerRuntime(pipeline) | ||
|
||
// add the go build step | ||
{ | ||
script := new(spec.StepExec) | ||
script.Run = "./gradlew build" | ||
|
||
if useImage { | ||
script.Image = "kotlin" | ||
} | ||
|
||
step := new(spec.Step) | ||
step.Name = "kotlin_build" | ||
step.Type = "script" | ||
step.Spec = script | ||
|
||
stage.Steps = append(stage.Steps, step) | ||
} | ||
|
||
// add the go test step | ||
{ | ||
script := new(spec.StepExec) | ||
script.Run = "./gradlew test" | ||
|
||
if useImage { | ||
script.Image = "kotlin" | ||
} | ||
|
||
step := new(spec.Step) | ||
step.Name = "kotlin_test" | ||
step.Type = "script" | ||
step.Spec = script | ||
stage.Steps = append(stage.Steps, step) | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// Copyright 2022 Harness Inc. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package harness | ||
|
||
import ( | ||
"fmt" | ||
"io/fs" | ||
|
||
spec "github.com/drone/spec/dist/go" | ||
"github.com/wings-software/autogen-go/utils" | ||
) | ||
|
||
// ConfigureGo configures a Go step. | ||
func ConfigureKotlinwithMaven(fsys fs.FS, pipeline *spec.Pipeline) error { | ||
stage := pipeline.Stages[0].Spec.(*spec.StageCI) | ||
|
||
// check for the go.mod file. | ||
if !(utils.Exists(fsys, "pom.xml") && utils.IsDirectoryPresent(fsys, "/src/test/kotlin")) { | ||
fmt.Println("Error getting current kotlin directory:") | ||
return nil | ||
} | ||
|
||
// check if we should use a container-based | ||
// execution environment. | ||
useImage := utils.IsContainerRuntime(pipeline) | ||
|
||
// add the go build step | ||
{ | ||
script := new(spec.StepExec) | ||
script.Run = "mvn clean compile" | ||
|
||
if useImage { | ||
script.Image = "maven" | ||
} | ||
|
||
step := new(spec.Step) | ||
step.Name = "kotlin_mvn_build" | ||
step.Type = "script" | ||
step.Spec = script | ||
|
||
stage.Steps = append(stage.Steps, step) | ||
} | ||
|
||
// add the go test step | ||
{ | ||
script := new(spec.StepExec) | ||
script.Run = "mvn clean test" | ||
|
||
if useImage { | ||
script.Image = "maven" | ||
} | ||
|
||
step := new(spec.Step) | ||
step.Name = "kotlin_mvn_test" | ||
step.Type = "script" | ||
step.Spec = script | ||
stage.Steps = append(stage.Steps, step) | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters