-
-
Notifications
You must be signed in to change notification settings - Fork 143
Update npm scripts used for building, testing, etc. #299
Conversation
In test driven development, to fix a bug I often first write a test that demonstrates the bug (the test should necessarily fail) and then I write the fix in another commit to demonstrate that the bug was fixed. If tests have to pass before I push, then it breaks this development pattern. However, having
Very nice. Is there any case where
If formatting and linting are in CircleCI, then we shouldn't need to run them before running
Can we also update the package.json with the versions of webpack (and remove the archetype). i.e. update it to match https://github.com/plotly/dash-component-boilerplate?
For tests, see the commands that are in circle: dash-core-components/.circleci/config.yml Lines 49 to 54 in 29d9f1d
pylint in there but it might've gotten removed when @T4rk1n added circle 2 support?
|
Yeah, I'd say let's remove these. I'm not sure how to get twine to upload the latest package, so I always run these manually:
Or perhaps we turn it into a script that substitutes the version number, so we run:
and it does all of those things, subsituting the version number where appropriate |
@chriddyp Yeah fair about test driven development. Running tests locally before every push does take a long time too, so I'll remove that for now. I'm actually not sure about if I like the |
Yeah, I don't think you're missing anything. We should add prettier, eslint, pylint, and flake8 to the circle config. pylint and flake8 used to be in there I believe. |
We only ran pylint on the package eslint tests runs in the npm tests. I'm not really familiar with prettier but I added it and the configs from #274, I believe it checks the prettier rules while running eslint. I think formatting should be done by pre-commit hook or running the command locally. Considering pre-commit hooks, in my experience, they don't work well with IDE, so it needs to be togglable.
I have also removed the old build command in #293.
I also don't use them, I do |
The no-console is in the eslintrc, it didnt catch it because you used |
I would prefer not to introduce Husky into our libraries. It is great for in-house application development where devs can agree on tooling. But in OSS where there isn't that level of control forcing git to automagically run when things happen can be dangerous in certain environments. For example some IDEs configure git hooks already (like my emacs magit IDE) |
@T4rk1n I just used no-console as an example, in that ESLint will catch different errors than Prettier. @bpostlethwaite Ah ok, that's interesting. I can just add a I've also removed the old webpack and babel configs, as well as the archetype from deps, since we've upgraded webpack and are no longer using them. |
I'm not sure what's causing the Percy diffs - I guess formatting the |
I've made some changes. I still think it's a good idea to automatically run the formatter and the linter locally, mostly because having the tests fail on CircleCI because you forgot a semicolon somewhere is a bit of a hassle, and might as well run formatting too while you're at it, so that if newcomers make changes we don't have to comment on their coding style, i.e. that we want 4 spaces instead of 2 for indentation. I'm now running formatting and linting as steps before building, when running I've also updated CircleCI to run formatting and linting before building, which is maybe unnecessary if we're already doing that in |
@bpostlethwaite Could you review as well? Thanks :) |
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.
Great, I think these changes are an improvement. Nice work!
💃
What are the Percy visual diffs about though? |
There are regressions in the percy diff, the checklist seems broken. |
I think the tabs screenshots are a bit finicky, I got that |
@T4rk1n @bpostlethwaite Running the code in the test in a Dash app looks fine to me, I have no idea what's up with those Percy diffs. |
@valentijnnieman I confirm the same, working normally in a dash app. |
Perhaps the changes in #312 will give us some better insights into what's going on here. |
@valentijnnieman Can we change the webpack config like @bpostlethwaite did here plotly/dash-component-boilerplate#14 (comment) ? |
Hi! This is an update for all the npm scripts we're using.
TL;DR
We should automate linting and formatting. Formatting so that we don't have to ask contributors to use 4 spaces instead of 2 for indentation for example, and so that we ensure our code looks nice and clean. We should run linting locally before the build step, so we prevent linting errors happening in CircleCI (which takes more time). I personally want to automate these things, so I don't have to spend time thinking about it.
More detailed:
build-dev
,build-dist
andcopy-lib
scripts that no longer work after updating our webpack config and adds the newbuild:js
andbuild:py
scripts.build:watch
script. This I personally find very handy when making changes to the code, and wanting to test them in an actual Dash app. This watcher just runsbuild:all
when files have changed.the Archetype dependency.
test
script to run our python tests instead of linting (and changes the CircleCI command)lint
commandformat
command that runs PrettierIt updates theprepublish
hook with running formatting first, then linting, then building (formatting and linting might not be needed here / might be overkill, depending on where we would run it)build:watch
.it adds thehusky
dependency, which allows for git hooks. I've set up thepre-push
hook, which fires before everygit push
.scripts
folder with apublish.js
script, that can be called usingnpm run publish-all
, and it should get the name & version number frompackage.json
, and publish to both NPM and PyPinpm start
commandRight now the publish script does
npm publish
, which isn't enough if you've enabled 2FA. Should we make 2FA the default, i.e. update it to runnpm publish --otp
?What I would like to discuss most is thepre-push
hook. I very much like automating stuff, because I know myself and know that I sometimes forget stuff. The tests take quite a while to finish however, so I would love to know if you think it is unnecessary to run tests before everygit push
. I know that some other big open source projects likeapollo
use this flow, and I know that it never hurts to run tests locally before pushing to Github. I also think it is a good idea toformat
andlint
before pushing, so that the code is clean and readable in a PR.Another point of discussion are the publish scriptspublish-all
andpublish-pypi
. I've left those as-is but I know that they've never really worked for me - I always just runprepublish
first, thennpm publish
and thentwine upload dist/***
what are your thoughts on this?@plotly/dash