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 #1903 added regex check to ensure analytics/crashlytics is explicitly disab… #4995

Merged
merged 7 commits into from
May 31, 2023

Conversation

chrislee115
Copy link
Contributor

@chrislee115 chrislee115 commented May 23, 2023

Explanation

Fix #1903

Adds a regex check in file content validation to ensure Firebase analytics are disabled in the codebase. Both regex are tested in https://regex101.com/r/l14O5J/1, https://regex101.com/r/QVHGxi/1 for Firebase analytics, Crashlytics, respectively.

Manual testing:
Case 1: firebase_analytis_collection_deactivated = false in AndroidManifest.xml; want = true (line 19)
image

Case 2: firebase_analytis_collection_deactivated = true not found in AndroidManifest.xml; want = explicit line (line 19)
image

Case 3: firebase_crashlytics_collection_enabled = true in AndroidManifest.xml; want = false (line 20)
image

Case 4: firebase_crashlytics_collection_enabled = false not found in AndroidManifest.xml; want = explicit line (line 20)
image

Case 5: happy case
image

Essential Checklist

  • The PR title and explanation each start with "Fix #bugnum: " (If this PR fixes part of an issue, prefix the title with "Fix part of #bugnum: ...".)
  • Any changes to scripts/assets files have their rationale included in the PR explanation.
  • The PR follows the style guide.
  • The PR does not contain any unnecessary code changes from Android Studio (reference).
  • The PR is made from a branch that's not called "develop" and is up-to-date with "develop".
  • [] The PR is assigned to the appropriate reviewers (reference).

Copy link
Collaborator

@adhiamboperes adhiamboperes left a comment

Choose a reason for hiding this comment

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

Hi @chrislee115, thanks for your PR!

Your changes look good, just a couple of things:

  • You have a failing lint check on CI that you should fix. Ktlint usually runs pre-push, and it is likely that you missed this step while setting up your project. Please refer to Gradle Build Failure in Mac M1 #4842 (comment) on how to set this up, so that this will always fail locally before pushing.
  • Please add a demonstration (e.g. screenshots) in the PR description showing these checks correctly failing when the values are reverted in the main AndroidManifest.xml file.

@oppiabot
Copy link

oppiabot bot commented May 24, 2023

Unassigning @adhiamboperes since the review is done.

@oppiabot
Copy link

oppiabot bot commented May 24, 2023

Hi @chrislee115, it looks like some changes were requested on this pull request by @adhiamboperes. PTAL. Thanks!

@chrislee115
Copy link
Contributor Author

  • You have a failing lint check on CI that you should fix. Ktlint usually runs pre-push, and it is likely that you missed this step while setting up your project. Please refer to Gradle Build Failure in Mac M1 #4842 (comment) on how to set this up, so that this will always fail locally before pushing.

Is there an equivalent link for Windows?

@adhiamboperes
Copy link
Collaborator

  • You have a failing lint check on CI that you should fix. Ktlint usually runs pre-push, and it is likely that you missed this step while setting up your project. Please refer to Gradle Build Failure in Mac M1 #4842 (comment) on how to set this up, so that this will always fail locally before pushing.

Is there an equivalent link for Windows?

Please refer to wiki page, for windows instructions to run bash scripts/setup.sh.

@adhiamboperes
Copy link
Collaborator

  • You have a failing lint check on CI that you should fix. Ktlint usually runs pre-push, and it is likely that you missed this step while setting up your project. Please refer to Gradle Build Failure in Mac M1 #4842 (comment) on how to set this up, so that this will always fail locally before pushing.

Is there an equivalent link for Windows?

Please refer to wiki page, for windows instructions to run bash scripts/setup.sh.

Alternatively, in android studio, go to the .github folder and find the static_checks.yml file. Search for the line that corresponds to the name of the job that failed, and you can copy and run the same script on your terminal if you have bazel set up.

@chrislee115
Copy link
Contributor Author

Got it thanks! Sorry for the basic questions - As for testing the changes, should the scripts be run if I run

bazel build //:oppia

If so, it seems like my checks aren't properly working as the build is successfully completing.

@adhiamboperes
Copy link
Collaborator

adhiamboperes commented May 25, 2023

Got it thanks! Sorry for the basic questions - As for testing the changes, should the scripts be run if I run

bazel build //:oppia

If so, it seems like my checks aren't properly working as the build is successfully completing.

Similar to the ktlint check(and any other static check), you can get the command for name: Regex Patterns Validation Check from the static_checks.yml and run it on your terminal. Reference

@chrislee115
Copy link
Contributor Author

Updated the description! I was wondering if we should also prohibit the commented version of the correct lines. I.e.

  <!--  <meta-data android:name="firebase_analytics_collection_deactivated" android:value="true" /> -->

I'm not sure how feasible this is since matching beginning/end of strings appear to not work as intended and matching anything less granular might be too fragile - #4949 (comment)

@adhiamboperes
Copy link
Collaborator

adhiamboperes commented May 25, 2023

Hi @chrislee115 , if you have finished making changes, please re-assign the PR over to the reviewers.

@chrislee115 chrislee115 removed their assignment May 26, 2023
Copy link
Contributor Author

@chrislee115 chrislee115 left a comment

Choose a reason for hiding this comment

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

Added Screenshots in description for manual testing results + fixed kt lint changes in the kt file by shortening test case names.

@chrislee115
Copy link
Contributor Author

I requested another review from you - is that the same as re-assigning? Sorry still new to this

@adhiamboperes
Copy link
Collaborator

I requested another review from you - is that the same as re-assigning? Sorry still new to this

No, you can assign by writing: "@adhiamboperes, PTAL" and oppiabot should assign the person mentioned.

@adhiamboperes
Copy link
Collaborator

Updated the description! I was wondering if we should also prohibit the commented version of the correct lines. I.e.

  <!--  <meta-data android:name="firebase_analytics_collection_deactivated" android:value="true" /> -->

I'm not sure how feasible this is since matching beginning/end of strings appear to not work as intended and matching anything less granular might be too fragile - #4949 (comment)

I will defer to @BenHenning on this.

Copy link
Collaborator

@adhiamboperes adhiamboperes left a comment

Choose a reason for hiding this comment

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

Thanks @chrislee115, these changes look good to me.

Copy link
Sponsor 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 @chrislee115! This looks great! LGTM.

@BenHenning
Copy link
Sponsor Member

Updated the description! I was wondering if we should also prohibit the commented version of the correct lines. I.e.

  <!--  <meta-data android:name="firebase_analytics_collection_deactivated" android:value="true" /> -->

I'm not sure how feasible this is since matching beginning/end of strings appear to not work as intended and matching anything less granular might be too fragile - #4949 (comment)

I will defer to @BenHenning on this.

I think it's fine to ignore this @adhiamboperes @chrislee115 since it's a bit of an edge case, and we still always have codeowners to check for such things happening. This seems like a completely reasonable stop-gap for #1903.

@BenHenning
Copy link
Sponsor Member

Updating to latest develop & enabling auto-merge.

@BenHenning BenHenning enabled auto-merge (squash) May 31, 2023 07:58
@oppiabot
Copy link

oppiabot bot commented May 31, 2023

Unassigning @BenHenning since they have already approved the PR.

@BenHenning BenHenning merged commit 324023b into oppia:develop May 31, 2023
37 checks passed
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.

Add regex checks to ensure Firebase analytics + Crashlytics stay disabled in the codebase.
3 participants