mirror of
https://code.forgejo.org/forgejo/runner.git
synced 2025-08-11 17:50:58 +00:00
test updates
Signed-off-by: Casey Lee <cplee@nektos.com>
This commit is contained in:
parent
c236395c01
commit
eb7e10e86b
8 changed files with 33 additions and 24 deletions
4
.github/workflows/push.yml
vendored
4
.github/workflows/push.yml
vendored
|
@ -6,5 +6,5 @@ jobs:
|
|||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
#- uses: ./.github/workflows/check
|
||||
- uses: ./.github/workflows/integration
|
||||
- uses: ./.github/workflows/check
|
||||
#- uses: ./.github/workflows/integration
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"strings"
|
||||
"testing"
|
||||
|
||||
"gotest.tools/assert"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestReadWorkflow_StringEvent(t *testing.T) {
|
||||
|
@ -20,9 +20,10 @@ jobs:
|
|||
`
|
||||
|
||||
workflow, err := ReadWorkflow(strings.NewReader(yaml))
|
||||
assert.NilError(t, err, "read workflow should succeed")
|
||||
assert.NoError(t, err, "read workflow should succeed")
|
||||
|
||||
assert.DeepEqual(t, workflow.On(), []string{"push"})
|
||||
assert.Len(t, workflow.On(), 1)
|
||||
assert.Contains(t, workflow.On(), "push")
|
||||
}
|
||||
|
||||
func TestReadWorkflow_ListEvent(t *testing.T) {
|
||||
|
@ -38,9 +39,11 @@ jobs:
|
|||
`
|
||||
|
||||
workflow, err := ReadWorkflow(strings.NewReader(yaml))
|
||||
assert.NilError(t, err, "read workflow should succeed")
|
||||
assert.NoError(t, err, "read workflow should succeed")
|
||||
|
||||
assert.DeepEqual(t, workflow.On(), []string{"push", "pull_request"})
|
||||
assert.Len(t, workflow.On(), 2)
|
||||
assert.Contains(t, workflow.On(), "push")
|
||||
assert.Contains(t, workflow.On(), "pull_request")
|
||||
}
|
||||
|
||||
func TestReadWorkflow_MapEvent(t *testing.T) {
|
||||
|
@ -62,7 +65,8 @@ jobs:
|
|||
`
|
||||
|
||||
workflow, err := ReadWorkflow(strings.NewReader(yaml))
|
||||
assert.NilError(t, err, "read workflow should succeed")
|
||||
|
||||
assert.DeepEqual(t, workflow.On(), []string{"push", "pull_request"})
|
||||
assert.NoError(t, err, "read workflow should succeed")
|
||||
assert.Len(t, workflow.On(), 2)
|
||||
assert.Contains(t, workflow.On(), "push")
|
||||
assert.Contains(t, workflow.On(), "pull_request")
|
||||
}
|
||||
|
|
|
@ -33,10 +33,10 @@ func TestAddpath(t *testing.T) {
|
|||
rc := new(RunContext)
|
||||
handler := rc.commandHandler(ctx)
|
||||
|
||||
handler("::add-path::/zoo")
|
||||
handler("::add-path::/zoo\n")
|
||||
assert.Equal("/zoo:", rc.Env["PATH"])
|
||||
|
||||
handler("::add-path::/booo")
|
||||
handler("::add-path::/booo\n")
|
||||
assert.Equal("/booo:/zoo:", rc.Env["PATH"])
|
||||
}
|
||||
|
||||
|
|
|
@ -128,7 +128,11 @@ func (rc *RunContext) runContainer(containerSpec *model.ContainerSpec) common.Ex
|
|||
|
||||
rawLogger := common.Logger(ctx).WithField("raw_output", true)
|
||||
logWriter := common.NewLineWriter(rc.commandHandler(ctx), func(s string) {
|
||||
rawLogger.Debugf(s)
|
||||
if rc.Config.LogOutput {
|
||||
rawLogger.Infof(s)
|
||||
} else {
|
||||
rawLogger.Debugf(s)
|
||||
}
|
||||
})
|
||||
|
||||
return container.NewDockerRunExecutor(container.NewDockerRunExecutorInput{
|
||||
|
|
|
@ -22,6 +22,7 @@ type Config struct {
|
|||
EventPath string // path to JSON file to use for event.json in containers
|
||||
ReuseContainers bool // reuse containers to maintain state
|
||||
ForcePull bool // force pulling of the image, if already present
|
||||
LogOutput bool // log the output from docker run
|
||||
}
|
||||
|
||||
type runnerImpl struct {
|
||||
|
|
|
@ -37,18 +37,15 @@ func TestRunEvent(t *testing.T) {
|
|||
eventName string
|
||||
errorMessage string
|
||||
}{
|
||||
{"basic", "push", ""},
|
||||
{"fail", "push", "exit with `FAILURE`: 1"},
|
||||
{"runs-on", "push", ""},
|
||||
/*
|
||||
{"basic", "push", ""},
|
||||
{"fail", "push", "exit with `FAILURE`: 1"},
|
||||
{"runs-on", "push", ""},
|
||||
{"job-container", "push", ""},
|
||||
{"uses-docker-url", "push", ""},
|
||||
{"remote-action-docker", "push", ""},
|
||||
{"remote-action-js", "push", ""},
|
||||
{"local-action-docker-url", "push", ""},
|
||||
{"local-action-dockerfile", "push", ""},
|
||||
*/
|
||||
{"job-container", "push", ""},
|
||||
{"uses-docker-url", "push", ""},
|
||||
{"remote-action-docker", "push", ""},
|
||||
{"remote-action-js", "push", ""},
|
||||
{"local-action-docker-url", "push", ""},
|
||||
{"local-action-dockerfile", "push", ""},
|
||||
}
|
||||
log.SetLevel(log.DebugLevel)
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ type Input struct {
|
|||
reuseContainers bool
|
||||
dryrun bool
|
||||
forcePull bool
|
||||
logOutput bool
|
||||
}
|
||||
|
||||
func (i *Input) resolve(path string) string {
|
||||
|
|
|
@ -36,6 +36,7 @@ func Execute(ctx context.Context, version string) {
|
|||
rootCmd.PersistentFlags().StringVarP(&input.workflowsPath, "workflows", "W", "./.github/workflows/", "path to workflow files")
|
||||
rootCmd.PersistentFlags().StringVarP(&input.workdir, "directory", "C", ".", "working directory")
|
||||
rootCmd.PersistentFlags().BoolP("verbose", "v", false, "verbose output")
|
||||
rootCmd.PersistentFlags().BoolVarP(&input.logOutput, "output", "o", false, "log output from steps")
|
||||
rootCmd.PersistentFlags().BoolVarP(&input.dryrun, "dryrun", "n", false, "dryrun mode")
|
||||
if err := rootCmd.Execute(); err != nil {
|
||||
os.Exit(1)
|
||||
|
@ -94,6 +95,7 @@ func newRunCommand(ctx context.Context, input *Input) func(*cobra.Command, []str
|
|||
ForcePull: input.forcePull,
|
||||
ReuseContainers: input.reuseContainers,
|
||||
Workdir: input.Workdir(),
|
||||
LogOutput: input.logOutput,
|
||||
}
|
||||
runner, err := runner.New(config)
|
||||
if err != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue