awslabs / damo

DAMON user-space tool
https://damonitor.github.io/
GNU General Public License v2.0
155 stars 26 forks source link

pre-commit: Add automatic unittest script run #102

Closed honggyukim closed 3 months ago

honggyukim commented 3 months ago

The PR #100 supports "target_nid" for migrate actions, but it didn't handle the unit test properly.

It's because running unit test at ./tests/unit/test.sh is recommended at CONTRIBUTING file, but it's not enforced before making PRs.

This patch make each commit prevent from breaking unittest unexpectedly by having a dedicated pre-commit hook that runs ./tests/unit/test.sh when .py files are modified.

The following log shows when test_damo_schemes_input.py is broken as the PR #100 made the issue.

  check yaml...............................................................Passed
  fix end of files.........................................................Passed
  trim trailing whitespace.................................................Passed
  isort................................................(no files to check)Skipped
  codespell................................................................Passed
  ./tests/unit/test.sh.....................................................Failed
  - hook id: unit-test
  - exit code: 1

  PASS unit test_damo_records.py
  PASS unit test_damo_scheme_dbgfs_conversion.py
  FAIL unit test_damo_schemes_input.py

This was fixed by the commit below, but just roll backed to one before this commit to see whether the pre-commit hook runs properly showing the issue.

79d0d69 tests/unit/test_damo_schemes_input: Fix wrong Damos constructor call

sj-aws commented 3 months ago

Looks great to me. Thank you for making damo much better!

honggyukim commented 3 months ago

Thanks. My pleasure!