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

Fix Automatus on Python 3.6 #10281

Merged
merged 1 commit into from
Mar 3, 2023
Merged

Conversation

Mab879
Copy link
Member

@Mab879 Mab879 commented Mar 1, 2023

Description:

This PR ensures that JINJA_MACROS_DIRECTORY in ssg/constants.py is always an ABS path.

Fixes #10267

Rationale:

The os.path.dirname(file) on Python 3.6 seems to return an relative path and on newer Pythons it returns an absolute path. This commit ensures that the JINJA_MACROS_DIRECTORY is always an abssolute path. This is needed because the AbsolutePathFileSystemLoader for Jinja will throw a TemplateNotFound if the template path is not absolute

Review Hints:

To reproduce the error use a RHEL 8.7 machine to run the tests as described in #10267.

@Mab879 Mab879 added bugfix Fixes to reported bugs. Test Suite Update in Test Suite. labels Mar 1, 2023
@Mab879 Mab879 added this to the 0.1.67 milestone Mar 1, 2023
@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Used by openshift-ci bot. label Mar 1, 2023
@openshift-ci
Copy link

openshift-ci bot commented Mar 1, 2023

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@Mab879 Mab879 marked this pull request as ready for review March 1, 2023 20:36
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Used by openshift-ci bot. label Mar 1, 2023
@github-actions
Copy link

github-actions bot commented Mar 1, 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

The os.path.dirname(__file__) on Python 3.6 seems to return an relative path
and on newer Pythons it returns an absolute path. This commit ensures that the
JINJA_MACROS_DIRECTORY is always an abssolute path. This is needed
because the AbsolutePathFileSystemLoader for Jinja will throw a
TemplateNotFound if the template path is not absolute
@codeclimate
Copy link

codeclimate bot commented Mar 1, 2023

Code Climate has analyzed commit 5d526d6 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 51.7% (0.0% change).

View more on Code Climate.

@matejak
Copy link
Member

matejak commented Mar 3, 2023

It's probably not the dirname that makes paths relative, but the __file__ , as it is not really documented how it should behave.

@matejak matejak merged commit 10c2df9 into ComplianceAsCode:master Mar 3, 2023
@Mab879 Mab879 deleted the fix_10267 branch March 3, 2023 21:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix Fixes to reported bugs. Test Suite Update in Test Suite.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Automatus does not work with default python on RHEL 8.7
2 participants