Skip to content

Presubmit Go-native runner #19

Open
@cardil

Description

@cardil

Rewrite presubmit-tests.sh script (https://github.com/knative/hack/blob/main/README.md#using-the-presubmit-testssh-helper-script) into a Golang tool knative.dev/toolbox/presubmit.

Invent new Go-native extension interface, for example:

# will look for Go files with `presubmit` build constraints, that register configuration
go run knative.dev/toolbox/presubmit@latest --unit-tests

An example configuration might look like:

//go:build presubmit
package eventing

import (
  "fmt"
  "os"

  "github.com/bitfield/script"
  "knative.dev/toolbox/presubmit/pkg/config"
)

init {
  config.Configure(config.Hooks{
    PostBuildTests: function(ctx config.Context) error {
      return os.RemoveAll("build-cache")
    },
    UnitTests: function(ctx config.Context) error {
      p := script.Exec("make -C tests test")
      _, _ = pp.Stdout()
      return p.Error()
    },
    PreIntegrationTests: function(ctx config.Context) error {
      return os.RemoveAll("staging-area")
    },
  })
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions