Skip to content

Commit 39bf02f

Browse files
authored
Merge pull request #1036 from PatrickRice-KSC/deprecate-branch-coverage
Deprecate branch coverage
2 parents b3732f9 + b644e55 commit 39bf02f

File tree

5 files changed

+57
-22
lines changed

5 files changed

+57
-22
lines changed

.gitpod.yml

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
image: gitpod/workspace-go
22
tasks:
3-
- init: go get
3+
# Retrieve our go dependencies. Also inject several vscode settings that are specifically helpful to a GitPod environment and not needed when opening the repo locally.
4+
# The reason the settings are copied to a temp file and then moved is that applying the jq string directly to settings.json results in a blank file.
5+
- init: |
6+
go get
7+
cat .vscode/settings.json | jq '. + {"terminal.integrated.lineHeight": 1.0,"terminal.integrated.letterSpacing": 1.0,"terminal.integrated.scrollback": 5000}' > .vscode/temp.json
8+
mv .vscode/temp.json .vscode/settings.json
49
- name: Start acceptance Test Environment
510
command: make testacc-up
611
openMode: split-right

.vscode/settings.json

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
2-
"go.testEnvVars": {
3-
"TF_ACC": "1",
4-
"GITLAB_TOKEN": "ACCTEST1234567890123",
5-
"GITLAB_BASE_URL": "http://127.0.0.1:8080"
6-
},
7-
"go.testFlags": ["-count=1", "-v"]
8-
}
2+
"go.testEnvVars": {
3+
"TF_ACC": "1",
4+
"GITLAB_TOKEN": "ACCTEST1234567890123",
5+
"GITLAB_BASE_URL": "http://127.0.0.1:8080"
6+
},
7+
"go.testFlags": ["-count=1", "-v", "-timeout=30m"]
8+
}

