Skip to content

Commit

Permalink
fix: rename this project to ghatm
Browse files Browse the repository at this point in the history
- #6
  • Loading branch information
suzuki-shunsuke committed Jun 27, 2024
1 parent 5fb7684 commit 0b04e6b
Show file tree
Hide file tree
Showing 12 changed files with 46 additions and 46 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/wc-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
16 changes: 8 additions & 8 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
version: 2
project_name: gha-set-timeout-minutes
project_name: ghatm

archives:
- name_template: "{{.ProjectName}}_{{.Os}}_{{.Arch}}"
Expand All @@ -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:
Expand All @@ -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
Expand All @@ -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.
Expand All @@ -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:
-
Expand Down
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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

Expand Down
6 changes: 3 additions & 3 deletions cmd/gha-set-timeout-minutes/main.go → cmd/ghatm/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand All @@ -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")
}
}

Expand Down
6 changes: 3 additions & 3 deletions cmdx.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/suzuki-shunsuke/gha-set-timeout-minutes
module github.com/suzuki-shunsuke/ghatm

go 1.22.4

Expand Down
18 changes: 9 additions & 9 deletions pkg/cli/completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
{
Expand Down Expand Up @@ -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]}
Expand All @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/cli/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions pkg/cli/set.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand All @@ -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{
Expand Down
2 changes: 1 addition & 1 deletion pkg/log/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
})
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/testutil/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
6 changes: 3 additions & 3 deletions scripts/generate-usage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ 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
}

echo "# Usage
<!-- This is generated by scripts/generate-usage.sh. Don't edit this file directly. -->
$(command_console gha-set-timeout-minutes help)
$(command_console ghatm help)
$(commands)
" > USAGE.md

0 comments on commit 0b04e6b

Please sign in to comment.