-
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 #4 from wings-software/python_cpp_c
autogen changes for python, c, cpp
- Loading branch information
Showing
4 changed files
with
484 additions
and
2 deletions.
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,152 @@ | ||
// Copyright 2023 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" | ||
) | ||
|
||
// ConfigureC configures a C step. | ||
func ConfigureC(fsys fs.FS, pipeline *spec.Pipeline) error { | ||
stage := pipeline.Stages[0].Spec.(*spec.StageCI) | ||
|
||
if utils.Match(fsys, "*/*.c") || utils.Match(fsys, "*.c") { | ||
if utils.Exists(fsys, "Makefile") { | ||
{ | ||
script := new(spec.StepExec) | ||
script.Run = "make" | ||
|
||
step := new(spec.Step) | ||
step.Name = "build make" | ||
step.Type = "script" | ||
step.Spec = script | ||
|
||
stage.Steps = append(stage.Steps, step) | ||
} | ||
|
||
{ | ||
script := new(spec.StepExec) | ||
script.Run = "make lint" | ||
|
||
step := new(spec.Step) | ||
step.Name = "make lint" | ||
step.Type = "script" | ||
step.Spec = script | ||
|
||
stage.Steps = append(stage.Steps, step) | ||
} | ||
|
||
{ | ||
script := new(spec.StepExec) | ||
script.Run = "make test" | ||
script.Reports = []*spec.Report{ | ||
{ | ||
Path: []string{ | ||
"**/*.xml", | ||
}, | ||
Type: "JUnit", | ||
}, | ||
} | ||
|
||
step := new(spec.Step) | ||
step.Name = "run tests" | ||
step.Type = "script" | ||
step.Spec = script | ||
|
||
stage.Steps = append(stage.Steps, step) | ||
} | ||
} else if utils.Match(fsys, "CMakeLists.txt") { | ||
{ | ||
script := new(spec.StepExec) | ||
script.Run = "sudo apt-get update\nsudo apt-get install check && sudo apt-get install lcov" | ||
step := new(spec.Step) | ||
step.Name = "install and update deps" | ||
step.Type = "script" | ||
step.Spec = script | ||
|
||
stage.Steps = append(stage.Steps, step) | ||
} | ||
|
||
{ | ||
script := new(spec.StepExec) | ||
script.Run = "mkdir build && cd build && cmake .. && cmake --build ." | ||
|
||
step := new(spec.Step) | ||
step.Name = "cmake build && make" | ||
step.Type = "script" | ||
step.Spec = script | ||
|
||
stage.Steps = append(stage.Steps, step) | ||
} | ||
|
||
{ | ||
script := new(spec.StepExec) | ||
script.Run = "cd build && make test" | ||
script.Reports = []*spec.Report{ | ||
{ | ||
Path: []string{ | ||
"**/*.xml", | ||
}, | ||
Type: "JUnit", | ||
}, | ||
} | ||
|
||
step := new(spec.Step) | ||
step.Name = "run tests" | ||
step.Type = "script" | ||
step.Spec = script | ||
|
||
stage.Steps = append(stage.Steps, step) | ||
} | ||
} else if utils.Match(fsys, "Makefile.am") { | ||
{ | ||
script := new(spec.StepExec) | ||
script.Run = "./bootstrap && ./configure --with-coverage" | ||
step := new(spec.Step) | ||
step.Name = "configure" | ||
step.Type = "script" | ||
step.Spec = script | ||
|
||
stage.Steps = append(stage.Steps, step) | ||
} | ||
|
||
{ | ||
script := new(spec.StepExec) | ||
script.Run = "make clean && make check" | ||
|
||
step := new(spec.Step) | ||
step.Name = "run tests and get coverage" | ||
step.Type = "script" | ||
step.Spec = script | ||
script.Reports = []*spec.Report{ | ||
{ | ||
Path: []string{ | ||
"**/*.xml", | ||
}, | ||
Type: "JUnit", | ||
}, | ||
} | ||
stage.Steps = append(stage.Steps, step) | ||
} | ||
|
||
{ | ||
script := new(spec.StepExec) | ||
script.Run = "make cov" | ||
|
||
step := new(spec.Step) | ||
step.Name = "get coverage" | ||
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,112 @@ | ||
// Copyright 2023 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" | ||
) | ||
|
||
// ConfigureCPP configures a CPP step. | ||
func ConfigureCPP(fsys fs.FS, pipeline *spec.Pipeline) error { | ||
stage := pipeline.Stages[0].Spec.(*spec.StageCI) | ||
|
||
if utils.Match(fsys, "*.cpp") || utils.Match(fsys, "*/*.cpp") || utils.Match(fsys, "*/*.cc") || utils.Match(fsys, "*.cc") { | ||
if utils.Exists(fsys, "Makefile") { | ||
{ | ||
script := new(spec.StepExec) | ||
script.Run = "make" | ||
|
||
step := new(spec.Step) | ||
step.Name = "build make" | ||
step.Type = "script" | ||
step.Spec = script | ||
|
||
stage.Steps = append(stage.Steps, step) | ||
} | ||
|
||
{ | ||
script := new(spec.StepExec) | ||
script.Run = "make lint" | ||
|
||
step := new(spec.Step) | ||
step.Name = "make lint" | ||
step.Type = "script" | ||
step.Spec = script | ||
|
||
stage.Steps = append(stage.Steps, step) | ||
} | ||
|
||
{ | ||
script := new(spec.StepExec) | ||
script.Run = "TEST_NODE_INDEX=<+strategy.iteration>\nTEST_NODE_TOTAL=<+strategy.iterations>\n" + | ||
"export TEST_FILES=`split_tests --glob 'test/**/*.cpp' --split-by file_timing --verbose " + | ||
"--split-index '${TEST_NODE_INDEX}' --split-total '${TEST_NODE_TOTAL}'`" | ||
script.Reports = []*spec.Report{ | ||
{ | ||
Path: []string{ | ||
"**/*.xml", | ||
}, | ||
Type: "JUnit", | ||
}, | ||
} | ||
|
||
step := new(spec.Step) | ||
step.Name = "run tests" | ||
step.Type = "script" | ||
step.Spec = script | ||
|
||
stage.Steps = append(stage.Steps, step) | ||
} | ||
} else if utils.Exists(fsys, "CMakeLists.txt") { | ||
{ | ||
script := new(spec.StepExec) | ||
script.Run = "sudo apt-get update\nsudo apt-get install libgtest-dev" | ||
step := new(spec.Step) | ||
step.Name = "install and update deps" | ||
step.Type = "script" | ||
step.Spec = script | ||
|
||
stage.Steps = append(stage.Steps, step) | ||
} | ||
|
||
{ | ||
script := new(spec.StepExec) | ||
script.Run = "mkdir build && cd build && cmake .. && cmake --build ." | ||
|
||
step := new(spec.Step) | ||
step.Name = "cmake build && make" | ||
step.Type = "script" | ||
step.Spec = script | ||
|
||
stage.Steps = append(stage.Steps, step) | ||
} | ||
|
||
{ | ||
script := new(spec.StepExec) | ||
script.Run = "cd build && make check" | ||
script.Reports = []*spec.Report{ | ||
{ | ||
Path: []string{ | ||
"**/*.xml", | ||
}, | ||
Type: "JUnit", | ||
}, | ||
} | ||
|
||
step := new(spec.Step) | ||
step.Name = "run tests" | ||
step.Type = "script" | ||
step.Spec = script | ||
|
||
stage.Steps = append(stage.Steps, step) | ||
} | ||
} | ||
} | ||
|
||
return nil | ||
} |
Oops, something went wrong.