Skip to content

Comments

Reenable lint check in PR workflow and fix lint errors#1007

Merged
anth-volk merged 4 commits intoPolicyEngine:masterfrom
abhcs:fix-issue-1006
Dec 22, 2023
Merged

Reenable lint check in PR workflow and fix lint errors#1007
anth-volk merged 4 commits intoPolicyEngine:masterfrom
abhcs:fix-issue-1006

Conversation

@abhcs
Copy link
Collaborator

@abhcs abhcs commented Dec 22, 2023

Description

Fix #1006 by using the right flags for lint. The lint action prettier -c was used to check for errors but in #902 was changed to prettier -w which does not do anything in the context of the PR workflow. We switch back to using -c again, and use fix instead of lint in the Makefile.

@abhcs
Copy link
Collaborator Author

abhcs commented Dec 22, 2023

See the error in the action for the above commit. Lint errors are now detected correctly.

@abhcs
Copy link
Collaborator Author

abhcs commented Dec 22, 2023

See the action details for the above commit:

Checking formatting...
All matched files use Prettier code style!

@anth-volk
Copy link
Collaborator

The reason we had originally changed prettier -c to prettier --write, though, was that numerous users would fail the test run and have to either manually sift through prettier's checks and fix stuff or know to run prettier --write - considering that we have quite a few contributors who are new to development, I don't know that that's the most intuitive workflow.

What if we split the difference by creating two make rules:

  • make format_check could be run by the GitHub Action and consist of the call to black and prettier -c
  • make format could be required of the user and run black and prettier --write

These could also be named differently

@abhcs
Copy link
Collaborator Author

abhcs commented Dec 22, 2023

I have not changed what make format does. It still writes. Please check again.

@anth-volk anth-volk self-requested a review December 22, 2023 20:20
Copy link
Collaborator

Choose a reason for hiding this comment

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

Apologies, I gave too cursory a read to your initial comments. Even so, could you change the format rule to something like make format-check and run your edited npm run lint there? This would ensure that the actions only check the formatting, not update it. Separately, I think it'd be best to have a make format that runs your new npm run fix that a user would run prior to opening a PR.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Since the linting issue we're having is that the actions lint prior to deploying, but don't actually alter the files as they sit in the repo

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 am not sure I understand which issue make format-check fixes -- which workflow uses this command?

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 am guessing that it is meant as an aid to new users?

Copy link
Collaborator

Choose a reason for hiding this comment

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

On your first comment, I would envision the PR Action also being updated to use make format-check instead of make format, if you'd be willing to change it.

On the second, it's meant to do three things: be an aid, ensure that users can run both prettier and black in one action, and ensure that users can run prettier --write without the workflow running it, since the workflow's changes don't appear to affect the live repo, only the deployed app.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Users can run prettier --write and black in one action right now in make format unless I am missing something. That's what npm run fix does. I am happy to make any changes but I do wish to understand the logic so that I don't mess up.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If I understand the workflows right now, prettier --write will only occur when the user explicitly says so locally. There is no automated prettier --write before deploy if my cursory reading of push.yml is correct.

Copy link
Collaborator

Choose a reason for hiding this comment

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

You know what, you're right, I introduced way too much confusion to this. I was thinking of the action that occurs on the API side, where we actually do explicitly run make format, and I had confused that with the call to npm run lint in the app's workflow. You're totally right, as it's written right now, this would all work. Sorry about the confusion.

Copy link
Collaborator

Choose a reason for hiding this comment

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

You know what, you're right, I introduced way too much confusion to this. I was thinking of the action that occurs on the API side, where we actually do explicitly run make format, and I had confused that with the call to npm run lint in the app's workflow. You're totally right, as it's written right now, this would all work. Sorry about the confusion.

@anth-volk
Copy link
Collaborator

Thanks for your contributions on this, @abhcs, and thanks for catching my mistake on the workflows

@anth-volk anth-volk merged commit 10fa332 into PolicyEngine:master Dec 22, 2023
@abhcs abhcs deleted the fix-issue-1006 branch December 27, 2023 20:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Reenable lint check in PR workflow and fix lint errors

3 participants