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

Add MultiMod releaser app (source code and half of unit tests) #8

Merged
merged 34 commits into from
Aug 10, 2021

Conversation

eddyleelin
Copy link
Contributor

@eddyleelin eddyleelin commented Jul 27, 2021

This PR adds code to generate a Go Cobra application used for flexible module releasing for Go repos with multiple Go Modules. Currently, the script works as intended in testing with the OpenTelemetry-Go repo, and is intended primarily for maintainers of repos. For more context about this tool, such as why it is necessary, how to use it, and what the overall design is, please see this design doc.

The following are completed and included in the PR:

  • support app subcommands
    • verify
    • prerelease
    • tag
  • update README with usage
  • unit tests have been added for all functions in common and verify

Here is the organization of the major source files changes (not including test-related or CI-related files):

- multimod/
    - README.md # README for the multimod tool
    - main.go # creates the Cobra app binary
    - cmd/ # handles CLI commands, subcommands, and flags using Cobra
        - root.go # define global flags
        - verify.go
        - prerelease.go
        - tag.go
    - internal/
        - common/ # shared functions for multimod app
            - commontest/ # package containing shared functions used for testing
            - conversions.go # convert between Mod import path, file path, tag names
            - tools.go # miscellaneous shared funcs
            - versions.go # structs/funcs for reading in version files
        - verify/
            - verify.go
        - prerelease/
            - prerelease.go
        - tag/
            - tag.go

There are several TODO items to clean up the code which will be implemented shortly in subsequent PRs, including a full testing suite to help maintain the tool. In addition, several refactoring items and additional features are currently in the works, such as:

  • prevent script from deleting tags already in remote upstream
  • use Go-Git for Git functions rather than CLI (in progress)
  • enhance error messaging in verify to support slices of errors and update syntax
  • add ability to specify multiple module sets
  • add verification to tag script to check that the module set specified is the same as the one updated in the prerelease commit
  • add functionality to run "go mod tidy" for all Modules in prerelease step

Includes code to generate the Cobra "releasing" application and unit tests for versions/versions.go and verify/verify.go
Need to add the makeTree function to create the go.mod test files during runtime, rather than storing in the repo.
Additionally added dynamic creation of mod files
Ensures that error messages do not have capitalization or end with punctuation. Handles all errors in test files.
@codecov
Copy link

codecov bot commented Jul 29, 2021

Codecov Report

Merging #8 (6007c84) into main (520d53f) will increase coverage by 9.43%.
The diff coverage is 39.69%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main       #8      +/-   ##
==========================================
+ Coverage   30.00%   39.43%   +9.43%     
==========================================
  Files           1       14      +13     
  Lines          20      743     +723     
==========================================
+ Hits            6      293     +287     
- Misses         11      423     +412     
- Partials        3       27      +24     
Impacted Files Coverage Δ
multimod/internal/prerelease/prerelease.go 0.00% <0.00%> (ø)
multimod/internal/tag/tag.go 0.00% <0.00%> (ø)
multimod/main.go 0.00% <0.00%> (ø)
multimod/cmd/verify.go 26.31% <26.31%> (ø)
multimod/internal/verify/errors.go 30.76% <30.76%> (ø)
multimod/internal/common/commontest/commontest.go 37.25% <37.25%> (ø)
multimod/cmd/tag.go 40.00% <40.00%> (ø)
multimod/internal/common/tools.go 53.84% <53.84%> (ø)
multimod/internal/common/versions.go 53.84% <53.84%> (ø)
multimod/cmd/root.go 63.63% <63.63%> (ø)
... and 16 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 520d53f...6007c84. Read the comment docs.

@pellared
Copy link
Member

pellared commented Jul 29, 2021

Disclaimer: Opinionated comment

I think it might be worth considering using https://github.com/goyek/goyek for making build pipelines in Go.
As an example I am trying to make some reusable tasks/pipelines here: https://github.com/signalfx/go-pipeline and here is a sample PR for adoption: signalfx/splunk-otel-go#71

Why? I think it would be easier to maintain, debug, and use than a combination of CLI Go programs + Makefile.

Tomorrow, I will try to create an issue about it under https://github.com/open-telemetry/opentelemetry-go regarding it. Then I will remove or edit this comment.

EDIT

Here is the issue: open-telemetry/opentelemetry-go#2152

releaser/README.md Outdated Show resolved Hide resolved
releaser/internal/verify/verify.go Outdated Show resolved Hide resolved
@eddyleelin eddyleelin changed the title Add Releaser app (source code and half of unit tests) Add MultiMod releaser app (source code and half of unit tests) Aug 2, 2021
multimod/go.mod Show resolved Hide resolved
multimod/README.md Show resolved Hide resolved
multimod/README.md Outdated Show resolved Hide resolved
multimod/README.md Outdated Show resolved Hide resolved
multimod/README.md Outdated Show resolved Hide resolved
multimod/README.md Outdated Show resolved Hide resolved
@MrAlias MrAlias merged commit 84eb691 into open-telemetry:main Aug 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants