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
9 changes: 8 additions & 1 deletion internal/infra/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ func generateOutput(params RunParams, api *server.API, outFile *os.File) ([]byte
api.Actual.Input.Job = *params.Job

// ignore conditions help make tests reproducible, so they are generated if there aren't any yet
if len(api.Actual.Input.Job.IgnoreConditions) == 0 && api.Actual.Input.Job.PackageManager != "submodules" {
if len(api.Actual.Input.Job.IgnoreConditions) == 0 {
if err := generateIgnoreConditions(&params, &api.Actual); err != nil {
return nil, err
}
Expand Down Expand Up @@ -342,6 +342,8 @@ func expandEnvironmentVariables(api *server.API, params *RunParams) {
}
}

var gitShaVersion = regexp.MustCompile(`^[0-9a-f]{40}$`)

func generateIgnoreConditions(params *RunParams, actual *model.SmokeTest) error {
for _, out := range actual.Output {
if out.Type == "create_pull_request" {
Expand All @@ -355,6 +357,11 @@ func generateIgnoreConditions(params *RunParams, actual *model.SmokeTest) error
// dependency version nil due to it being removed
continue
}
if gitShaRegex.MatchString(*dep.Version) {
// Git SHAs (used by submodules, nix flake inputs, etc.) cannot be
// expressed as a Gem::Requirement, so skip those individual conditions.
continue
}
ignore := model.Condition{
DependencyName: dep.Name,
VersionRequirement: fmt.Sprintf(">%v", *dep.Version),
Expand Down
28 changes: 28 additions & 0 deletions internal/infra/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,32 @@ func Test_generateIgnoreConditions(t *testing.T) {
t.Error("expected 0 ignore condition to be generated, got", len(actual.Input.Job.IgnoreConditions))
}
})

t.Run("skips git SHA versions", func(t *testing.T) {
runParams := &RunParams{
Output: outputFileName,
}
semver := "1.0.0"
sha := "8b27c1239e5c421a2bbc2c65d52e4a6fbf2ff296"
actual := &model.SmokeTest{
Output: []model.Output{{
Type: "create_pull_request",
Expect: model.UpdateWrapper{Data: model.CreatePullRequest{
Dependencies: []model.Dependency{
{Name: "semver-dep", Version: &semver},
{Name: "sha-dep", Version: &sha},
},
}},
}},
}
if err := generateIgnoreConditions(runParams, actual); err != nil {
t.Fatal(err)
}
if len(actual.Input.Job.IgnoreConditions) != 1 {
t.Fatalf("expected 1 ignore condition, got %d", len(actual.Input.Job.IgnoreConditions))
}
if actual.Input.Job.IgnoreConditions[0].DependencyName != "semver-dep" {
t.Errorf("expected semver-dep, got %q", actual.Input.Job.IgnoreConditions[0].DependencyName)
}
})
}
Loading