Skip to content
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

Documentation for tool tox #11165

Merged
merged 3 commits into from
Oct 6, 2023
Merged

Conversation

Honny1
Copy link
Collaborator

@Honny1 Honny1 commented Oct 2, 2023

Description:

This PR creates documentation for the use of tox. And disables the automatic execution of flake8 when using tox.

@Honny1 Honny1 requested a review from jan-cerny October 2, 2023 12:59
@Honny1 Honny1 added the Documentation Update in project documentation. label Oct 2, 2023
@github-actions
Copy link

github-actions bot commented Oct 2, 2023

Start a new ephemeral environment with changes proposed in this pull request:

Fedora Environment
Open in Gitpod

Oracle Linux 8 Environment
Open in Gitpod

@jan-cerny jan-cerny self-assigned this Oct 2, 2023
@jan-cerny jan-cerny added this to the 0.1.71 milestone Oct 2, 2023
Copy link
Collaborator

@jan-cerny jan-cerny left a comment

Choose a reason for hiding this comment

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

This is a good idea and I love the various examples.

@@ -15,9 +15,44 @@ To add a script to be checked with mypy use the `mypy_test` macro in `tests/CMak

### Unit Tests

`ctest` is used to run the unit tests for the `ssg` python package that is in the repo.
`ctest` is used to run the unit tests for the `ssg` python package that is in the repo. But you need to build content and `ctest` isn't able to run unit tests with differed versions of python. To run only unit tests with differed version of python for the `ssg` python package is recommended to use `tox`.
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is against the Style Guide https://github.com/ComplianceAsCode/content/blob/master/docs/manual/developer/04_style_guide.md#markup-languages which says that we shall have one sentence per line.

@@ -15,9 +15,44 @@ To add a script to be checked with mypy use the `mypy_test` macro in `tests/CMak

### Unit Tests

`ctest` is used to run the unit tests for the `ssg` python package that is in the repo.
`ctest` is used to run the unit tests for the `ssg` python package that is in the repo. But you need to build content and `ctest` isn't able to run unit tests with differed versions of python. To run only unit tests with differed version of python for the `ssg` python package is recommended to use `tox`.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Python should be with capital P.

@@ -15,9 +15,44 @@ To add a script to be checked with mypy use the `mypy_test` macro in `tests/CMak

### Unit Tests

`ctest` is used to run the unit tests for the `ssg` python package that is in the repo.
`ctest` is used to run the unit tests for the `ssg` python package that is in the repo. But you need to build content and `ctest` isn't able to run unit tests with differed versions of python. To run only unit tests with differed version of python for the `ssg` python package is recommended to use `tox`.
Copy link
Collaborator

Choose a reason for hiding this comment

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

different

@@ -15,9 +15,44 @@ To add a script to be checked with mypy use the `mypy_test` macro in `tests/CMak

### Unit Tests

`ctest` is used to run the unit tests for the `ssg` python package that is in the repo.
`ctest` is used to run the unit tests for the `ssg` python package that is in the repo. But you need to build content and `ctest` isn't able to run unit tests with differed versions of python. To run only unit tests with differed version of python for the `ssg` python package is recommended to use `tox`.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't understand what you mean by "But you need to build content and ..." . If you mean that you need to build SCAP content in order to run unit tests then that's not true.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If I understand documentation correctly? It means that the unit tests are part of the ctest test suite, and before running ctest you need to execute the ./build_product command to build the content. For tox, just clone the repo, install tox and run it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

But we're talking about Python unit tests of the ssg Python package. For them to run, you don't have to build anything, it's enough to just configure:

cd build 
rm -rf *
cmake ..
ctest -R python-unit-ssg-module

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Okay, I'll add it to the documentation. This information was missing from the documentation.

`ctest` is used to run the unit tests for the `ssg` python package that is in the repo.
`ctest` is used to run the unit tests for the `ssg` python package that is in the repo. But you need to build content and `ctest` isn't able to run unit tests with differed versions of python. To run only unit tests with differed version of python for the `ssg` python package is recommended to use `tox`.

Note that `tox` creates a virtual environment that handles all dependencies defined in the test request file and performs unit tests with multiple versions of python. Thus, you can test your changes with different versions of python on your machine and don't have to wait for the upstream CI to check them for you.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Python should be with capital P.


*You must be in the root directory of the project before running the `tox` command.*

Runs tests with python2, python3.8, python3.9 and python3-latest on machine:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is the python2 Python 2.7 or which version?

`ctest` is used to run the unit tests for the `ssg` python package that is in the repo.
`ctest` is used to run the unit tests for the `ssg` python package that is in the repo. But you need to build content and `ctest` isn't able to run unit tests with differed versions of python. To run only unit tests with differed version of python for the `ssg` python package is recommended to use `tox`.

Note that `tox` creates a virtual environment that handles all dependencies defined in the test request file and performs unit tests with multiple versions of python. Thus, you can test your changes with different versions of python on your machine and don't have to wait for the upstream CI to check them for you.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would omit the "Note that"

@jan-cerny
Copy link
Collaborator

/packit retest-failed

@codeclimate
Copy link

codeclimate bot commented Oct 4, 2023

Code Climate has analyzed commit fca6810 and detected 0 issues on this pull request.

The test coverage on the diff in this pull request is 100.0% (50% is the threshold).

This pull request will bring the total coverage in the repository to 56.9%.

View more on Code Climate.

@jan-cerny
Copy link
Collaborator

/packit retest-failed

Copy link
Collaborator

@jan-cerny jan-cerny left a comment

Choose a reason for hiding this comment

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

I like these changes very much! They're really detailed and precise.

The TF CS9 fail is tracked in #11179 and isn't caused by the changes in this PR.

@jan-cerny
Copy link
Collaborator

/packit retest-failed

2 similar comments
@jan-cerny
Copy link
Collaborator

/packit retest-failed

@jan-cerny
Copy link
Collaborator

/packit retest-failed

@Honny1 Honny1 requested a review from jan-cerny October 6, 2023 08:00
@Honny1
Copy link
Collaborator Author

Honny1 commented Oct 6, 2023

@jan-cerny All tests were successful.

@jan-cerny jan-cerny merged commit 4530b79 into ComplianceAsCode:master Oct 6, 2023
38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation Update in project documentation.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants