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

feat(crate): Support releaseTimestamp #31467

Open
wants to merge 25 commits into
base: main
Choose a base branch
from

Conversation

zharinov
Copy link
Collaborator

@zharinov zharinov commented Sep 18, 2024

Changes

Context

Documentation (please check one with an [x])

  • I have updated the documentation, or
  • No documentation update is required

How I've tested my work (please select one)

I have verified these changes via:

  • Code inspection only, or
  • Newly added/modified unit tests, or
  • No unit tests but ran on a real repository, or
  • Both unit tests + ran on a real repository

@zharinov zharinov marked this pull request as ready for review September 18, 2024 20:42
Comment on lines +381 to +387
private static releaseTimestampSchema = z
.object({
version: z.object({
created_at: z.string(),
}),
})
.transform(({ version: { created_at } }) => created_at);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Don't we normally put these in a schema.ts?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, didn't feel like it creating the new file, will do this later

{ registryUrl, packageName }: PostprocessReleaseConfig,
{ version }: Release,
) => `postprocessRelease:${registryUrl}:${packageName}:${version}`,
ttlMinutes: 24 * 60,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are releases immutable on crates.io? If so then we should think about the maximum feasible cache time for this - perhaps a week?

Copy link
Collaborator

Choose a reason for hiding this comment

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

We should also make sure we've considered the scenario where we get a temporary error (including 429) and don't cache that for long

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It could be yanked, and also there is updated_at field, so let's not consider it immutable.

We should also make sure we've considered the scenario where we get a temporary error (including 429) and don't cache that for long

With current cache decorator implementation, it's hard to set the TTL a posteriori. If the error was thrown, we could either not cache it, or we could catch and return the cacheable null (without distinguishing the reason).

Comment on lines +408 to +411
const { body: releaseTimestamp } = await this.http.getJson(
url,
CrateDatasource.releaseTimestampSchema,
);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does this need a try/catch for safety?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think we're okay with standard error handling, which just returns the release object intact

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.

Consider release date on crates.io for minimumReleaseAge
2 participants