Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Git pre-push checks for UI #3072

Merged
merged 6 commits into from
Nov 10, 2016
Merged

Git pre-push checks for UI #3072

merged 6 commits into from
Nov 10, 2016

Conversation

ngotchac
Copy link
Contributor

@ngotchac ngotchac commented Nov 1, 2016

This would address partially #2291

A new script in js/scripts/pre-push that should be copied to .git/hooks.
It runs linting for the js files if the current branch name starts with js or ui, and if npm is installed.
This would prevent this hook to be executed by everybody, but only devs working on the UI.

NB : the linter runs in about 3sec

@ngotchac ngotchac added A0-pleasereview 🤓 Pull request needs code review. F2-build labels Nov 1, 2016

# Check that the branch starts with `ui` or `js`
# and that `npm` is installed
if [[ "$branch" =~ ^(ui|js) ]] && npm --version 1>/dev/null 2>/dev/null;
Copy link
Contributor

@jacogr jacogr Nov 1, 2016

Choose a reason for hiding this comment

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

I'd rather do it on everything, it is fast enough - plus, we are doing more-and-more of the combined PRs especially in the jsapi realm. I like the copy approach, just think it should cover all branches when a developer switches this on.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, agreed. So what about this :

  • On postinstall, copy the git hook pre-push script to the right folder (like that everyone using npm will have it)
  • The script itself only checks if npm is installed, as well as eslint (globally or in the node_modules/bin directory)

@jacogr jacogr added A5-grumble 🔥 Pull request has minor issues that must be addressed before merging. and removed A0-pleasereview 🤓 Pull request needs code review. F2-build labels Nov 1, 2016
@ngotchac ngotchac added A0-pleasereview 🤓 Pull request needs code review. and removed A5-grumble 🔥 Pull request has minor issues that must be addressed before merging. labels Nov 2, 2016
@jacogr jacogr added A8-looksgood 🦄 Pull request is reviewed well. A0-pleasereview 🤓 Pull request needs code review. and removed A0-pleasereview 🤓 Pull request needs code review. A8-looksgood 🦄 Pull request is reviewed well. labels Nov 2, 2016
"test": "mocha 'src/**/*.spec.js'",
"test:coverage": "istanbul cover _mocha -- 'src/**/*.spec.js'",
"test:e2e": "mocha 'src/**/*.e2e.js'"
"test:e2e": "mocha 'src/**/*.e2e.js'",
"postinstall": "cp scripts/pre-push ../.git/hooks/"
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure it's worth pulling in another dev dependency, but there's husky.

@@ -0,0 +1,15 @@
#!/bin/bash

base_dir=$(git rev-parse --show-toplevel)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not use npm prefix here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess this would be invalidated anyway with husky

@jacogr jacogr added A1-onice 🌨 Pull request is reviewed well, but should not yet be merged. and removed A0-pleasereview 🤓 Pull request needs code review. labels Nov 2, 2016
@jacogr
Copy link
Contributor

jacogr commented Nov 2, 2016

Looks good. Marked it onice since fist want a proper test (after release) when GitLab is up and running again. Don't want fireworks. So as it stands, looks good, just want to make sure we run all the checks and is prepared for it. (Specifically since we commit from CI)

In short - once GitLab is humming again, can merge, test & firefight if need-be.

@ngotchac
Copy link
Contributor Author

ngotchac commented Nov 2, 2016

Seems fair. Note that with husky, it shouldn't run the hooks on CI

@gavofyork
Copy link
Contributor

Here's a UI screenshot
image

@gavofyork
Copy link
Contributor

And another
image

@gavofyork
Copy link
Contributor

and another
image

@gavofyork
Copy link
Contributor

and another
image

@gavofyork
Copy link
Contributor

image

@gavofyork gavofyork added M1-ci 🙉 Continuous integration. A8-looksgood 🦄 Pull request is reviewed well. and removed M6-ui A1-onice 🌨 Pull request is reviewed well, but should not yet be merged. labels Nov 9, 2016
@gavofyork
Copy link
Contributor

gitlab seems to be working again

@jacogr
Copy link
Contributor

jacogr commented Nov 9, 2016

Thanks will get this one in the morning. (Want to make sure we are there to watch - just in-case)

@jacogr jacogr merged commit 1deeb0d into master Nov 10, 2016
@ngotchac ngotchac deleted the ui-ng-pre-push-checks branch November 10, 2016 11:28
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A8-looksgood 🦄 Pull request is reviewed well. M1-ci 🙉 Continuous integration.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants