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 SiteTests #438

Conversation

erikbasargin
Copy link
Contributor

This PR addresses the "PublishingContext.default accessed before being initialized. Call PublishingContext.initialize() first. error when Markdown content contains invalid lastModified.

  • Content/parseMetadataDate is updated to set error on the provided context rather than shared instance of PublishingContext

@JPToroDev
Copy link
Collaborator

Please see my note about parseMetadataDate()—those changes should be undone—otherwise this looks excellent!

@erikbasargin
Copy link
Contributor Author

Hey @JPToroDev, are you referring to the description of the parseMetadataDate function? I’m a bit confused about the changes you want to undo. I see that the description doesn’t quite match up with what’s actually happening, I’m happy to help you update it!

@JPToroDev
Copy link
Collaborator

You've add a context argument to that method that wasn't there before, right?

@erikbasargin
Copy link
Contributor Author

erikbasargin commented Jan 30, 2025

Yep, I replaced PublishingContext.default with context. This is what caused the crash "PublishingContext.default accessed before being initialized.. Covered by the SiteTests/publishingWithInvalidLastModifiedDate test.

@JPToroDev
Copy link
Collaborator

That does solve the problem in that one spots, but parseMetadataDate() is a symptom of a larger issue that #420 addresses.

So we should undo that change and just focus on the tests. Even if they fail at the moment, once #420 is merged in, it'll be resolved naturally.

@erikbasargin
Copy link
Contributor Author

I probably missing something, I can update this PR just to provide SiteTests. However, I want to point out that SiteTests/publishingWithInvalidLastModifiedDate a real life scenario, I mean ignite build failed for me yesterday when I tried to build a website.

#420 seems only covers IgniteTesting.

ignite build
⚙️  Building your site...

Building for debugging...
[0/3] Write swift-version--58304C5D6DBC2206.txt
Build of product 'MyBlog' complete! (0.11s)
Ignite/PublishingContext.swift:22: Fatal error: "PublishingContext.default accessed before being initialized. Call PublishingContext.initialize() first.

@erikbasargin erikbasargin force-pushed the fix-site-publish-when-content-with-invalid-lastModified branch from 64505e2 to 14c408c Compare January 30, 2025 19:39
@JPToroDev
Copy link
Collaborator

JPToroDev commented Jan 30, 2025

I see, thank you for clarifying. Could you open up a separate issue/PR outlining the Ignite build failure you experienced yesterday that's separate from testing—and your proposed solution?

@erikbasargin
Copy link
Contributor Author

I rebased my tests on top of your changes #420 (https://github.com/erikbasargin/Ignite/tree/012825a), and you're absolutely right that tests are fixed. However, ignite build still fails when lastModified date has invalid format in Markdown files. I'll check how I can update my tests so they would still cover the issue in parseMetadataDate function including #420 changes.

Do you want to merge current SiteTests? I can raise another PR a bit later today with proposed solution.

@erikbasargin erikbasargin changed the title Fix metadata parser Add SiteTests Jan 30, 2025
@erikbasargin erikbasargin force-pushed the fix-site-publish-when-content-with-invalid-lastModified branch from 14c408c to d123cfa Compare January 30, 2025 20:23
@JPToroDev
Copy link
Collaborator

When the build fails, do you get an error like "Content should have a date in the format of XYZ", or the publishing context nil error?

@erikbasargin
Copy link
Contributor Author

This is the output that I see for ignite build

ignite build
⚙️  Building your site...

[0/1] Planning build
Building for debugging...
[0/3] Write swift-version--58304C5D6DBC2206.txt
Build of product 'MyBlog' complete! (0.18s)
Ignite/PublishingContext.swift:22: Fatal error: "PublishingContext.default accessed before being initialized. Call PublishingContext.initialize() first.


❌ Failed to generate HTML.

@JPToroDev
Copy link
Collaborator

JPToroDev commented Jan 30, 2025

Perfect—thank you. Include this all in your new PR, along with your proposed solution using the revamped parseMetadataDate()—which we'll need to ensure addresses the real bug and not just a symptom of it, because this doesn't seem to be an issue when building from Xcode—and we'll get this resolved shortly.

@JPToroDev JPToroDev merged commit 88ce42f into twostraws:main Jan 30, 2025
1 check passed
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.

2 participants