-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make merge gatekeeper more resilient #67
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,7 @@ At UPSIDER, we have a few internal repositories set up with a monorepo structure | |
|
||
We are looking to add a few more features, such as extra signoff from non-coder, label based check, etc. | ||
|
||
<sup><sub>NOTE: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you take out the blank spaces here, it would change the line break layout slightly. While it seems to read just fine with this change, I'd like to check if this was an intentional update? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. my ide removed it |
||
<sup><sub>NOTE: | ||
<sup>(\*1)</sup> There are some other hacks, such as using an empty job with the same name to override the status, but those solutions do not provide the flexible control we are after.</sub></sup> | ||
|
||
<!-- == imptr: background / end == --> | ||
|
@@ -85,6 +85,7 @@ There are some customisation available for Merge Gatekeeper. | |
| `token` | `GITHUB_TOKEN` or Personal Access Token with `repo` scope | Yes | | ||
| `self` | The name of Merge Gatekeeper job, and defaults to `merge-gatekeeper`. This is used to check other job status, and do not check Merge Gatekeeper itself. If you updated the GitHub Action job name from `merge-gatekeeper` to something else, you would need to specify the new name with this value. | | | ||
| `interval` | Check interval to recheck the job status. Default is set to 5 (sec). | | | ||
| `github-client-retry` | Retry the request if the GitHub client returns 5xx error. Default is set to 0. | | | ||
| `timeout` | Timeout setup to give up further check. Default is set to 600 (sec). | | | ||
| `ignored` | Jobs to ignore regardless of their statuses. Defined as a comma-separated list. | | | ||
| `ref` | Git ref to check out. This falls back to the HEAD for given PR, but can be set to any ref. | | | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package github | ||
|
||
import ( | ||
"log" | ||
"math" | ||
"net/http" | ||
"time" | ||
) | ||
|
||
type RetryTransport struct { | ||
next http.RoundTripper | ||
Retries int | ||
log log.Logger | ||
} | ||
|
||
func NewRetryTransport(retry int) *RetryTransport { | ||
return &RetryTransport{ | ||
next: http.DefaultTransport, | ||
Retries: retry, | ||
} | ||
} | ||
|
||
func (t *RetryTransport) RoundTrip(req *http.Request) (*http.Response, error) { | ||
var ( | ||
resp *http.Response | ||
err error | ||
) | ||
|
||
for i := 0; i <= t.Retries; i++ { | ||
resp, err = t.next.RoundTrip(req) | ||
if err != nil { | ||
return resp, err | ||
} | ||
|
||
if resp.StatusCode >= 500 && resp.StatusCode < 600 { | ||
log.Printf("Retrying request due to status code: %d\n", resp.StatusCode) | ||
delay := time.Duration(math.Pow(2, float64(i))) * time.Second | ||
time.Sleep(delay) | ||
|
||
resp.Body.Close() | ||
continue | ||
} | ||
|
||
break | ||
} | ||
|
||
return resp, err | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is something very peculiar to our setup, but we are using Importer https://github.com/upsidr/importer for our documentation. This means we are only pulling in pieces of documentation from
docs
directory.You can see some markdown comments such as
<!-- == imptr: inputs / begin from: ./docs/action-usage.md#[inputs] == -->
It means it's checking the file
./docs/action-usage.md
and a markerinputs
, and when you runimporter update README.md
, it would replace the documentation with that given content. This is our own way of ensuring documentation does not get drifted between places, and that's the reason why the CI is failing. If you could make sure to update the./docs
directory content as well asREADME.md
, that would be appreciated! 🥰There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addressed