Skip to content

Commit 54620d1

Browse files
feat(release-checks): introduce discrimination of quality guidelines by repo category (#1530)
* feat(release-checks): introduce discrimination of quality guidelines by repo category * chore(test_runner): fix log messages, remove outcommented code and fix typos
1 parent cd51776 commit 54620d1

24 files changed

+295
-30
lines changed

release-automation/cmd/run_trg_checks.go

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,18 @@ var checkLocalCmd = &cobra.Command{
4949
basedir = "./"
5050
}
5151

52-
var releaseGuidelines = []tractusx.QualityGuideline{
52+
metadata, err := tractusx.MetadataFromLocalFile(basedir)
53+
if err != nil {
54+
fmt.Println("Error occurred! Metadata file (.tractusx) missing at root directory of repo. Please check out TRG 2.05: https://eclipse-tractusx.github.io/docs/release/trg-2/trg-2-05")
55+
os.Exit(1)
56+
}
57+
58+
if metadata.RepoCategory == tractusx.RepoCategoryUnknown {
59+
fmt.Println("Error occurred! Metadata file (.tractusx) contains no or unknown repository category. Please check out TRG 2.05: https://eclipse-tractusx.github.io/docs/release/trg-2/trg-2-05")
60+
os.Exit(1)
61+
}
62+
63+
allReleaseGuidelines := []tractusx.QualityGuideline{
5364
docs.NewReadmeExists(basedir),
5465
docs.NewInstallExists(basedir),
5566
docs.NewChangelogExists(basedir),
@@ -66,8 +77,10 @@ var checkLocalCmd = &cobra.Command{
6677
open_source.NewNoticeForNonCodeExists(basedir),
6778
}
6879

69-
runner := testrunner.NewTestRunner(releaseGuidelines)
70-
err := runner.Run()
80+
//applicableGuidelines := getApplicableGuidelines(allReleaseGuidelines, metadata.RepoCategory)
81+
82+
runner := testrunner.NewTestRunner(allReleaseGuidelines, *metadata)
83+
err = runner.Run()
7184

7285
if err != nil {
7386
fmt.Println("Error occurred! Check command output for details on failed checks")
@@ -78,6 +91,16 @@ var checkLocalCmd = &cobra.Command{
7891
},
7992
}
8093

94+
func getApplicableGuidelines(allGuidelines []tractusx.QualityGuideline, category tractusx.RepoCategory) []tractusx.QualityGuideline {
95+
var applicable []tractusx.QualityGuideline
96+
for _, guideline := range allGuidelines {
97+
if guideline.IsApplicableToCategory(category) {
98+
applicable = append(applicable, guideline)
99+
}
100+
}
101+
return applicable
102+
}
103+
81104
func init() {
82105
rootCmd.AddCommand(checkLocalCmd)
83106
}

release-automation/internal/container/allowed_base_image_check.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*******************************************************************************
22
* Copyright (c) 2023 Contributors to the Eclipse Foundation
3+
* Copyright (c) 2025 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. (represented by Fraunhofer ISST)
34
*
45
* See the NOTICE file(s) distributed with this work for additional
56
* information regarding copyright ownership.
@@ -127,3 +128,7 @@ func containsString(slice []string, element string) bool {
127128
}
128129
return false
129130
}
131+
132+
func (a *AllowedBaseImage) IsApplicableToCategory(category tractusx.RepoCategory) bool {
133+
return category == tractusx.RepoCategoryProduct
134+
}

release-automation/internal/container/dockerfile.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*******************************************************************************
22
* Copyright (c) 2023 Contributors to the Eclipse Foundation
3+
* Copyright (c) 2025 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. (represented by Fraunhofer ISST)
34
*
45
* See the NOTICE file(s) distributed with this work for additional
56
* information regarding copyright ownership.
@@ -28,6 +29,7 @@ import (
2829
pathUtil "path"
2930
"path/filepath"
3031
"strings"
32+
"tractusx-release-automation/internal/tractusx"
3133
)
3234

3335
// dockerfile is a simple utility to create or read dockerfiles.
@@ -160,3 +162,7 @@ func readLines(file *os.File) []string {
160162
}
161163
return lines
162164
}
165+
166+
func (a *dockerfile) IsApplicableToCategory(category tractusx.RepoCategory) bool {
167+
return category == tractusx.RepoCategoryProduct
168+
}

release-automation/internal/container/non_root_container_check.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*******************************************************************************
22
* Copyright (c) 2023 Contributors to the Eclipse Foundation
3+
* Copyright (c) 2025 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. (represented by Fraunhofer ISST)
34
*
45
* See the NOTICE file(s) distributed with this work for additional
56
* information regarding copyright ownership.
@@ -113,3 +114,7 @@ func isRootUser(user string) bool {
113114
func isRootGroup(group string) bool {
114115
return group == "root" || group == "0"
115116
}
117+
118+
func (a *NonRootContainer) IsApplicableToCategory(category tractusx.RepoCategory) bool {
119+
return category == tractusx.RepoCategoryProduct
120+
}

release-automation/internal/dashboard/tractusx.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ func getProductsFromMetadata(metadataForRepo map[string]repoInfo) []Product {
190190
log.Printf("Repo %s is leading, addign name (%s) + repo URL (%s) to product", url, info.metadata.ProductName, info.metadata.LeadingRepository)
191191
p.Name = info.metadata.ProductName
192192
p.LeadingRepo = info.metadata.LeadingRepository
193-
p.RepoCategory = info.metadata.RepoCategory
193+
p.RepoCategory = info.metadata.RepoCategory.String()
194194
}
195195
}
196196

release-automation/internal/docs/admin_guide_exists.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,7 @@ func (a *AdminGuideExists) Test() *tractusx.QualityResult {
6060
func (a *AdminGuideExists) IsOptional() bool {
6161
return true
6262
}
63+
64+
func (a *AdminGuideExists) IsApplicableToCategory(category tractusx.RepoCategory) bool {
65+
return category == tractusx.RepoCategoryProduct
66+
}

release-automation/internal/docs/architecture_documentation_exists.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,7 @@ func getArchitectureDocEntryPaths(dir string) []string {
9292

9393
return append(allowedArchitectureDocsGlob, file.ArchitectureDocEntryPath)
9494
}
95+
96+
func (a *ArchitectureDocumentationExists) IsApplicableToCategory(category tractusx.RepoCategory) bool {
97+
return category == tractusx.RepoCategoryProduct
98+
}

release-automation/internal/docs/changelog_exists.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*******************************************************************************
22
* Copyright (c) 2023 Contributors to the Eclipse Foundation
3+
* Copyright (c) 2025 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. (represented by Fraunhofer ISST)
34
*
45
* See the NOTICE file(s) distributed with this work for additional
56
* information regarding copyright ownership.
@@ -61,3 +62,7 @@ func (c ChangeLogExists) Test() *tractusx.QualityResult {
6162
}
6263
return &tractusx.QualityResult{Passed: true}
6364
}
65+
66+
func (a *ChangeLogExists) IsApplicableToCategory(category tractusx.RepoCategory) bool {
67+
return category == tractusx.RepoCategoryProduct || category == tractusx.RepoCategorySupport || category == tractusx.RepoCategorySpecial
68+
}

release-automation/internal/docs/install_exists.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*******************************************************************************
22
* Copyright (c) 2023 Contributors to the Eclipse Foundation
3+
* Copyright (c) 2025 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. (represented by Fraunhofer ISST)
34
*
45
* See the NOTICE file(s) distributed with this work for additional
56
* information regarding copyright ownership.
@@ -64,3 +65,7 @@ func (i *InstallExists) Test() *tractusx.QualityResult {
6465
func (i *InstallExists) IsOptional() bool {
6566
return true
6667
}
68+
69+
func (a *InstallExists) IsApplicableToCategory(category tractusx.RepoCategory) bool {
70+
return category == tractusx.RepoCategoryProduct
71+
}

release-automation/internal/docs/readme_exists.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*******************************************************************************
22
* Copyright (c) 2023 Contributors to the Eclipse Foundation
3+
* Copyright (c) 2025 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. (represented by Fraunhofer ISST)
34
*
45
* See the NOTICE file(s) distributed with this work for additional
56
* information regarding copyright ownership.
@@ -61,3 +62,7 @@ func (r *ReadmeExists) Test() *tractusx.QualityResult {
6162
}
6263
return &tractusx.QualityResult{Passed: true}
6364
}
65+
66+
func (a *ReadmeExists) IsApplicableToCategory(category tractusx.RepoCategory) bool {
67+
return category == tractusx.RepoCategoryProduct || category == tractusx.RepoCategorySupport || category == tractusx.RepoCategorySpecial
68+
}

0 commit comments

Comments
 (0)