Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove checkdoc #380

Merged
merged 3 commits into from
Jul 31, 2023
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
16 changes: 16 additions & 0 deletions .chloggen/remove-checkdoc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: breaking

# The name of the component, or a single word describing the area of concern, (e.g. crosslink)
component: checkdoc

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: checkdoc has been removed in favor of checkfile. Please use checkfile with argument --file-name README.md instead.

# One or more tracking issues related to the change
issues: [378]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ go.work.sum
crosslink/internal/test_data/
!crosslink/internal/test_data/.placeholder

checkdoc/checkdoc
checkfile/checkfile
chloggen/chloggen
crosslink/crosslink
Expand Down
17 changes: 0 additions & 17 deletions checkdoc/README.md

This file was deleted.

8 changes: 0 additions & 8 deletions checkdoc/go.mod

This file was deleted.

4 changes: 0 additions & 4 deletions checkdoc/go.sum

This file was deleted.

53 changes: 0 additions & 53 deletions checkdoc/main.go

This file was deleted.

30 changes: 4 additions & 26 deletions internal/check/check.go → checkfile/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// Package check provides functions used in checkdoc and checkfile.
package check
package main

import (
"flag"
"fmt"
"go/parser"
"go/token"
Expand All @@ -25,26 +23,6 @@ import (
"strings"
)

const (
// Absolute root path of the project
projectPathFlag = "project-path"
// Relative path where imports all default components
relativeDefaultComponentsPathFlag = "component-rel-path"
// The project Go Module name
projectGoModuleFlag = "module-name"
// The name of the file to validate
fileNameFlag = "file-name"
)

func Flags() (projectPath *string, componentPath *string, moduleName *string, fileName *string) {
projectPath = flag.String(projectPathFlag, "", "specify the project path")
componentPath = flag.String(relativeDefaultComponentsPathFlag, "", "specify the relative component path")
moduleName = flag.String(projectGoModuleFlag, "", "specify the project go module")
fileName = flag.String(fileNameFlag, "", "specify the file name")
flag.Parse()
return
}

// FileExists returns an error if the given file is missing for at least one
// enabled component. "projectPath" is the absolute path to the root
// of the project to which the components belong. "defaultComponentsFilePath" is
Expand Down Expand Up @@ -72,10 +50,10 @@ func FileExists(projectPath string, relativeComponentsPath string, projectGoModu

if isComponentImport(importPath, importPrefixesToCheck) {
relativeComponentPath := strings.Replace(importPath, projectGoModule, "", 1)
readmePath := filepath.Join(projectPath, relativeComponentPath, filename)
_, err := os.Stat(readmePath)
filePath := filepath.Join(projectPath, relativeComponentPath, filename)
_, err := os.Stat(filePath)
if err != nil {
return fmt.Errorf("%s does not exist at %s, add one", filename, readmePath)
return fmt.Errorf("%s does not exist at %s, add one", filename, filePath)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion internal/check/check_test.go → checkfile/file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// limitations under the License.

// Package tools provides helper functions used in multiple build tools.
package check
package main

import (
"os"
Expand Down
8 changes: 6 additions & 2 deletions checkfile/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ module go.opentelemetry.io/build-tools/checkfile

go 1.19

require go.opentelemetry.io/build-tools v0.10.0
require github.com/stretchr/testify v1.8.4

replace go.opentelemetry.io/build-tools => ../
require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
6 changes: 6 additions & 0 deletions checkfile/go.sum
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
23 changes: 20 additions & 3 deletions checkfile/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,18 @@
package main

import (
"go.opentelemetry.io/build-tools/internal/check"
"flag"
)

const (
// Absolute root path of the project
projectPathFlag = "project-path"
// Relative path where imports all default components
relativeDefaultComponentsPathFlag = "component-rel-path"
// The project Go Module name
projectGoModuleFlag = "module-name"
// The name of the file to validate
fileNameFlag = "file-name"
)

// The main verifies if filename exists for the enabled default components
Expand All @@ -34,12 +45,18 @@ import (
// --module-name github.com/open-telemetry/opentelemetry-collector-contrib
// --file-name metadata.yaml
func main() {
projectPath, componentPath, moduleName, fileName := check.Flags()
projectPath := flag.String(projectPathFlag, "", "specify the project path")
componentPath := flag.String(relativeDefaultComponentsPathFlag, "", "specify the relative component path")
moduleName := flag.String(projectGoModuleFlag, "", "specify the project go module")
fileName := flag.String(fileNameFlag, "", "specify the file name")

flag.Parse()

if *fileName == "" {
panic("Missing required argument: --file-name")
}

err := check.FileExists(
err := FileExists(
*projectPath,
*componentPath,
*moduleName,
Expand Down
1 change: 0 additions & 1 deletion versions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ module-sets:
version: v0.10.0
modules:
- go.opentelemetry.io/build-tools
- go.opentelemetry.io/build-tools/checkdoc
- go.opentelemetry.io/build-tools/checkfile
- go.opentelemetry.io/build-tools/chloggen
- go.opentelemetry.io/build-tools/crosslink
Expand Down