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

Reduce XML reformatting #11641

Merged
merged 8 commits into from
Mar 7, 2024
Merged

Reduce XML reformatting #11641

merged 8 commits into from
Mar 7, 2024

Conversation

jan-cerny
Copy link
Collaborator

@jan-cerny jan-cerny commented Mar 1, 2024

Description:

This PR removes xmllint reformat steps when they are not needed.

First, we don't need to reformat the XMLs of the internal steps that aren't shipped to the users, ie. oval-unlinked.xml and ocil-unlinked.xml. Second, if we use Python 3.9 or newer, the outputs are generated already formatted so we don't need to reformat them.

For more details, please read commit messages of all commits.

Rationale:

small speed up (1 - 2 seconds)

These files are interim built artifects and aren't shipped
or packaged, therefore they don't need to look nice.
If we have Python 3.9 or newer, we use the ElementTree.indent method
which formats the output which means the output doesn't have to be
reformatted.
Use the ET.indent() method if it's available (ie. on Python 3.9
and newer) for building OCIL documents.
If we have Python 3.9 or newer, we use the ElementTree.indent method
which formats the output which means the output doesn't have to be
reformatted.
Format output with 2 spaces and add XML header when building the
ssg-$product-xccdf.xml.
If we have Python 3.9 or newer, we use the ElementTree.indent method
which formats the output which means the output doesn't have to be
reformatted.
@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Used by openshift-ci bot. label Mar 1, 2024
Copy link

openshift-ci bot commented Mar 1, 2024

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

@jan-cerny jan-cerny added the Infrastructure Our content build system label Mar 1, 2024
Copy link

github-actions bot commented Mar 1, 2024

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

Fedora Environment
Open in Gitpod

Oracle Linux 8 Environment
Open in Gitpod

Copy link

github-actions bot commented Mar 1, 2024

🤖 A k8s content image for this PR is available at:
ghcr.io/complianceascode/k8scontent:11641

Click here to see how to deploy it

If you alread have Compliance Operator deployed:
utils/build_ds_container.py -i ghcr.io/complianceascode/k8scontent:11641

Otherwise deploy the content and operator together by checking out ComplianceAsCode/compliance-operator and:
CONTENT_IMAGE=ghcr.io/complianceascode/k8scontent:11641 make deploy-local

Reduce code duplication by unifying the code of macros
ssg_build_xccdf_final, ssg_build_oval_final and ssg_build_ocil_final
into a single macro ssg_build_xml_final.
Copy link

codeclimate bot commented Mar 1, 2024

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

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

This pull request will bring the total coverage in the repository to 59.8% (0.0% change).

View more on Code Climate.

@jan-cerny jan-cerny marked this pull request as ready for review March 1, 2024 15:37
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Used by openshift-ci bot. label Mar 1, 2024
@jan-cerny jan-cerny added this to the 0.1.73 milestone Mar 1, 2024
@Mab879 Mab879 self-assigned this Mar 7, 2024
@Mab879
Copy link
Member

Mab879 commented Mar 7, 2024

Waving the coverage as this code is ran in the build steps.

@Mab879 Mab879 merged commit 6644eae into ComplianceAsCode:master Mar 7, 2024
43 of 44 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Infrastructure Our content build system
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants