Skip to content

Commit

Permalink
Adds a Taskfile in line with internal Go dev standards and also forma…
Browse files Browse the repository at this point in the history
…ts the code
  • Loading branch information
elliotforbes committed Sep 28, 2022
1 parent 7587e2d commit 5aea070
Show file tree
Hide file tree
Showing 9 changed files with 87 additions and 27 deletions.
60 changes: 60 additions & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
version: '3'

tasks:
lint:
desc: Lint code
cmds:
- golangci-lint run -c .golangci.yml
summary: Lint the project with golangci-lint

clean:
desc: Cleans out the build, out, docs, and dist directories
cmds:
- GO111MODULE=off go clean -i
- rm -rf build out docs dist

fmt:
desc: Run `go fmt` to format the code
cmds:
- go fmt ./...

test:
desc: Run the tests
cmds:
- TESTING=true go test -v ./...

tidy:
desc: Run 'go mod tidy' to clean up module files.
cmds:
- go mod tidy -v

doc:
desc: run's the godocs
cmds:
- godoc -http=:6060

check-go-mod:
desc: Check go.mod is tidy
cmds:
- go mod tidy -v
- git diff --exit-code -- go.mod go.sum

vendor:
desc: go mod vendor
cmds:
- go mod vendor

build:
desc: Build main
cmds:
- go build -v -o build/darwin/amd64/circleci .

build-linux:
desc: Build main
cmds:
- go build -v -o build/linux/amd64/circleci .

cover:
desc: tests and generates a cover profile
cmds:
- TESTING=true go test -race -coverprofile=coverage.txt ./...
4 changes: 2 additions & 2 deletions api/context_rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ func (c *ContextRestClient) listContexts(params *listContextsParams) (*listConte
return &dest, nil
}

//newCreateContextRequest posts a new context creation with orgname and vcs type using a slug
// newCreateContextRequest posts a new context creation with orgname and vcs type using a slug
func (c *ContextRestClient) newCreateContextRequest(vcs, org, name string) (*http.Request, error) {
var err error
queryURL, err := url.Parse(c.server)
Expand Down Expand Up @@ -398,7 +398,7 @@ func (c *ContextRestClient) newCreateContextRequest(vcs, org, name string) (*htt
return c.newHTTPRequest("POST", queryURL.String(), bodyReader)
}

//newCreateContextRequestWithOrgID posts a new context creation with an orgID
// newCreateContextRequestWithOrgID posts a new context creation with an orgID
func (c *ContextRestClient) newCreateContextRequestWithOrgID(orgID *string, name string) (*http.Request, error) {
var err error
queryURL, err := url.Parse(c.server)
Expand Down
2 changes: 1 addition & 1 deletion api/info/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type InfoRESTClient struct {
client *http.Client
}

//organization json org info
// organization json org info
type Organization struct {
ID string `json:"id"`
Name string `json:"name"`
Expand Down
4 changes: 2 additions & 2 deletions cmd/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,8 @@ func readSecretValue() (string, error) {
}
}

//createContext determines if the context is being created via orgid or vcs and org name
//and navigates to corresponding function accordingly
// createContext determines if the context is being created via orgid or vcs and org name
// and navigates to corresponding function accordingly
func createContext(cmd *cobra.Command, client api.ContextInterface, args []string) error {
//skip if no orgid provided
if orgID != nil && strings.TrimSpace(*orgID) != "" && len(args) == 1 {
Expand Down
4 changes: 2 additions & 2 deletions cmd/follow.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type options struct {
cfg *settings.Config
}

//followProject gets the remote data and attempts to follow its git project
// followProject gets the remote data and attempts to follow its git project
func followProject(opts options) error {

remote, err := git.InferProjectFromGitRemotes()
Expand Down Expand Up @@ -45,7 +45,7 @@ func followProject(opts options) error {
return nil
}

//followProjectCommand follow cobra command creation
// followProjectCommand follow cobra command creation
func followProjectCommand(config *settings.Config) *cobra.Command {
opts := options{
cfg: config,
Expand Down
6 changes: 3 additions & 3 deletions cmd/info/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/spf13/cobra"
)

//infoOptions info command options
// infoOptions info command options
type infoOptions struct {
cfg *settings.Config
validator validator.Validator
Expand All @@ -33,7 +33,7 @@ func NewInfoCommand(config *settings.Config, preRunE validator.Validator) *cobra
return infoCommand
}

//orgInfoCommand organization information subcommand cobra command creation
// orgInfoCommand organization information subcommand cobra command creation
func orgInfoCommand(client info.InfoClient, opts infoOptions) *cobra.Command {
return &cobra.Command{
Use: "org",
Expand All @@ -48,7 +48,7 @@ func orgInfoCommand(client info.InfoClient, opts infoOptions) *cobra.Command {
}
}

//getOrgInformation gets all of the users organizations' information
// getOrgInformation gets all of the users organizations' information
func getOrgInformation(cmd *cobra.Command, client info.InfoClient) error {
resp, err := client.GetInfo()
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions cmd/open.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ var errorMessage = `
This command is intended to be run from a git repository with a remote named 'origin' that is hosted on Github or Bitbucket only.
We are not currently supporting any other hosts.`

//projectUrl uses the provided values to create the url to open
// projectUrl uses the provided values to create the url to open
func projectUrl(remote *git.Remote) string {
return fmt.Sprintf("https://app.circleci.com/pipelines/%s/%s/%s",
url.PathEscape(strings.ToLower(string(remote.VcsType))),
url.PathEscape(remote.Organization),
url.PathEscape(remote.Project))
}

//openProjectInBrowser takes the created url and opens a browser to it
// openProjectInBrowser takes the created url and opens a browser to it
func openProjectInBrowser() error {
remote, err := git.InferProjectFromGitRemotes()
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ func skipUpdateByDefault() bool {

/**************** Help Menu Functions ****************/

//rootHelpLong creates content for the long field in the command
// rootHelpLong creates content for the long field in the command
func rootHelpLong() string {
long := `
/?? /?? /??
Expand Down
28 changes: 14 additions & 14 deletions update/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,20 +136,20 @@ func checkFromHomebrew(check *Options) error {
// HomebrewOutdated wraps the JSON output from running `brew outdated --json=v2`
// We're specifically looking for this kind of structured data from the command:
//
// {
// "formulae": [
// {
// "name": "circleci",
// "installed_versions": [
// "0.1.1248"
// ],
// "current_version": "0.1.3923",
// "pinned": false,
// "pinned_version": null
// }
// ],
// "casks": []
// }
// {
// "formulae": [
// {
// "name": "circleci",
// "installed_versions": [
// "0.1.1248"
// ],
// "current_version": "0.1.3923",
// "pinned": false,
// "pinned_version": null
// }
// ],
// "casks": []
// }
type HomebrewOutdated struct {
Formulae []struct {
Name string `json:"name"`
Expand Down

0 comments on commit 5aea070

Please sign in to comment.