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 #3291: Add check for XML syntax validation #3341

Merged
merged 94 commits into from
Jul 8, 2021
Merged

Conversation

Sparsh1212
Copy link
Contributor

@Sparsh1212 Sparsh1212 commented Jun 18, 2021

Explanation

Fixes #3291: Add check for XML syntac validation

The script traverses different layers of the codebase to check for the syntax correctness of XML files
To run the script, use:

bazel run //scripts:xml_syntax_check -- $(pwd)

For testing the script, automated tests have been added.
To execute the tests, use:

bazel test //scripts/src/javatests/org/oppia/android/scripts/xml:XmlSyntaxCheckTest

Note: We are generating the test assets dynamically at the time of executing them. The test assets are automatically deleted, when the test finishes.

Blocked on: #3340

Screenshot of new tests passing locally:

image

Checklist

  • The PR title starts with "Fix #bugnum: ", followed by a short, clear summary of the changes. (If this PR fixes part of an issue, prefix the title with "Fix part of #bugnum: ...".)
  • The PR explanation includes the words "Fixes #bugnum: ..." (or "Fixes part of #bugnum" if the PR only partially fixes an issue).
  • The PR follows the style guide.
  • The PR does not contain any unnecessary auto-generated code from Android Studio.
  • The PR is made from a branch that's not called "develop".
  • The PR is made from a branch that is up-to-date with "develop".
  • The PR's branch is based on "develop" and not on any other branch.
  • The PR is assigned to an appropriate reviewer in both the Assignees and the Reviewers sections.

Copy link
Contributor

@anandwana001 anandwana001 left a comment

Choose a reason for hiding this comment

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

Thanks @Sparsh1212

Same comment from the previous PR review, for script kt file and test file.


- name: XML Syntax Validation Check
run: |
bazel run //scripts:xml_syntax_check -- $(pwd) app data utility domain
Copy link
Contributor

Choose a reason for hiding this comment

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

data domain doesn't have any res file, utility does file dimen and string XML file if we are checking that else no needed, we can keep the check only for app module.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes! they don't have any res files, but my only concern was that these layers do have the AndroidManifest.xml file present, so I thought of including them too in the XML syntax check.
WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

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

Looking for @BenHenning thoughts on this

Copy link
Member

Choose a reason for hiding this comment

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

Hmm. I just left a comment in #3340 about passing in the root directory and just recursing among that. If we validate all XML files then this slight oddity is less noticeable (since we do ultimately want all XML files to be valid). Would that mitigate the concern here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@anandwana001 anandwana001 removed their assignment Jun 20, 2021
@Sparsh1212 Sparsh1212 removed their assignment Jul 6, 2021
Copy link
Member

@BenHenning BenHenning left a comment

Choose a reason for hiding this comment

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

Thanks @Sparsh1212! Same as #3340. This is effectively 'LGTM' with one more comment to resolve. Please resolve that & assign back once all CI tests are passing in this PR.

@BenHenning BenHenning assigned Sparsh1212 and unassigned BenHenning Jul 8, 2021
Copy link
Member

@BenHenning BenHenning left a comment

Choose a reason for hiding this comment

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

Thanks @Sparsh1212! LGTM, but waiting to approve until #3340 is merged. Also, per our discussion I'm cancelling the workflows for this & the next PR since that will relieve pressure on the CI system and once you merge #3340 into develop and update these PRs they should have much fewer tests to run..

Base automatically changed from regex-checks to develop July 8, 2021 21:13
@BenHenning BenHenning requested a review from a team as a code owner July 8, 2021 21:13
@BenHenning BenHenning requested a review from seanlip July 8, 2021 21:13
@Sparsh1212 Sparsh1212 assigned BenHenning and unassigned Sparsh1212 Jul 8, 2021
@BenHenning BenHenning changed the title Fix #3291: Add check for XML syntax validation [Blocked on: #3340] Fix #3291: Add check for XML syntax validation Jul 8, 2021
Copy link
Member

@BenHenning BenHenning left a comment

Choose a reason for hiding this comment

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

Thanks @Sparsh1212! CI is green so going ahead and merging this.

@BenHenning BenHenning merged commit 128b386 into develop Jul 8, 2021
@BenHenning BenHenning deleted the xml-syntax-check branch July 8, 2021 22:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create a Kotlin script to validate the Xml files for syntax correctness
5 participants