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 #3292: Add check for test files presence for prod files #3343

Merged
merged 140 commits into from
Jul 9, 2021

Conversation

Sparsh1212
Copy link
Contributor

@Sparsh1212 Sparsh1212 commented Jun 18, 2021

Explanation

Fixes #3292: Add check for test files presence for prod files

The script traverses different layers of the codebase to check for the presence of test files for prod files.

Note: It works on the logic of searching Filename+'Test'.kt in the codebase, to ensure the test file presence.
The files listed in the test_file_exemptions.textproto will be skipped for this check, and currently, all the prod files which were failing this check, have been added to this list so that the workflow doesn't fail.
We can remove any file from the exemption list, where we think that we can't go without a test file for that prod file, or if a test file is now added for that particular file.

To run the script, use:

bazel run //scripts:test_file_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/testfile:TestFileCheckTest

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: #3341 #3340

Screenshot of all new added tests passing successfully on local:

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.

@Sparsh1212 Sparsh1212 changed the title Fix #3292: Add check for test files presence for prod files Fix #3292: Add check for test files presence for prod files [Blocked on: #3340 #3341] Jun 18, 2021
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

The same comment applies here from your previous PR regarding the script .kt file and its test file.

@Sparsh1212 Sparsh1212 assigned BenHenning and unassigned Sparsh1212 Jul 8, 2021
Base automatically changed from xml-syntax-check to develop July 8, 2021 22:04
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. Generally LGTM, but two questions:

  1. Can you please bring this branch up-to-date with develop now that Fix #3291: Add check for XML syntax validation #3341 is merged & update the title to no longer indicate it's blocked
  2. Can you clear the textproto file & show what the CI failure looks like for an empty exemption list? I'm interested in verifying the failure cases in a real CI scenario
  3. After (2), please restore the textproto file so that CI is green (the result should be 1 commit with the specific failures requested from (2) and the latest commit passing)

@BenHenning BenHenning assigned Sparsh1212 and unassigned BenHenning Jul 8, 2021
@Sparsh1212 Sparsh1212 changed the title Fix #3292: Add check for test files presence for prod files [Blocked on: #3340 #3341] Fix #3292: Add check for test files presence for prod files Jul 8, 2021
@Sparsh1212
Copy link
Contributor Author

Sparsh1212 commented Jul 8, 2021

@BenHenning
The test commit added!
Also, note that one test will fail, because we have also removed the exempted file which is needed by the exempted file test. So, its a expected behaviour.

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! Just waiting for green CI to merge.

@oppiabot
Copy link

oppiabot bot commented Jul 8, 2021

Unassigning @BenHenning since they have already approved the PR.

@oppiabot
Copy link

oppiabot bot commented Jul 8, 2021

Assigning @seanlip for code owner reviews. Thanks!

@BenHenning
Copy link
Member

@Sparsh1212 looks like the new check is failing in CI--please fix.

@seanlip
Copy link
Member

seanlip commented Jul 9, 2021

I'm a bit confused ... why is Oppiabot assigning me to this PR? I don't code-own any files in it.

@seanlip seanlip removed their assignment Jul 9, 2021
@seanlip seanlip removed their request for review July 9, 2021 00:02
@BenHenning
Copy link
Member

@seanlip looks like a potential bug. You were auto-added as a reviewer because a base PR changed the codeowners file. I guess Oppiabot assumes that reviewers always get auto-assigned even if they aren't a codeowner or at-mentioned?

@BenHenning
Copy link
Member

Thanks @Sparsh1212. Everything is looking good. Enabling auto-merge.

@BenHenning BenHenning enabled auto-merge (squash) July 9, 2021 00:15
@seanlip
Copy link
Member

seanlip commented Jul 9, 2021

Oh, weird. Hm, I'm not too bothered about it, but if it recurs it might be worth fixing on Oppiabot's end. /cc @jameesjohn for info.

@BenHenning BenHenning merged commit 9abd017 into develop Jul 9, 2021
@BenHenning BenHenning deleted the test-file-check branch July 9, 2021 00:41
@jameesjohn
Copy link
Contributor

@seanlip looks like a potential bug. You were auto-added as a reviewer because a base PR changed the codeowners file. I guess Oppiabot assumes that reviewers always get auto-assigned even if they aren't a codeowner or at-mentioned?

Yes. oppiabot assumes that reviewers who are yet to review a PR are to be assigned.

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 that ensures test files are present for all the production files
7 participants