Skip to content
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

Add poll-interval input #99

Merged
merged 1 commit into from
May 29, 2023

Conversation

namoscato
Copy link
Contributor

@namoscato namoscato commented May 27, 2023

Resolves #95

Context

I work with @dlively1 and in addition to #97 retries, we thought it would be helpful to introduce a delay in between each Vercel API request in an effort to stay within their rate limits.

Summary

  • Add poll-interval input, defaulting to 1 second (which will allow for about 8 concurrent executions of this GitHub Action)
  • Add tsconfig.eslint.json, which includes __tests__ directory
  • Set NODE_ENV=test in sandboxed main.test.ts process
  • Pull input defaults into action.yml configuration
  • Introduce millisecondsFromInput utility function
  • Fix retryMaxDuration value

@@ -13,7 +13,7 @@ plugins:
- jest
parser: '@typescript-eslint/parser'
parserOptions:
project: ./tsconfig.json
project: ./tsconfig.eslint.json
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the same as tsconfig.json with the exception of exclude: ['**/*.test.ts'] which fixes this error in test files:

Parsing error: ESLint was configured to run on `<tsconfigRootDir>/__tests__/main.test.ts` using `parserOptions.project`: <tsconfigRootDir>/../github-action-await-vercel/tsconfig.json
However, that TSConfig does not include this file.

(if you ever want to start running ESLint on the entire project)

@@ -2,3 +2,4 @@
coverage/
node_modules/
lib/
README.md
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might make sense to use Prettier to format the entire project, but I didn't want to bloat this diff.

It looks like my editor did remove some trailing spaces (which I'm happy to revert if you want).

action.yml Show resolved Hide resolved
Comment on lines +10 to +13
/** Duration (in milliseconds) to wait for a terminal deployment status */
timeout: number;
/** Duration (in milliseconds) to wait in between polled Vercel API requests */
pollInterval: number;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pulled this into a single object argument with named parameters, mostly to de-risk an ordering bug with passing in multiple number arguments.

src/awaitVercelDeployment.ts Show resolved Hide resolved
@namoscato namoscato marked this pull request as ready for review May 27, 2023 16:34
},
})
.then((data) => data.json())
.catch((error: string) => reject(error))) as VercelDeployment;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given we were awaiting for the promise, this didn't seem necessary. Errors thrown inside of executor function will inherently reject the promise.

headers: {
Authorization: `Bearer ${process.env.VERCEL_TOKEN}`,
},
retryOptions: {
retryMaxDuration: timeout * 1000, // Convert seconds to milliseconds
Copy link
Contributor Author

@namoscato namoscato May 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

timeout was actually already converted to milliseconds, so this would have been much too large. I actually helped review #97 but didn't catch this on my first pass 😓

The updated value adjusts for the remaining timeout duration in milliseconds.

Copy link
Member

@Vadorequest Vadorequest left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Vadorequest Vadorequest changed the base branch from main to add-poll-interval May 29, 2023 06:11
@Vadorequest Vadorequest merged commit 5a8e291 into UnlyEd:add-poll-interval May 29, 2023
@Vadorequest
Copy link
Member

Tested on #100

Vadorequest added a commit that referenced this pull request May 29, 2023
Co-authored-by: Nick Amoscato <nick@amoscato.com>
@Vadorequest
Copy link
Member

Vadorequest commented May 29, 2023

@namoscato Your PR has been merged with main and released. Thank you!

@namoscato namoscato deleted the add-poll-interval branch May 30, 2023 01:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Vercel timeout
2 participants