Set GitHub Actions timeout-minutes

In this article I introduce a GitHub Actions’ setting timeout-minutes and tools related to timeout-minutes.

What’s timeout-minutes?
Why should you set timeout-minutes?
Linters to enforce timeout-minutes
A command line tool to set timeout-minutes to a…


This content originally appeared on DEV Community and was authored by Shunsuke Suzuki

In this article I introduce a GitHub Actions' setting timeout-minutes and tools related to timeout-minutes.

  • What's timeout-minutes?
  • Why should you set timeout-minutes?
  • Linters to enforce timeout-minutes
  • A command line tool to set timeout-minutes to all GitHub Actions jobs
  • Set timeout-minutes to your all repositories

What's timeout-minutes?

timeout-minutes is the maximum number of minutes to let a job run before GitHub automatically cancels it.
The default value is 360.

Why should you set timeout-minutes?

The default value of timeout-minutes is 360, but this is too long for most GitHub Actions jobs.
Even if processes are stuck for some reason, jobs keeps running until the timeout.
This wastes resources uselessly.
By setting timeout-minutes properly, you can notice the issue and resolve it by retrying jobs quickly.

https://exercism.org/docs/building/github/gha-best-practices#h-set-timeouts-for-workflows

Linters to enforce timeout-minutes

There are linters to enforce timeout-minutes.

  1. ghalint is a GitHub Actions linter
  2. lintnet is a general purpose linter powered by Jsonnet

ghalint

From ghalint v0.2.12, ghalint enforces timeout-minutes.

https://github.com/suzuki-shunsuke/ghalint/blob/main/docs/policies/012.md

lintnet

ghalint is ported to lintnet as a module.

https://github.com/lintnet-modules/ghalint

So you can enforce timeout-minutes using the module.

https://github.com/lintnet-modules/ghalint/tree/main/workflow/job_timeout_minutes_is_required

A command line tool to set timeout-minutes to all GitHub Actions jobs

It is very bothersome to set timeout-minutes to a lot of jobs by hand.
But you can do it easily using a command line tool ghatm.
It finds GitHub Actions workflows and adds timeout-minutes to jobs which don't have the setting.
It edits workflow files while keeping YAML comments, indents, empty lines, and so on.

For details, please see https://github.com/suzuki-shunsuke/ghatm .

Set timeout-minutes to your all repositories

ghatm is useful, but it is very bothersome to run ghatm and create and merge pull requests to a lot of repositories by hand.
But you can do it easily using ghatm and multi-gitter.

  1. Create pull requests by multi-gitter run
multi-gitter run ./ghatm-set.sh \
    --config config.yaml \
    -O "$org" \
    -t "ci: set timeout-minutes using ghatm" \
    --skip-forks \
    -b "$body" \
    -B ci-set-timeout-minutes-by-ghatm

ghatm-set.sh

ghatm set

config.yaml

git-type: cmd # Use git to sign commits
  1. Merge pull requests by multi-gitter merge
multi-gitter merge \
    -O "$org" \
    -B ci-set-timeout-minutes-by-ghatm \
    --skip-forks


This content originally appeared on DEV Community and was authored by Shunsuke Suzuki


Print Share Comment Cite Upload Translate Updates
APA

Shunsuke Suzuki | Sciencx (2024-07-03T02:46:43+00:00) Set GitHub Actions timeout-minutes. Retrieved from https://www.scien.cx/2024/07/03/set-github-actions-timeout-minutes/

MLA
" » Set GitHub Actions timeout-minutes." Shunsuke Suzuki | Sciencx - Wednesday July 3, 2024, https://www.scien.cx/2024/07/03/set-github-actions-timeout-minutes/
HARVARD
Shunsuke Suzuki | Sciencx Wednesday July 3, 2024 » Set GitHub Actions timeout-minutes., viewed ,<https://www.scien.cx/2024/07/03/set-github-actions-timeout-minutes/>
VANCOUVER
Shunsuke Suzuki | Sciencx - » Set GitHub Actions timeout-minutes. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/07/03/set-github-actions-timeout-minutes/
CHICAGO
" » Set GitHub Actions timeout-minutes." Shunsuke Suzuki | Sciencx - Accessed . https://www.scien.cx/2024/07/03/set-github-actions-timeout-minutes/
IEEE
" » Set GitHub Actions timeout-minutes." Shunsuke Suzuki | Sciencx [Online]. Available: https://www.scien.cx/2024/07/03/set-github-actions-timeout-minutes/. [Accessed: ]
rf:citation
» Set GitHub Actions timeout-minutes | Shunsuke Suzuki | Sciencx | https://www.scien.cx/2024/07/03/set-github-actions-timeout-minutes/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.