codeforpdx / PASS

PASS project - with HMIS module integration
MIT License
28 stars 25 forks source link

Enhancement: Add git hooks to run linter and unit tests #373

Closed timbot1789 closed 10 months ago

timbot1789 commented 1 year ago

Describe the Current Behavior/Feature:

We have several automated tests that run on PRs. eslint, prettier, vitests, etc. We don't allow commits to enter the project if these tests don't pass. However, when developing, it can be annoying to run all these manually. It's very easy to forget to run these tests, and only find out you have failures when you create a PR. This slows down code reviews. Additionally, if a new member is merging from a fork, the PR tests don't run until another maintainer comes by and manually activates them. This makes it difficult to know that they need to run these tests at all.


Proposed Behavior/Feature:

A popular package called Husky is designed to solve these problems. It allows us to run commands on a git commit. If a test fails, the commit is blocked. We can configure this to run eslint, prettier, and vitest. The same commands that are being run in our github workflows.

eathren commented 1 year ago

Everything added, 13 tests currently broken, which would ironically block this from passing if I hadn't committed with the --no-verify flag. Progress can be seen at branch feature-husky-prettier-eslint-tests, and I'll nibble more on it later this week to see if those tests are failing for valid reasons or not.

Some eslintrc rules updated, some deps moved.

eathren commented 1 year ago

Update, those tests also fail on main.

timbot1789 commented 1 year ago

@nolanbraman I just ran your branch, and didn't see any tests failing. What tests are you seeing fail? And what system are you testing on?

eathren commented 1 year ago

@timbot1789 I was on WSL and looks like that was causing problems. On my ubuntu laptop and node v16, looks like tests run squeaky clean on a fresh branch off of Master.

PR is up here with that fresh branch. https://github.com/codeforpdx/PASS/pull/385

timbot1789 commented 10 months ago

This is complete. We've eliminated the test runner feature for now due to poor performance from vitest.