diff --git a/.github/workflows/description-check.yml b/.github/workflows/description-check.yml new file mode 100644 index 00000000..53e6df85 --- /dev/null +++ b/.github/workflows/description-check.yml @@ -0,0 +1,21 @@ +name: description check +on: + pull_request: +permissions: + contents: read + pull-requests: write + id-token: write + checks: write +jobs: + verify: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + with: + fetch-depth: 0 + ref: ${{ github.event.pull_request.head.sha }} + - uses: lemahq/lema-verify@v1 + with: + api-url: https://lema-api-4wojvodvaq-uc.a.run.app # STAGE — not api.lema.sh + github-token: ${{ github.token }} + record-decisions: true diff --git a/retry/retry.go b/retry/retry.go new file mode 100644 index 00000000..570283cd --- /dev/null +++ b/retry/retry.go @@ -0,0 +1,22 @@ +// Package retry retries an operation with exponential backoff. +package retry + +import "time" + +// Do runs fn up to attempts times. After each failure it waits, doubling the +// delay each round (exponential backoff), and returns the final error if every +// attempt fails. +func Do(attempts int, base time.Duration, fn func() error) error { + delay := base + var err error + for i := 0; i < attempts; i++ { + if err = fn(); err == nil { + return nil + } + if i < attempts-1 { + time.Sleep(delay) + delay *= 2 + } + } + return err +}