Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion cmd/dependabot/internal/cmd/graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,16 @@ func NewGraphCommand() *cobra.Command {
}
input.Job.Experiments["enable_dependency_submission_poc"] = true

if input.Job.Command == "" {
input.Job.Command = model.UpdateGraphCommand
}

var writer io.Writer
if !flags.debugging {
writer = os.Stdout
}

if err := infra.Run(infra.RunParams{
Command: model.UpdateGraphCommand,
CacheDir: flags.cache,
CollectorConfigPath: flags.collectorConfigPath,
CollectorImage: collectorImage,
Expand Down
1 change: 0 additions & 1 deletion cmd/dependabot/internal/cmd/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ func NewTestCommand() *cobra.Command {
processInput(&smokeTest.Input, nil)

if err := executeTestJob(infra.RunParams{
Command: smokeTest.Command,
CacheDir: flags.cache,
CollectorConfigPath: flags.collectorConfigPath,
CollectorImage: collectorImage,
Expand Down
12 changes: 5 additions & 7 deletions internal/infra/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ import (

var runCmds = map[model.RunCommand]string{
model.UpdateFilesCommand: "bin/run fetch_files && bin/run update_files",
model.RecreateCommand: "bin/run fetch_files && bin/run update_files",
model.SecurityCommand: "bin/run fetch_files && bin/run update_files",
model.UpdateGraphCommand: "bin/run fetch_files && bin/run update_graph",
}

type RunParams struct {
// Input file
Input string
// Which command to use, this will default to UpdateFilesCommand
Command model.RunCommand
// job definition passed to the updater
Job *model.Job
// expectations asserted at the end of a test
Expand Down Expand Up @@ -96,10 +96,9 @@ func (p *RunParams) Validate() error {
return fmt.Errorf("commit must be a SHA, or not provided")
}
// Allows for older smoke tests without the command field to keep working.
if p.Command == "" {
p.Command = model.UpdateFilesCommand
if p.Job.Command == "" {
p.Job.Command = model.UpdateFilesCommand
}
p.Job.Command = string(p.Command)
return nil
}

Expand Down Expand Up @@ -175,7 +174,6 @@ func generateOutput(params RunParams, api *server.API, outFile *os.File) ([]byte
// store the SHA we worked with for reproducible tests
params.Job.Source.Commit = api.Actual.Input.Job.Source.Commit
}
api.Actual.Command = params.Command
api.Actual.Input.Job = *params.Job

// ignore conditions help make tests reproducible, so they are generated if there aren't any yet
Expand Down Expand Up @@ -467,7 +465,7 @@ func runContainers(ctx context.Context, params RunParams) (err error) {
if params.Flamegraph {
env = append(env, "FLAMEGRAPH=1")
}
if err := updater.RunCmd(ctx, runCmds[params.Command], dependabot, env...); err != nil {
if err := updater.RunCmd(ctx, runCmds[params.Job.Command], dependabot, env...); err != nil {
return err
}
if params.Flamegraph {
Expand Down
2 changes: 1 addition & 1 deletion internal/model/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ reasons.

// Job is the data that is passed to the updater.
type Job struct {
Command string `json:"command" yaml:"command,omitempty"`
Command RunCommand `json:"command" yaml:"command,omitempty"`
PackageManager string `json:"package-manager" yaml:"package-manager"`
AllowedUpdates []Allowed `json:"allowed-updates" yaml:"allowed-updates,omitempty"`
Debug bool `json:"debug" yaml:"debug,omitempty"`
Expand Down
4 changes: 2 additions & 2 deletions internal/model/smoke.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ type RunCommand string

const (
UpdateFilesCommand RunCommand = "update"
RecreateCommand RunCommand = "recreate"
SecurityCommand RunCommand = "security"
UpdateGraphCommand RunCommand = "graph"
)

// SmokeTest is a way to test a job by asserting the outputs.
type SmokeTest struct {
// Command is the command to run for testing a smoke test (update, graph)
Command RunCommand `yaml:"command"`
// Input is the input parameters
Input Input `yaml:"input"`
// Output is the list of expected outputs
Expand Down
Loading