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

Add FXIOS-9487 - Remote settings config auto fetch script for password rules #21023

Merged

Conversation

nbhasin2
Copy link
Contributor

📜 Tickets

Jira ticket
Github issue

💡 Description

This script is to fetch remote settings on Tuesdays and Thursdays automatically and create necessary PRs if there are any changes.

  • Added github actions for auto fetch
  • Added python script to fetch remote settings
  • Added initial remote settings record for password rules

Ref: https://github.com/issammani/firefox-ios/blob/main/.github/workflows/firefox-ios-update_credential_provider_script.yml

📝 Checklist

You have to check all boxes before merging

  • Filled in the above information (tickets numbers and description of your work)
  • Updated the PR name to follow our PR naming guidelines
  • Wrote unit tests and/or ensured the tests suite is passing
  • When working on UI, I checked and implemented accessibility (minimum Dynamic Text and VoiceOver)
  • If needed, I updated documentation / comments for complex code and public methods
  • If needed, added a backport comment (example @Mergifyio backport release/v120)

@nbhasin2
Copy link
Contributor Author

@issammani I am tagging you as you did some work around fetching data using python script from HG for autofill
And also tagging @razvanlitianu as he is involved in the autofill area in general

Copy link
Collaborator

@issammani issammani left a comment

Choose a reason for hiding this comment

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

This looks great. Thanks @nbhasin2.

Tried locally and it works as expected when the json file changed / not changed. I left some minor nits.


if not changes_detected:
print("No changes detected in any rules.")

Copy link
Collaborator

Choose a reason for hiding this comment

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

It won't break the code since we check if the directory exists before creating it, but maybe we should remove the directory after we are done ? Something like shutil.rmtree(GITHUB_ACTIONS_TMP_PATH)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

true, I left it here as I wasn't sure what to do here 🤷🏼
One question that I had was since its run on github actions, does it spin a new VM everytime an action is run or all share the same VM

Copy link
Collaborator

Choose a reason for hiding this comment

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

Good question. So looking at the docs, github actions doesn't cache that directory between runs. And since the files in there won't be committed and not in the final PR it doesn't really matter if we remove it or not 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can leave it be then for any logs during that run!

@nbhasin2 nbhasin2 marked this pull request as ready for review July 19, 2024 19:59
@nbhasin2 nbhasin2 requested review from a team as code owners July 19, 2024 19:59
@nbhasin2 nbhasin2 requested a review from isabelrios July 19, 2024 19:59
Comment on lines +4 to +7
"name": "Password Rules",
"url": "https://firefox.settings.services.mozilla.com/v1/buckets/main/collections/password-rules/records",
"file": "./firefox-ios/Client/Assets/RemoteSettingsData/RemotePasswordRules.json"
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Making it ready for review, once this gets merged I will start the process of adding more files for upcoming remote settings work. So think of this as the initial step

@issammani issammani self-requested a review July 22, 2024 04:35
@nbhasin2
Copy link
Contributor Author

Once @isabelrios gives the r+ I will merge this in 🤞🏼

- name: Commit and push changes
run: |
git diff
git diff --quiet || (git add . && git commit -m "Update remote settings with latest rules" && git push)
Copy link
Contributor

Choose a reason for hiding this comment

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

If I got it right you are creating a temp file when comparing the changes.. git git add . it may be added... I always try to be specific about the files that I would expect to be changed and commited in the PR to save time not having to fix the automatic PR

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh you mean, make it explicit?

Copy link
Contributor

Choose a reason for hiding this comment

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

- name: Send Slack notification if GitHub Action fails
if: '!cancelled()'
id: slack
uses: slackapi/slack
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this needs to be like: slackapi/[email protected], I see an error in your for for this github action

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, not sure if just with that there will be a notification, usually there are some fields to be filled in in this step.. we can try to trigger the action from your fork and see

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

This PR has been automatically marked as stale. Please leave any comment to keep this PR opened. It will be closed automatically if no further update occurs in the next 7 days. Thank you for your contributions!

@github-actions github-actions bot added the stale Stalebot use this label to stale issues and PRs label Aug 17, 2024
@github-actions github-actions bot closed this Aug 24, 2024
@nbhasin2 nbhasin2 reopened this Sep 3, 2024
@nbhasin2 nbhasin2 force-pushed the nb/remote_setting_config_password_rule branch from 0ac1fe4 to 1d7cdca Compare September 3, 2024 22:04
@nbhasin2 nbhasin2 removed the stale Stalebot use this label to stale issues and PRs label Sep 3, 2024
Comment on lines +69 to +75
env:
JOB_STATUS: ${{ job.status == 'success' && ':white_check_mark:' || job.status == 'failure' && ':x:' }}
JOB_STATUS_COLOR: ${{ job.status == 'success' && '#36a64f' || job.status == 'failure' && '#FF0000' }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
with:
payload-file-path: "./test-fixtures/ci/slack-notification-payload-remote-settings-fetch.json"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@isabelrios added payload, could you review please 🙏🏼

Copy link
Contributor

Choose a reason for hiding this comment

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

The slack notification is correctly received now:
Failing:
imagen
Working:
imagen

This is received in the Mobile Test eng alerts sandbox, where we test notifications, we monitor that, if you want to move that to firefox-ios let me know so that we change the slack token

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks Isabel, we can leave it there for now. Maybe once I add more items we can look into sending it to its own area.

- name: Commit and push changes
run: |
git diff
git diff --quiet || (git add firefox-ios/Client/Assets/RemoteSettingsData/RemotePasswordRules.json && git commit -m "Update remote settings with latest rules" && git push)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@isabelrios also added specific json file location, tagging you to double check

Copy link
Contributor

@isabelrios isabelrios Sep 4, 2024

Choose a reason for hiding this comment

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

You would need to remove the latest part: && git commit -m "Update remote settings with latest rules" && git push
The github action fails to do the push directly, I don't think we want that push to happen without review..

If you remove that part, there is the next step to create the PR with the changes to review and then merge

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@isabelrios let me DM you as I am wondering why do I even need the commit part considering we are doing the create pull request

@mobiletest-ci-bot
Copy link

mobiletest-ci-bot commented Sep 3, 2024

Messages
📖 Edited 1 files
📖 Created 5 files

Generated by 🚫 Danger Swift against 04ed227

@isabelrios
Copy link
Contributor

isabelrios commented Sep 4, 2024

Once @isabelrios gives the r+ I will merge this in 🤞🏼

Sorry, there is one more change to make or the github action will consistently fail. Please see my comment to remove part of the git diff statement. Thanks!

@nbhasin2 nbhasin2 merged commit 858d432 into mozilla-mobile:main Sep 4, 2024
13 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.

6 participants