docs/resources/project.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ resource "gitlab_project" "peters_repo" {
8181
- `auto_devops_deploy_strategy` (String) Auto Deploy strategy. Valid values are `continuous`, `manual`, `timed_incremental`.
8282
- `auto_devops_enabled` (Boolean) Enable Auto DevOps for this project.
8383
- `autoclose_referenced_issues` (Boolean) Set whether auto-closing referenced issues on default branch.
84-
- `build_coverage_regex` (String) Test coverage parsing for the project.
84+
- `build_coverage_regex` (String, Deprecated) Test coverage parsing for the project. This is deprecated feature in GitLab 15.0.
8585
- `build_git_strategy` (String) The Git strategy. Defaults to fetch.
8686
- `build_timeout` (Number) The maximum amount of time, in seconds, that a job can run.
8787
- `builds_access_level` (String) Set the builds access level. Valid values are `disabled`, `private`, `enabled`.

internal/provider/resource_gitlab_project.go

+11-4
Original file line numberDiff line numberDiff line change
@@ -367,9 +367,10 @@ var resourceGitLabProjectSchema = map[string]*schema.Schema{
367367
RequiredWith: []string{"import_url"},
368368
},
369369
"build_coverage_regex": {
370-
Description: "Test coverage parsing for the project.",
370+
Description: "Test coverage parsing for the project. This is deprecated feature in GitLab 15.0.",
371371
Type: schema.TypeString,
372372
Optional: true,
373+
Deprecated: "build_coverage_regex is removed in GitLab 15.0.",
373374
},
374375
"issues_template": {
375376
Description: "Sets the template for new issues in the project.",
@@ -714,7 +715,6 @@ func resourceGitlabProjectSetToState(ctx context.Context, client *gitlab.Client,
714715
d.Set("mirror_trigger_builds", project.MirrorTriggerBuilds)
715716
d.Set("mirror_overwrites_diverged_branches", project.MirrorOverwritesDivergedBranches)
716717
d.Set("only_mirror_protected_branches", project.OnlyMirrorProtectedBranches)
717-
d.Set("build_coverage_regex", project.BuildCoverageRegex)
718718
d.Set("issues_template", project.IssuesTemplate)
719719
d.Set("merge_requests_template", project.MergeRequestsTemplate)
720720
d.Set("ci_config_path", project.CIConfigPath)
@@ -752,6 +752,10 @@ func resourceGitlabProjectSetToState(ctx context.Context, client *gitlab.Client,
752752
d.Set("wiki_access_level", string(project.WikiAccessLevel))
753753
d.Set("squash_commit_template", project.SquashCommitTemplate)
754754
d.Set("merge_commit_template", project.MergeCommitTemplate)
755+
756+
//Note: This field is deprecated and will always be an empty string starting in GitLab 15.0.
757+
d.Set("build_coverage_regex", project.BuildCoverageRegex)
758+
755759
return nil
756760
}
757761

@@ -780,11 +784,14 @@ func resourceGitlabProjectCreate(ctx context.Context, d *schema.ResourceData, me
780784
PrintingMergeRequestLinkEnabled: gitlab.Bool(d.Get("printing_merge_request_link_enabled").(bool)),
781785
Mirror: gitlab.Bool(d.Get("mirror").(bool)),
782786
MirrorTriggerBuilds: gitlab.Bool(d.Get("mirror_trigger_builds").(bool)),
783-
BuildCoverageRegex: gitlab.String(d.Get("build_coverage_regex").(string)),
784787
CIConfigPath: gitlab.String(d.Get("ci_config_path").(string)),
785788
CIForwardDeploymentEnabled: gitlab.Bool(d.Get("ci_forward_deployment_enabled").(bool)),
786789
}
787790

791+
if v, ok := d.GetOk("build_coverage_regex"); ok {
792+
options.BuildCoverageRegex = gitlab.String(v.(string))
793+
}
794+
788795
if v, ok := d.GetOk("path"); ok {
789796
options.Path = gitlab.String(v.(string))
790797
}
@@ -1312,7 +1319,7 @@ func resourceGitlabProjectUpdate(ctx context.Context, d *schema.ResourceData, me
13121319
}
13131320

13141321
if d.HasChange("build_coverage_regex") {
1315-
options.BuildCoverageRegex = gitlab.String(d.Get("build_coverage_regex").(string))
1322+
options.IssuesTemplate = gitlab.String(d.Get("build_coverage_regex").(string))
13161323
}
13171324

13181325
if d.HasChange("issues_template") {

internal/provider/resource_gitlab_project_test.go

+32-9
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ func TestAccGitlabProject_basic(t *testing.T) {
7777
PackagesEnabled: true,
7878
PrintingMergeRequestLinkEnabled: true,
7979
PagesAccessLevel: gitlab.PublicAccessControl,
80-
BuildCoverageRegex: "foo",
8180
IssuesTemplate: "",
8281
MergeRequestsTemplate: "",
8382
CIConfigPath: ".gitlab-ci.yml@mynamespace/myproject",
@@ -158,7 +157,6 @@ func TestAccGitlabProject_basic(t *testing.T) {
158157
Archived: true,
159158
PackagesEnabled: false,
160159
PagesAccessLevel: gitlab.DisabledAccessControl,
161-
BuildCoverageRegex: "bar",
162160
CIForwardDeploymentEnabled: false,
163161
ResolveOutdatedDiffDiscussions: false,
164162
AnalyticsAccessLevel: gitlab.DisabledAccessControl,
@@ -736,7 +734,6 @@ func TestAccGitlabProject_transfer(t *testing.T) {
736734
PackagesEnabled: true,
737735
PrintingMergeRequestLinkEnabled: true,
738736
PagesAccessLevel: gitlab.PrivateAccessControl,
739-
BuildCoverageRegex: "foo",
740737
CIForwardDeploymentEnabled: true,
741738
}
742739

@@ -1148,6 +1145,38 @@ func TestAccGitlabProject_containerExpirationPolicy(t *testing.T) {
11481145
})
11491146
}
11501147

1148+
func TestAccGitlabProject_DeprecatedBuildCoverageRegex(t *testing.T) {
1149+
var received gitlab.Project
1150+
rInt := acctest.RandInt()
1151+
1152+
resource.Test(t, resource.TestCase{
1153+
PreCheck: func() { testAccPreCheck(t) },
1154+
ProviderFactories: providerFactories,
1155+
CheckDestroy: testAccCheckGitlabProjectDestroy,
1156+
Steps: []resource.TestStep{
1157+
{
1158+
SkipFunc: isGitLabVersionLessThan(context.Background(), testGitlabClient, "15.0"),
1159+
Config: fmt.Sprintf(`
1160+
resource "gitlab_project" "this" {
1161+
name = "foo-%d"
1162+
visibility_level = "public"
1163+
1164+
build_coverage_regex = "helloWorld"
1165+
}`, rInt),
1166+
Check: resource.ComposeTestCheckFunc(
1167+
testAccCheckGitlabProjectExists("gitlab_project.this", &received),
1168+
),
1169+
},
1170+
{
1171+
SkipFunc: isGitLabVersionLessThan(context.Background(), testGitlabClient, "15.0"),
1172+
ResourceName: "gitlab_project.this",
1173+
ImportState: true,
1174+
ImportStateVerify: true,
1175+
},
1176+
},
1177+
})
1178+
}
1179+
11511180
func testAccCheckGitlabProjectExists(n string, project *gitlab.Project) resource.TestCheckFunc {
11521181
return func(s *terraform.State) error {
11531182
var err error
@@ -1359,7 +1388,6 @@ resource "gitlab_project" "foo" {
13591388
# So that acceptance tests can be run in a gitlab organization
13601389
# with no billing
13611390
visibility_level = "public"
1362-
build_coverage_regex = "foo"
13631391
}
13641392
`, rInt, rInt, rInt)
13651393
}
@@ -1415,7 +1443,6 @@ resource "gitlab_project" "foo" {
14151443
# So that acceptance tests can be run in a gitlab organization
14161444
# with no billing
14171445
visibility_level = "public"
1418-
build_coverage_regex = "foo"
14191446
}
14201447
14211448
resource "gitlab_project_variable" "foo" {
@@ -1449,7 +1476,6 @@ resource "gitlab_project" "foo" {
14491476
# So that acceptance tests can be run in a gitlab organization
14501477
# with no billing
14511478
visibility_level = "public"
1452-
build_coverage_regex = "foo"
14531479
}
14541480
14551481
resource "gitlab_project_variable" "foo" {
@@ -1489,7 +1515,6 @@ resource "gitlab_project" "foo" {
14891515
only_allow_merge_if_all_discussions_are_resolved = true
14901516
squash_option = "default_off"
14911517
pages_access_level = "public"
1492-
build_coverage_regex = "foo"
14931518
allow_merge_on_skipped_pipeline = false
14941519
ci_config_path = ".gitlab-ci.yml@mynamespace/myproject"
14951520
resolve_outdated_diff_discussions = true
@@ -1589,7 +1614,6 @@ resource "gitlab_project" "foo" {
15891614
archived = true
15901615
packages_enabled = false
15911616
pages_access_level = "disabled"
1592-
build_coverage_regex = "bar"
15931617
ci_forward_deployment_enabled = false
15941618
merge_pipelines_enabled = false
15951619
merge_trains_enabled = false
@@ -1929,7 +1953,6 @@ resource "gitlab_project" "foo" {
19291953
only_allow_merge_if_all_discussions_are_resolved = true
19301954
squash_option = "default_off"
19311955
pages_access_level = "public"
1932-
build_coverage_regex = "foo"
19331956
allow_merge_on_skipped_pipeline = false
19341957
ci_config_path = ".gitlab-ci.yml@mynamespace/myproject"
19351958
resolve_outdated_diff_discussions = true

0 commit comments

Comments
 (0)