-
Notifications
You must be signed in to change notification settings - Fork 21
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
Image sizing ci #331
base: master
Are you sure you want to change the base?
Image sizing ci #331
Conversation
@nicolasjeong is this PR ready to review? I'm not sure if we've hit all the requested items in the ticket yet! |
Oh my bad, I thought I had to submit a PR after resolving some of the comments from checkImageSize.js before moving on to fixImageSize.js. (Unless I missed something in checkImageSize.js) |
Sure, in that case I can give a light review, but we shouldn't merge this until we also make a working |
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.
Left some comments! Also cc: @vivianha534
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.
I'm going to defer to @mattxwang because I'm not very familiar with CI, but I left a couple of comments. Adding whether or not a file is fixable, is more of a nit.
test/checkImageSize.js
Outdated
for (const file of finalFilesArray){ //Check the image size of all image files | ||
const imageStatus = imageSizeChecker(file); | ||
if (imageStatus.error){ | ||
console.error("Error: " + file + " -- " + imageStatus.message+ "\n"); |
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.
It would be nice to also let the person know if their error is fixable, so that way they know if they need to manually fix the issue or if they can run fixImageSize to fix it.
test/checkImageSize.js
Outdated
else if(isImageWidthLarge(imageSize)){ | ||
return errorType.LARGE_IMAGE_ERROR; | ||
} | ||
else if (!isAValidExtension(input)){ |
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 if statement would also fail if the file had a non .jpg, .jpeg, or .png extension (ie. it would fail if they had a .svg file) However, the error message for EXTENSION_ERROR only mentions file name not having a lower case extension name.
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.
The getAllFiles() function(line 86) deals with this since it returns an array of the file names that have .jpg, jpeg, or .png. Therefore, the array won't contain any file that has a non .jpg, .jpeg, or .png extension. We will run imageSizeChecker to files that only have the .jpg, .jpeg, or .png extension.
@reginawang99 @ellieyhcheng I'm not sure why the export/require statements are causing everything in checkImageSize.js to run instead of just the getAllFiles function. |
Kk I can take a look tonight |
Oh I can jump in here if that makes things easier, basically the entire file is being executed on interpretation (afaik how importing works with ESM/node, but I could be wrong) I would suggest instead to separate concerns:
Ideally, any file you import shouldn't have any deterministic or side-effect behaviour! |
@mattxwang Oh ok, so if I'm understanding this correctly, if we had functions that we wanted to use in both checkImageSize.js and fixImageSize.js then we should define the function inside of another file like library.js or something and export the functions in there, and require library.js in checkImageSize.js and fixImageSize.js in order to use the exported functions? |
Yup! I would also say that this is generally best practice! I would put all relevant library files in your Also, since we're not supporting Node 10, ESM imports/exports are probably the way to go. |
…ant functions to checkImageSize.js and fixImageSize.js, and finished fixImageSize.js
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.
Left some comments! Most of them are nitpicky, though the behaviour around failing fixes is pretty important (I think try-catch and log is probably fine in this instance).
Also, a minor nit is that we're using let
very frequently when const
would suffice, which helps with "defensive coding"!
I think if you address these comments, we're prob good to go. After you make the changes (tag me again, but I think this is good), you should:
- merge
master
intoimage-sizing-ci
- then, run the fixer
- ideally, commit that night
Co-authored-by: Matt Wang <matt@matthewwang.me>
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.
Feel free to pull the trigger on merging + autofixing!
It seems that one of the check still fails? I'm pretty sure it's because of the non-fixable images that have errors. |
Just touching back to this, @reginawang99 / @vivianha534 are y'all wrapping up this ticket? Or do you want me to finish it? |
@vivianha534 i think we can just fix that one fixable image, and just push? and we manually fix/ask people with pictures that are too small for updated pics? (we can probably manually fix the non-square aspect ratios) |
@mattxwang @reginawang99 Oh I was planning on manually fixing all of the images before having Nico merge it. I've already been working on fixing the images, and the last couple should be done by tonight/tomorrow latest. |
Just curious, what ended up happening with this PR? @vivianha534 @reginawang3495 |
No description provided.