Skip to content

Setup hlint to run in the project#3816

Merged
natefaubion merged 3 commits intopurescript:masterfrom
joneshf:joneshf/setup-hlint
May 4, 2020
Merged

Setup hlint to run in the project#3816
natefaubion merged 3 commits intopurescript:masterfrom
joneshf:joneshf/setup-hlint

Conversation

@joneshf
Copy link
Copy Markdown
Member

@joneshf joneshf commented Mar 16, 2020

As the first step in cleaning up language extensions, we're setting up hlint. Assuming this approach works, we'll then use hlint to restrict which language extensions can be used.

joneshf added 3 commits March 16, 2020 04:34
There have been a smattering of efforts to run `hlint` on the project:
* 1b77d7e
* afd4605
* 5860f1e
* b120af7
* a647c78
* f806a6f
* 20f1200
* 0b07beb

The last explicit `hlint` inspiried cleanup was three and a half years
ago. Over that time, we've accumulated almost 400 hints from `hlint`.
It's unclear if these are all new or if they've been around for a while
and the previous efforts only addressed some of the issues.

To mitigate the number of new hints, we setup `hlint` properly in the
project. Given that there are too many hints to attempt to take on all
at once, we ignore all of the current hints with a `.hlint.yaml` file
provided by the `--default` flag. We can triage the hints that we think
are useful, and ignore the ones we don't find useful.

The motivation behind doing this change now is that we want to be more
consistent with the language extensions in use:
purescript#3805. Since `hlint` can
enforce the use of language extensions:
https://github.com/ndmitchell/hlint/tree/9f1e23655c4fac537446a2600dd2f5d89825406c#restricting-items,
it seemed like an alright approach to solving this problem:
purescript#3805 (comment).

We'll move on to cleaning up language extensions after we've decided
what to do about this approach.
Turns out `make` doesn't exist on the Windows environment of TravisCI.
It has `cmake` instead. Also, the macOS environment of TravisCI doesn't
have the same version of `mktemp` or `rm` that exists on the Linux
environment. It is probably using the BSD versions of those while we
expected the GNU versions.

We write things more agnostic by taking in the build and bin
directories. This way, we can call the script with arguments instead of
expecting it to know more information than it should. It was dubious of
us to assume the path to `bin` would always work anyway.

To address the Windows issue, we call the script directly to install
`hlint` and run `hlint` manually once it's installed. This isn't ideal
because it means that we have two workflows: one using `make` the other
orchestrating things by hand. Hopefully, we can address these issues
better in the future.
Looks like each line in this YAML string is run as its own shell
process. So maybe the variables aren't available directly to the script?
It's unclear why this didn't work but a few lines above we had `URL`
available in the environment.

In any case, we try putting it all on one line so it should hopefully be
part of the environment the script has available.
Copy link
Copy Markdown
Member Author

@joneshf joneshf left a comment

Choose a reason for hiding this comment

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

Requesting a review from @hdgarrood as he tends to do most TravisCI stuff. But anybody should feel free to review. Also, feel free to re-assign.

export CI_RELEASE=true
fi
script:
- hlint --git
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I was unsure how to reconcile this step with the timeout stuff happening below. Should this be part of the same timeout? Should this be in its own timeout? Should the ci/build.sh script call out to this?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think having the ci/build.sh script call out to hlint would be my preference. I suspect it doesn't really matter whether it's included in the timeout or not, because I don't suspect running hlint takes very long, but I think it's preferable to only have to look in one place to see what each CI job is actually checking.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What does the --git flag do? I haven't managed to find documentation for it.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Sounds good.

--git finds only the tracked files and lints them.

@joneshf joneshf marked this pull request as ready for review March 16, 2020 14:37
@joneshf joneshf requested a review from hdgarrood March 16, 2020 14:37
BIN_DIR=$(bin_dir) BUILD_DIR=$(build_dir) $<
touch $@

clean: ## Remove build artifacts
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this intended to cover all of the places that a build creates files? I know there are many others, most of which I had to clean while switching the polykinds PR on and off: .test_modules, **/.stack-work, tests/support/node_modules, tests/support/bower_components, etc. A git clean -fdX takes care of all of this; what value is make clean intended to add?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Is this intended to cover all of the places that a build creates files?

Yes, ideally.

A git clean -fdX takes care of all of this; what value is make clean intended to add?

The whole purpose of a build system (make or otherwise) is to not have to remember a bunch of different switches and flags and the order in which to call them for day-to-day tasks.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

In that case, all I'm trying to say is that I think you're missing a bunch of paths. Here's the output of git clean -ndX on a recent build for me:

Would remove .psci_modules/
Would remove .stack-work/
Would remove .test_modules/
Would remove lib/purescript-ast/.stack-work/
Would remove lib/purescript-ast/purescript-ast.cabal
Would remove lib/purescript-cst/.stack-work/
Would remove lib/purescript-cst/purescript-cst.cabal
Would remove purescript.cabal
Would remove tests/purs/docs/output/
Would remove tests/purs/make/
Would remove tests/purs/publish/basic-example/output/
Would remove tests/support/bower_components/
Would remove tests/support/node_modules/
Would remove tests/support/package-lock.json
Would remove tests/support/pscide/output/

I haven't done a checkout of this PR to test, though, so maybe some/all of these have been moved into .build? I don't know. Just trying to make sure make clean works as intended.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Right, it sounds like adding a clean target in the Makefile whose implementation is git clean -fdX is probably the way to go here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Sorry, I wasn't intending to have this rule fix all of the problems with the current build system. I only meant to clean up the new artifacts introduced with this PR.

Given that this is generating enough discussion by itself, and the build system hasn't been cleaning up after itself up until this point, I'm going to split this out to its own PR so we can focus on getting the hlint changes reviewed.

Copy link
Copy Markdown
Contributor

@hdgarrood hdgarrood left a comment

Choose a reason for hiding this comment

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

This looks good to me, assuming the clean changes are going to be split out and addressed separately.

@natefaubion natefaubion merged commit 1d78a36 into purescript:master May 4, 2020
@natefaubion
Copy link
Copy Markdown
Contributor

Thanks @joneshf!

@joneshf
Copy link
Copy Markdown
Member Author

joneshf commented May 6, 2020

Sorry, this wasn't quite ready to merge. We hadn't addressed @hdgarrood's suggestion or @rhendric's concern.

To mitigate this situation in the future, how do we better communicate that a PR still has work to do?

@garyb
Copy link
Copy Markdown
Member

garyb commented May 6, 2020

There's a "needs more work" label that is sometimes used, I think that'd do it.

@joneshf
Copy link
Copy Markdown
Member Author

joneshf commented May 6, 2020

Got it. Thanks!

@hdgarrood
Copy link
Copy Markdown
Contributor

I guess if I hadn't approved prematurely it probably wouldn't have happened.

@natefaubion
Copy link
Copy Markdown
Contributor

Sorry, should this be reverted? I merged it because it was approved and sat for several weeks.

@hdgarrood
Copy link
Copy Markdown
Contributor

I don't think it's worth reverting, the unresolved suggestions don't seem that important to me.

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.

5 participants