diff --git a/.github/workflows/wc-test.yaml b/.github/workflows/wc-test.yaml index 65fef9b..75bcab8 100644 --- a/.github/workflows/wc-test.yaml +++ b/.github/workflows/wc-test.yaml @@ -25,5 +25,5 @@ jobs: env: AQUA_GITHUB_TOKEN: ${{github.token}} - run: go test -v ./... -race -covermode=atomic - - run: go run ./cmd/gha-set-timeout-minutes set testdata/before.yaml + - run: go run ./cmd/ghatm set testdata/before.yaml - run: diff testdata/before.yaml testdata/after.yaml diff --git a/.goreleaser.yml b/.goreleaser.yml index 4a4786b..955e776 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -1,6 +1,6 @@ --- version: 2 -project_name: gha-set-timeout-minutes +project_name: ghatm archives: - name_template: "{{.ProjectName}}_{{.Os}}_{{.Arch}}" @@ -9,8 +9,8 @@ archives: format: zip builds: - - binary: gha-set-timeout-minutes - main: cmd/gha-set-timeout-minutes/main.go + - binary: ghatm + main: cmd/ghatm/main.go env: - CGO_ENABLED=0 goos: @@ -24,7 +24,7 @@ builds: release: prerelease: true header: | - [Pull Requests](https://github.com/suzuki-shunsuke/gha-set-timeout-minutes/pulls?q=is%3Apr+milestone%3A{{.Tag}}) | [Issues](https://github.com/suzuki-shunsuke/gha-set-timeout-minutes/issues?q=is%3Aissue+milestone%3A{{.Tag}}) | https://github.com/suzuki-shunsuke/gha-set-timeout-minutes/compare/{{.PreviousTag}}...{{.Tag}} + [Pull Requests](https://github.com/suzuki-shunsuke/ghatm/pulls?q=is%3Apr+milestone%3A{{.Tag}}) | [Issues](https://github.com/suzuki-shunsuke/ghatm/issues?q=is%3Aissue+milestone%3A{{.Tag}}) | https://github.com/suzuki-shunsuke/ghatm/compare/{{.PreviousTag}}...{{.Tag}} signs: - cmd: cosign @@ -51,13 +51,13 @@ brews: # GitHub/GitLab repository to push the formula to repository: owner: suzuki-shunsuke - name: homebrew-gha-set-timeout-minutes + name: homebrew-ghatm token: "{{ .Env.HOMEBREW_TAP_GITHUB_TOKEN }}" # The project name and current git tag are used in the format string. commit_msg_template: "Brew formula update for {{ .ProjectName }} version {{ .Tag }}" # Your app's homepage. # Default is empty. - homepage: https://github.com/suzuki-shunsuke/gha-set-timeout-minutes + homepage: https://github.com/suzuki-shunsuke/ghatm # Template of your app's description. # Default is empty. @@ -76,14 +76,14 @@ brews: # So you can `brew test` your formula. # Default is empty. test: | - system "#{bin}/gha-set-timeout-minutes --version" + system "#{bin}/ghatm --version" # Additional install instructions so you don't need to override `install`. # # Template: allowed # Since: v1.20 extra_install: | - generate_completions_from_executable(bin/"gha-set-timeout-minutes", "completion", shells: [:bash, :zsh, :fish]) + generate_completions_from_executable(bin/"ghatm", "completion", shells: [:bash, :zsh, :fish]) scoops: - diff --git a/README.md b/README.md index 26806d2..8f56e6e 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# gha-set-timeout-minutes +# ghatm Set [timeout-minutes](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idtimeout-minutes) to all GitHub Actions jobs @@ -9,43 +9,43 @@ Set [timeout-minutes](https://docs.github.com/en/actions/using-workflows/workflo - [job_timeout_minutes_is_required | lintnet-modules/ghalint](https://github.com/lintnet-modules/ghalint/tree/main/workflow/job_timeout_minutes_is_required) `timeout-minutes` should be set properly, but if you have a lot of workflows which don't set `timeout-minutes` it's so bothersome to fix all of them by hand. -`gha-set-timeout-minutes` sets `timeout-minutes` automatically. +`ghatm` sets `timeout-minutes` automatically. ## Install -`gha-set-timeout-minutes` is a single binary written in Go. +`ghatm` is a single binary written in Go. So you only need to put the executable binary into `$PATH`. ```sh -go install github.com/suzuki-shunsuke/gha-set-timeout-minutes@latest +go install github.com/suzuki-shunsuke/ghatm@latest ``` ## How to use -Please run `gha-set-timeout-minutes set` at the repository root directory. +Please run `ghatm set` at the repository root directory. ```sh -gha-set-timeout-minutes set +ghatm set ``` -then `gha-set-timeout-minutes` checks GitHub Actions workflows `^\.github/workflows/.*\.ya?ml$` and sets `timeout-minutes: 30` to jobs which don't have `timeout-minutes`. +then `ghatm` checks GitHub Actions workflows `^\.github/workflows/.*\.ya?ml$` and sets `timeout-minutes: 30` to jobs which don't have `timeout-minutes`. Jobs which have `timeout-minutes` aren't changed. You can specify the value of `timeout-minutes` with `-m` option. ```sh -gha-set-timeout-minutes set -m 60 +ghatm set -m 60 ``` You can specify workflow files by positional arguments. ```sh -gha-set-timeout-minutes set .github/workflows/test.yaml +ghatm set .github/workflows/test.yaml ``` ## Tips: Fix workflows by CI -Using `gha-set-timeout-minutes` in CI, you can fix workflows automatically. -When workflow files are added or changed in a pull request, you can run `gha-set-timeout-minutes` and commit and push changes to a feature branch. +Using `ghatm` in CI, you can fix workflows automatically. +When workflow files are added or changed in a pull request, you can run `ghatm` and commit and push changes to a feature branch. ## LICENSE diff --git a/cmd/gha-set-timeout-minutes/main.go b/cmd/ghatm/main.go similarity index 78% rename from cmd/gha-set-timeout-minutes/main.go rename to cmd/ghatm/main.go index 9dcfd80..847ff14 100644 --- a/cmd/gha-set-timeout-minutes/main.go +++ b/cmd/ghatm/main.go @@ -7,8 +7,8 @@ import ( "syscall" "github.com/sirupsen/logrus" - "github.com/suzuki-shunsuke/gha-set-timeout-minutes/pkg/cli" - "github.com/suzuki-shunsuke/gha-set-timeout-minutes/pkg/log" + "github.com/suzuki-shunsuke/ghatm/pkg/cli" + "github.com/suzuki-shunsuke/ghatm/pkg/log" "github.com/suzuki-shunsuke/logrus-error/logerr" ) @@ -21,7 +21,7 @@ var ( func main() { logE := log.New(version) if err := core(logE); err != nil { - logerr.WithError(logE, err).Fatal("gha-set-timeout-minutes failed") + logerr.WithError(logE, err).Fatal("ghatm failed") } } diff --git a/cmdx.yaml b/cmdx.yaml index a31e95c..9efbce1 100644 --- a/cmdx.yaml +++ b/cmdx.yaml @@ -39,9 +39,9 @@ tasks: - name: target - name: install short: i - description: Build and install gha-set-timeout-minutes - usage: Build and install gha-set-timeout-minutes by "go install" command - script: go install ./cmd/gha-set-timeout-minutes + description: Build and install ghatm + usage: Build and install ghatm by "go install" command + script: go install ./cmd/ghatm - name: fmt description: Format GO codes usage: Format GO codes diff --git a/go.mod b/go.mod index f972c3f..c99be5d 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/suzuki-shunsuke/gha-set-timeout-minutes +module github.com/suzuki-shunsuke/ghatm go 1.22.4 diff --git a/pkg/cli/completion.go b/pkg/cli/completion.go index 1f2ae39..27db06c 100644 --- a/pkg/cli/completion.go +++ b/pkg/cli/completion.go @@ -25,15 +25,15 @@ e.g. .bash_profile -source <(gha-set-timeout-minutes completion bash) +source <(ghatm completion bash) .zprofile -source <(gha-set-timeout-minutes completion zsh) +source <(ghatm completion zsh) fish -gha-set-timeout-minutes completion fish > ~/.config/fish/completions/gha-set-timeout-minutes.fish +ghatm completion fish > ~/.config/fish/completions/ghatm.fish `, Subcommands: []*cli.Command{ { @@ -74,16 +74,16 @@ _cli_bash_autocomplete() { fi } -complete -o bashdefault -o default -o nospace -F _cli_bash_autocomplete gha-set-timeout-minutes`) +complete -o bashdefault -o default -o nospace -F _cli_bash_autocomplete ghatm`) return nil } func (cc *completionCommand) zshCompletionAction(*cli.Context) error { // https://github.com/urfave/cli/blob/main/autocomplete/zsh_autocomplete // https://github.com/urfave/cli/blob/947f9894eef4725a1c15ed75459907b52dde7616/autocomplete/zsh_autocomplete - fmt.Fprintln(cc.stdout, `#compdef gha-set-timeout-minutes + fmt.Fprintln(cc.stdout, `#compdef ghatm -_gha-set-timeout-minutes() { +_ghatm() { local -a opts local cur cur=${words[-1]} @@ -100,10 +100,10 @@ _gha-set-timeout-minutes() { fi } -if [ "$funcstack[1]" = "_gha-set-timeout-minutes" ]; then - _gha-set-timeout-minutes "$@" +if [ "$funcstack[1]" = "_ghatm" ]; then + _ghatm "$@" else - compdef _gha-set-timeout-minutes gha-set-timeout-minutes + compdef _ghatm ghatm fi`) return nil } diff --git a/pkg/cli/runner.go b/pkg/cli/runner.go index a9d3968..3fd1814 100644 --- a/pkg/cli/runner.go +++ b/pkg/cli/runner.go @@ -29,7 +29,7 @@ func (r *Runner) Run(ctx context.Context, args ...string) error { compiledDate = time.Now() } app := cli.App{ - Name: "gha-set-timeout-minutes", + Name: "ghatm", Usage: "", Version: r.LDFlags.Version + " (" + r.LDFlags.Commit + ")", Compiled: compiledDate, diff --git a/pkg/cli/set.go b/pkg/cli/set.go index 6a3c15f..878d2f7 100644 --- a/pkg/cli/set.go +++ b/pkg/cli/set.go @@ -3,8 +3,8 @@ package cli import ( "github.com/sirupsen/logrus" "github.com/spf13/afero" - "github.com/suzuki-shunsuke/gha-set-timeout-minutes/pkg/controller/set" - "github.com/suzuki-shunsuke/gha-set-timeout-minutes/pkg/log" + "github.com/suzuki-shunsuke/ghatm/pkg/controller/set" + "github.com/suzuki-shunsuke/ghatm/pkg/log" "github.com/urfave/cli/v2" ) @@ -16,10 +16,10 @@ func (rc *setCommand) command() *cli.Command { return &cli.Command{ Name: "set", Usage: "Set timeout-minutes to GitHub Actions jobs which don't have timeout-minutes", - UsageText: "gha-set-timeout-minutes set", + UsageText: "ghatm set", Description: `Set timeout-minutes to GitHub Actions jobs which don't have timeout-minutes. -$ gha-set-timeout-minutes set +$ ghatm set `, Action: rc.action, Flags: []cli.Flag{ diff --git a/pkg/log/log.go b/pkg/log/log.go index 57ed4dd..2853b7a 100644 --- a/pkg/log/log.go +++ b/pkg/log/log.go @@ -16,7 +16,7 @@ func New(version string) *logrus.Entry { } return logger.WithFields(logrus.Fields{ "version": version, - "program": "gha-set-timeout-minutes", + "program": "ghatm", "env": fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH), }) } diff --git a/pkg/testutil/util.go b/pkg/testutil/util.go index 26e3744..8568f2d 100644 --- a/pkg/testutil/util.go +++ b/pkg/testutil/util.go @@ -5,7 +5,7 @@ import ( "os" "github.com/spf13/afero" - "github.com/suzuki-shunsuke/gha-set-timeout-minutes/pkg/osfile" + "github.com/suzuki-shunsuke/ghatm/pkg/osfile" ) const ( diff --git a/scripts/generate-usage.sh b/scripts/generate-usage.sh index 811c577..e012374 100644 --- a/scripts/generate-usage.sh +++ b/scripts/generate-usage.sh @@ -15,9 +15,9 @@ command_console() { commands() { for cmd in set completion; do echo " -## gha-set-timeout-minutes $cmd +## ghatm $cmd -$(command_console gha-set-timeout-minutes help $cmd)" +$(command_console ghatm help $cmd)" done } @@ -25,6 +25,6 @@ echo "# Usage -$(command_console gha-set-timeout-minutes help) +$(command_console ghatm help) $(commands) " > USAGE.md