À propos
Set timeout-minutes to all GitHub Actions jobs
Outils de développementProgression mesurée des étoiles
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- 0
- in 1 month
- Historique en cours
Variations nettes sur des périodes qui se chevauchent, pas des totaux quotidiens. Les mesures absentes restent vides. Les étoiles indiquent l’intérêt, pas la qualité.
README.md
Originalghatm
ghatm is a command line tool setting timeout-minutes to all GitHub Actions jobs.
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.
$ ghatm set
diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml
index e8c6ae7..aba3b2d 100644
--- a/.github/workflows/test.yaml
+++ b/.github/workflows/test.yaml
@@ -6,6 +6,7 @@ on: pull_request
jobs:
path-filter:
# Get changed files to filter jobs
+ timeout-minutes: 30
outputs:
update-aqua-checksums: ${{steps.changes.outputs.update-aqua-checksums}}
renovate-config-validator: ${{steps.changes.outputs.renovate-config-validator}}
@@ -71,6 +72,7 @@ jobs:
contents: read
build:
+ timeout-minutes: 30
runs-on: ubuntu-latest
permissions: {}
steps:
Motivation
- https://exercism.org/docs/building/github/gha-best-practices#h-set-timeouts-for-workflows
- job_timeout_minutes_is_required | suzuki-shunsuke/ghalint
- job_timeout_minutes_is_required | lintnet-modules/ghalint
timeout-minutes should be set properly, but it's so bothersome to fix a lot of workflow files by hand.
ghatm fixes them automatically.
How to install
ghatm is a single binary written in Go.
So you only need to put the executable binary into $PATH.
brew install suzuki-shunsuke/ghatm/ghatm
scoop bucket add suzuki-shunsuke https://github.com/suzuki-shunsuke/scoop-bucket
scoop install ghatm
aqua g -i suzuki-shunsuke/ghatm
- Download a prebuilt binary from GitHub Releases and install it into
$PATH
Verify downloaded assets from GitHub Releases
You can verify downloaded assets using some tools.
- GitHub CLI
- Cosign
- Packslip
ghatm >= v1.0.1 - slsa-verifier
ghatm <= v1.0.0
1. GitHub CLI
You can install GitHub CLI by aqua.
aqua g -i cli/cli
version=v1.0.1
asset=ghatm_darwin_arm64.tar.gz
gh release download -R suzuki-shunsuke/ghatm "$version" -p "$asset"
gh attestation verify "$asset" \
-R suzuki-shunsuke/ghatm \
--signer-workflow suzuki-shunsuke/go-release-workflow/.github/workflows/release.yaml
2. Cosign
You can install Cosign by aqua.
aqua g -i sigstore/cosign
From ghatm v1.0.1, the bundle file is ghatm_<version>_checksums.txt.sigstore.json.
Cosign v2.4.2 or later is required.
version=v1.0.1
checksum_file="ghatm_${version#v}_checksums.txt"
asset=ghatm_darwin_arm64.tar.gz
gh release download "$version" \
-R suzuki-shunsuke/ghatm \
-p "$asset" \
-p "$checksum_file" \
-p "${checksum_file}.sigstore.json"
cosign verify-blob \
"$checksum_file" \
--bundle "${checksum_file}.sigstore.json" \
--certificate-identity-regexp 'https://github\.com/suzuki-shunsuke/go-release-workflow/\.github/workflows/release\.yaml@.*' \
--certificate-oidc-issuer "https://token.actions.githubusercontent.com"
cat "$checksum_file" | sha256sum -c --ignore-missing -
For ghatm v1.0.0 or older, *.pem and *.sig are available instead.
version=v1.0.0
checksum_file="ghatm_${version#v}_checksums.txt"
asset=ghatm_darwin_arm64.tar.gz
gh release download "$version" \
-R suzuki-shunsuke/ghatm \
-p "$asset" \
-p "$checksum_file" \
-p "${checksum_file}.pem" \
-p "${checksum_file}.sig"
cosign verify-blob \
--signature "${checksum_file}.sig" \
--certificate "${checksum_file}.pem" \
--certificate-identity-regexp 'https://github\.com/suzuki-shunsuke/go-release-workflow/\.github/workflows/release\.yaml@.*' \
--certificate-oidc-issuer "https://token.actions.githubusercontent.com" \
"$checksum_file"
cat "$checksum_file" | sha256sum -c --ignore-missing -
3. Packslip
ghatm >= v1.0.1
You can install packslip by aqua.
aqua g -i jdx/packslip
version=v1.0.1
asset=ghatm_darwin_arm64.tar.gz
gh release download -R suzuki-shunsuke/ghatm "$version" -p "$asset" -p packslip.sigstore.json
packslip verify packslip.sigstore.json \
--pin ps1_u3uzfz3n2bowmhmt65tddssvri \
--identity-prefix https://github.com/suzuki-shunsuke/go-release-workflow/.github/workflows/release.yaml@ \
--artifact "$asset"
--pinrequires the release to be signed from the repositorysuzuki-shunsuke/ghatm, identified by its repository ID rather than its name--identity-prefixrequires the release to be signed by the release workflow of suzuki-shunsuke/go-release-workflow
On success, packslip prints a line starting with ok:.
Please make sure it shows the project and version you meant, e.g. github.com/suzuki-shunsuke/ghatm 1.0.1.
4. slsa-verifier
[!WARNING] As of ghatm v1.0.1,
multiple.intoto.jsonlhasn't been published anymore.
You can install slsa-verifier by aqua.
aqua g -i slsa-framework/slsa-verifier
version=v1.0.0
asset=ghatm_darwin_arm64.tar.gz
gh release download -R suzuki-shunsuke/ghatm "$version" -p "$asset" -p multiple.intoto.jsonl
slsa-verifier verify-artifact "$asset" \
--provenance-path multiple.intoto.jsonl \
--source-uri github.com/suzuki-shunsuke/ghatm \
--source-tag "$version"
- Go
go install github.com/suzuki-shunsuke/ghatm/cmd/ghatm@latest
How to use
Please run ghatm set on the repository root directory.
ghatm set
Then ghatm checks GitHub Actions workflows ^\.github/workflows/.*\.ya?ml$ and sets timeout-minutes: 30 to jobs not having timeout-minutes.
Jobs with timeout-minutes aren't changed.
You can specify the value of timeout-minutes with -t option.
ghatm set -t 60
You can specify workflow files by positional arguments.
ghatm set .github/workflows/test.yaml
Decide timeout-minutes based on each job's past execution times
ghatm set -auto [-repo <repository>] [-size <the number of sample data>]
[!warning] The feature doesn't support workflows using
workflow_call.
If the -auto option is used, ghatm calls GitHub API to get each job's past execution times and decide appropriate timeout-minutes.
This feature requires a GitHub access token with the actions:read permission.
You have to set the access token to the environment variable GITHUB_TOKEN or GHATM_GITHUB_TOKEN.
GitHub API:
ghatm takes 30 jobs by job to decide timeout-minutes.
You can change the number of jobs by the -size option.
max(job execution times) + 10
Tips: Fix workflows by CI
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
Explorer des projets similaires
Chargement…