Skip to content

Commit

Permalink
Fix vale config file according to latest version
Browse files Browse the repository at this point in the history
This will fix vale config file to compatible with latest version as
it was throwing error that IgnoredScopes and SkippedScopes to be
defined before syntx options
  • Loading branch information
piyush-garg authored and savitaashture committed Jul 26, 2024
1 parent 1e9f8ea commit aab624b
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 32 deletions.
6 changes: 3 additions & 3 deletions .vale.ini
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ StylesPath = .vale/styles
Packages = RedHat
MinAlertLevel = error

[*]
BasedOnStyles = Vale, RedHat, PaaC

# IgnoredScopes specifies inline-level HTML tags to ignore.
# These tags may occur in an active scope (unlike SkippedScopes, skipped entirely) but their content still will not raise any alerts.
# Default: ignore `code` and `tt`.
Expand All @@ -21,6 +18,9 @@ IgnoredScopes = code, tt, img, url, a, body.id
# For AsciiDoc: by default, listingblock, and literalblock.
SkippedScopes = script, style, pre, figure, code, tt, blockquote, listingblock, literalblock

[*]
BasedOnStyles = Vale, RedHat, PaaC

RedHat.ConfigMap = NO
RedHat.CaseSensitiveTerms = NO
Vale.Spelling = NO
Expand Down
75 changes: 46 additions & 29 deletions test/gitea_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ func TestGiteaProvenanceForDefaultBranch(t *testing.T) {
Settings: &v1alpha1.Settings{PipelineRunProvenance: "default_branch"},
NoPullRequestCreation: true,
}
verifyProvinance(t, topts, "HELLOMOTO", "step-task")
verifyProvinance(t, topts, "HELLOMOTO", "step-task", false)
}

// TestGiteaProvenanceForSource tests the provenance feature of the PipelineRun.
Expand All @@ -617,7 +617,7 @@ func TestGiteaProvenanceForSource(t *testing.T) {
Settings: &v1alpha1.Settings{PipelineRunProvenance: "source"},
NoPullRequestCreation: true,
}
verifyProvinance(t, topts, "testing provenance for source", "step-source-provenance-test")
verifyProvinance(t, topts, "testing provenance for source", "step-source-provenance-test", false)
}

// TestGiteaGlobalRepoProvenanceForDefaultBranch tests the provenance feature of the PipelineRun.
Expand All @@ -632,38 +632,55 @@ func TestGiteaGlobalRepoProvenanceForDefaultBranch(t *testing.T) {
Settings: &v1alpha1.Settings{},
}

ctx := context.Background()
topts.ParamsRun, topts.Opts, topts.GiteaCNX, _ = tgitea.Setup(ctx)
assert.NilError(t, topts.ParamsRun.Clients.NewClients(ctx, &topts.ParamsRun.Info))
topts.TargetRefName = names.SimpleNameGenerator.RestrictLengthWithRandomSuffix("pac-e2e-test")
topts.TargetNS = topts.TargetRefName
ctx, err := cctx.GetControllerCtxInfo(ctx, topts.ParamsRun)
assert.NilError(t, err)
assert.NilError(t, pacrepo.CreateNS(ctx, topts.TargetNS, topts.ParamsRun))
verifyProvinance(t, topts, "HELLOMOTO", "step-task", true)
}

globalNs := info.GetNS(ctx)
err = tgitea.CreateCRD(ctx, topts,
v1alpha1.RepositorySpec{
Settings: &v1alpha1.Settings{
PipelineRunProvenance: "default_branch",
},
// TestGiteaGlobalAndLocalRepoProvenance verifies the provenance feature of the PipelineRun,
// ensuring that when provenance is configured at both the global and local repository levels,
// the local repository settings take precedence. This end-to-end test confirms that behavior.
func TestGiteaGlobalAndLocalRepoProvenance(t *testing.T) {
topts := &tgitea.TestOpts{
SkipEventsCheck: true,
TargetEvent: triggertype.PullRequest.String(),
NoPullRequestCreation: true,
Settings: &v1alpha1.Settings{
PipelineRunProvenance: "source",
},
true)
assert.NilError(t, err)

defer (func() {
if os.Getenv("TEST_NOCLEANUP") != "true" {
topts.ParamsRun.Clients.Log.Infof("Cleaning up global repo %s in %s", info.DefaultGlobalRepoName, globalNs)
err = topts.ParamsRun.Clients.PipelineAsCode.PipelinesascodeV1alpha1().Repositories(globalNs).Delete(
context.Background(), info.DefaultGlobalRepoName, metav1.DeleteOptions{})
assert.NilError(t, err)
}
})()
}

verifyProvinance(t, topts, "HELLOMOTO", "step-task")
verifyProvinance(t, topts, "testing provenance for source", "step-source-provenance-test", true)
}

func verifyProvinance(t *testing.T, topts *tgitea.TestOpts, expectedOutput, cName string) {
func verifyProvinance(t *testing.T, topts *tgitea.TestOpts, expectedOutput, cName string, isGlobal bool) {
if isGlobal {
ctx := context.Background()
topts.ParamsRun, topts.Opts, topts.GiteaCNX, _ = tgitea.Setup(ctx)
assert.NilError(t, topts.ParamsRun.Clients.NewClients(ctx, &topts.ParamsRun.Info))
topts.TargetRefName = names.SimpleNameGenerator.RestrictLengthWithRandomSuffix("pac-e2e-test")
topts.TargetNS = topts.TargetRefName
ctx, err := cctx.GetControllerCtxInfo(ctx, topts.ParamsRun)
assert.NilError(t, err)
assert.NilError(t, pacrepo.CreateNS(ctx, topts.TargetNS, topts.ParamsRun))

globalNs := info.GetNS(ctx)
err = tgitea.CreateCRD(ctx, topts,
v1alpha1.RepositorySpec{
Settings: &v1alpha1.Settings{
PipelineRunProvenance: "default_branch",
},
},
isGlobal)
assert.NilError(t, err)

defer (func() {
if os.Getenv("TEST_NOCLEANUP") != "true" {
topts.ParamsRun.Clients.Log.Infof("Cleaning up global repo %s in %s", info.DefaultGlobalRepoName, globalNs)
err = topts.ParamsRun.Clients.PipelineAsCode.PipelinesascodeV1alpha1().Repositories(globalNs).Delete(
context.Background(), info.DefaultGlobalRepoName, metav1.DeleteOptions{})
assert.NilError(t, err)
}
})()
}
_, f := tgitea.TestPR(t, topts)
defer f()
targetRef := topts.TargetRefName
Expand Down

0 comments on commit aab624b

Please sign in to comment.