Skip to content

Unit tests + coverage reports, type checking, pre-commit, and requested fixes #81

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 77 commits into from
Aug 18, 2022

Conversation

2bndy5
Copy link
Collaborator

@2bndy5 2bndy5 commented Aug 9, 2022

Issues addressed

And more

  • skip executing clang-format if the style option is set to a blank string ('')
  • allow any OS to accept a path to the installed tools via the version option. Previously, this was intended only for Windows OS, but it was needed to allow custom builds of the tools to be executed from a user-defined install path.
  • switched to rely more on pathlib instead of os for file system operations.
    • with the switch to using pathlib.Path.rglob() (instead of using os.walk()), I was able to remove a slightly misleading debug statement as well.
  • moved install config to pyproject.toml, and updated the dockerfile accordingly. The setup.py file isn't actually used any more, but remains for older versions of pip.
  • added numerous unit tests and integrated codecov.io for coverage reporting.
  • simplified the stored list of files so that the same structure can be used for any supported event
  • improve translation from file's byte-offset to file's line & columns.
  • ensure the demo C++ sources use LF despite the OS that's checking out the repo. This was needed to get consistent results from the unit tests about the previous point.
  • added a CI workflow to publish to pypi or test-pypi. I also added the necessary pypi/test-pypi API tokens to this repo's secrets.
  • added type checking from mypy tool
  • added pre-commit config

2bndy5 added 30 commits July 26, 2022 15:26
- fix a few long line warnings
- add rich to the py dev reqs
- add types-PyYAML to dev reqs
normalize submodule path separators per runner's OS
also make sure the current working directory is appended to the .gitmodules path
- add pytest to dev reqs
- rename run-pylint.yml to run-dev-tests.yml
- install cpp-linter pkg in run-dev-tests.yml workflow
- upgrade actions/setup-python to v2 in run-dev-tests.yml workflow
- rename step in run-dev-tests.yml workflow
This allows the `lines-changed-only` option to accept the following values:
- false: All lines in a file are analyzed
- true: All lines in the diff are analyzed (including unchanged lines)
- strict: Only lines in the diff that contain additions are analyzed

gitignore some test resources as they are fetched running the tests.

Retain original repo structure when fetching files. This is only used when the user doesn't checkout the repo being analyzed.
also fix a typo in demo.hpp variable name
@2bndy5 2bndy5 marked this pull request as ready for review August 18, 2022 07:44
@2bndy5
Copy link
Collaborator Author

2bndy5 commented Aug 18, 2022

The file annotations seem to be in order also (see here). I'm much more confident now that we have 80% coverage and expected behavior in the unit tests.

@shenxianpeng
Copy link
Collaborator

shenxianpeng commented Aug 18, 2022

Could you also please update README.md to introduce v2 in this PR or #83. I believe your introduction must be better than mine. Thank you.

@2bndy5
Copy link
Collaborator Author

2bndy5 commented Aug 18, 2022

I think the v2 should go in #83 All the changes here were made with backward compatibility in mind. I do think there's some changes that should be made regarding the input options, so I'll re-read that file for accuracy.

@shenxianpeng
Copy link
Collaborator

Sure, please go ahead with #83

@2bndy5
Copy link
Collaborator Author

2bndy5 commented Aug 18, 2022

Is the .ci-ignore file still needed?

cpp_linter
mkdocs.yml

I recall this was for an external linter CI you had configured for the repo, but not sure if changing to an org account affected that.

@shenxianpeng
Copy link
Collaborator

I forgot it was configured by me. I even don't know what it used for, I think we don't need it

@2bndy5
Copy link
Collaborator Author

2bndy5 commented Aug 18, 2022

I think I'll leave this alone until I'm sure the pkg is available on pypi

run: python3 -m pip install git+https://github.com/cpp-linter/cpp-linter-action@v1

It would be nice to have all versions of the python source code up on pypi, but that's a lot of work for code that is known to be flawed.

@2bndy5
Copy link
Collaborator Author

2bndy5 commented Aug 18, 2022

Please look over the readme changes. I also removed that .ci-ignore file.

@shenxianpeng shenxianpeng self-requested a review August 18, 2022 09:07
@2bndy5
Copy link
Collaborator Author

2bndy5 commented Aug 18, 2022

All good to go on my end. Here's hoping uploads to pypi don't have the same problems we experienced with cpp-linter/clang-tools-pip v0.3.0 release.

🤞🏼

I added the PyPI token to this repo...

@shenxianpeng
Copy link
Collaborator

shenxianpeng commented Aug 18, 2022

Why not add PyPI token to cpp-linter repo, do you want to upload the package from this repo first and then migrate it to cpp-linter?

I used the same approach(in clang-tools-pip) and upload cpp-linter/cpp-linter-hooks to PyPI, everything goes well.

The only problem is you need to create a token (the scope is for all projects) for uploading if you don't have the project named cpp-linter in your pypi, then you have to create another token that scope is only for cpp-linter and update the token in the GitHub repo if you care about security.

@2bndy5
Copy link
Collaborator Author

2bndy5 commented Aug 18, 2022

do you want to upload the package from this repo first and then migrate it to cpp-linter?

Yes. That would eliminate some guesswork from migration. PyPI doesn't care about the origin as long as the right credentials are used.

@2bndy5
Copy link
Collaborator Author

2bndy5 commented Aug 18, 2022

According to the codecov action, the secret token isn't needed for public repos.

@shenxianpeng
Copy link
Collaborator

OK, please go ahead to remove the token.

@2bndy5
Copy link
Collaborator Author

2bndy5 commented Aug 18, 2022

Done.

If you're using the upload script from codecov's instruction on the cpp-linter-hook repo, then switching to the codecov action will eliminate the need for that token in the org secrets.

I'm honestly not sure if the token is needed after uploading the first report.

@shenxianpeng
Copy link
Collaborator

shenxianpeng commented Aug 18, 2022

I remember I copied the upload script and token from the codecov portal. It's Okay to remove the token and replaced with action, it should be easy to fix if any errors report.

@2bndy5
Copy link
Collaborator Author

2bndy5 commented Aug 18, 2022

Done (with no problems).

@shenxianpeng
Copy link
Collaborator

Done (with no problems).

So ready to merge?

@2bndy5
Copy link
Collaborator Author

2bndy5 commented Aug 18, 2022

yep

@shenxianpeng shenxianpeng merged commit 600b1aa into master Aug 18, 2022
@shenxianpeng shenxianpeng deleted the backlogged-updates branch August 18, 2022 11:17
2bndy5 added a commit to cpp-linter/test-cpp-linter-action that referenced this pull request Aug 19, 2022
* add a submodule and update the CI checkout steps

* Use NMake generator on Windows to get a DB

* setup VS dev env in CI

* don't use database option when running as action

* do thread comments when run as action
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
3 participants