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

[Merged by Bors] - fix(scripts): make lint-style.* work on macos and windows #6047

Closed
wants to merge 6 commits into from

Conversation

Julian
Copy link
Collaborator

@Julian Julian commented Feb 4, 2021

Make lint-style.sh use a POSIX-portable way of checking for executable bits, and make it always open files as UTF-8.

Also makes CI run the sanity checks across all 3 OSes to ensure this stays working.

@bryangingechen bryangingechen added awaiting-review The author would like community review of the PR CI This issue or PR is about continuous integration labels Feb 4, 2021
Running it exits with successful return code.
"""

subprocess.run(["./scripts/lint-style.sh"], check=True, cwd=ROOT_DIR)
Copy link
Collaborator

Choose a reason for hiding this comment

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

If a commit has a style linting error, will this test also fail?

Copy link
Collaborator Author

@Julian Julian Feb 5, 2021

Choose a reason for hiding this comment

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

Good catch. Yes, but I put in a way to make that not happen now. (One which involves running the linter yet another time, but without this I think it'd be hard to know that wasn't the case -- the shell script uses xargs, so you can't say check a particular return code because xargs changes the return code).

Copy link
Collaborator

Choose a reason for hiding this comment

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

If someone accidentally commits a .lean file with the executable bit set, this test will still fail, right?

Would it be better to create a temporary mostly-empty skeleton directory to run the test scripts in?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ech yes I suppose so.

Would it be better to create a temporary mostly-empty skeleton directory to run the test scripts in?

I guess, though it seems also potentially fragile since the script depends on arbitrary other files in the checkout (e.g. it blows up currently if style-exceptions.txt isn't present, and also depends on src/tactics/reserved_notation.lean...). Will give it a shot I suppose.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks again! I'm fully open to other suggestions, by the way. The main concern I have here is the experience for the typical user who doesn't want to think about the style linter unless it fails in GitHub Actions, so ideally the self-tests should never fail if someone doesn't touch the linting script in their commit.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah of course! I agree random folks will be confused if they see this test fail.

The other thing that occurred to me is possibly running this self-test against the src and archive directories from master, no matter what branch is running (but still use that branch's scripts directory). I'm letting it "steep" in my head to see which thing makes me feel least icky.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Actually I guess it occurs to me that GH Actions I believe supports some syntax for saying when to run a particular job, so perhaps yet another way would be only running the self-test at all when the scripts directory has changes.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Actually I guess it occurs to me that GH Actions I believe supports some syntax for saying when to run a particular job, so perhaps yet another way would be only running the self-test at all when the scripts directory has changes.

Right, this could work as well, though I think you would have a "run-always" preliminary step that checks for changes in scripts/, since from what I remember GHA doesn't have anything built-in that can tell you that.

However, one of the key issues here seems to be how to deal with all the assumptions the script makes about the directory / file structure of mathlib. I think it's probably better to make them explicit in Python in a test somehow rather than in the GHA workflow.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

OK went with running the script in a separate tree entirely...

Not too painful. Small chance of false negatives due to not having a "real" enough directory tree but maybe it's the best option. Let me know what you think.

Copy link
Collaborator

@bryangingechen bryangingechen left a comment

Choose a reason for hiding this comment

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

Looks great, thanks once again!
bors r+

@github-actions github-actions bot added ready-to-merge All that is left is for bors to build and merge this PR. (Remember you need to say `bors r+`.) and removed awaiting-review The author would like community review of the PR labels Feb 7, 2021
bors bot pushed a commit that referenced this pull request Feb 7, 2021
Make lint-style.sh use a POSIX-portable way of checking for executable bits, and make it always open files as UTF-8.

Also makes CI run the sanity checks across all 3 OSes to ensure this stays working.
@bors
Copy link

bors bot commented Feb 7, 2021

Pull request successfully merged into master.

Build succeeded:

@bors bors bot changed the title fix(scripts): make lint-style.* work on macos and windows [Merged by Bors] - fix(scripts): make lint-style.* work on macos and windows Feb 7, 2021
@bors bors bot closed this Feb 7, 2021
@bors bors bot deleted the linter-take-three branch February 7, 2021 21:12
b-mehta pushed a commit that referenced this pull request Apr 2, 2021
Make lint-style.sh use a POSIX-portable way of checking for executable bits, and make it always open files as UTF-8.

Also makes CI run the sanity checks across all 3 OSes to ensure this stays working.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI This issue or PR is about continuous integration ready-to-merge All that is left is for bors to build and merge this PR. (Remember you need to say `bors r+`.)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants