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

DX: Preload user namespace #19927

Merged
merged 6 commits into from
May 10, 2024
Merged

DX: Preload user namespace #19927

merged 6 commits into from
May 10, 2024

Conversation

ilmotta
Copy link
Contributor

@ilmotta ilmotta commented May 7, 2024

Summary

This PR preloads the user namespace (src/user.cljs and src/dev/user.cljs) for the mobile target and for dev-only purposes. The files are git-ignored.

Just a reminder that you'll be responsible for making sure your user namespace is correct. If it's broken in any way (e.g. calling non-existent code) the app will crash at initialization (dev-only environment obviously).

Why?

When the app initializes, it loads namespaces that were required at least once. If you create a user namespace, it won't be automatically required for you. And if you, like some Clojure devs, like to use the user namespace as your safe heaven for experimentation and dev-only utilities, you'll need to remember to evaluate the namespace at least once.

This is tedious and many times I forgot to do so and the app crashed because the compiler didn't know where the symbols were coming from.

How do I use it?

Simply create a file src/user.cljs or src/dev/user.cljs and write whatever you want there! Personally, I often use it to persist experiments during development, for example, functions to manipulate the app-db, functions I can call from Emacs directly, debugging functions (e.g. #19906 (comment)), and so on.

Some Clojure teams like to commit the user namespace and share it with other team members. This can work, but to me it misses the point that I want a namespace that's already loaded and which is my own playground where I don't care about code quality.

Areas that may be impacted

None.

Steps to test

Behavior-wise, nothing to test. As a dev, you can verify it works for you by creating a file like the following, and you can require any namespace inside src/. Once you load the app, the vars inside user or dev.user ns should be readily available for you to be used anywhere in the repo without having to require the user namespace in ns forms.

Remember to delete code using the user namespace before opening a PR ;)

(ns dev.user)

status: ready

@status-im-auto
Copy link
Member

status-im-auto commented May 7, 2024

Jenkins Builds

Click to see older builds (20)
Commit #️⃣ Finished (UTC) Duration Platform Result
5ce9206 #1 2024-05-07 13:25:17 ~3 min tests 📄log
✔️ 5ce9206 #1 2024-05-07 13:28:41 ~6 min android-e2e 🤖apk 📲
✔️ 5ce9206 #1 2024-05-07 13:29:54 ~7 min android 🤖apk 📲
✔️ 5ce9206 #1 2024-05-07 13:31:45 ~9 min ios 📱ipa 📲
✔️ 5cb40df #2 2024-05-07 13:49:00 ~3 min tests 📄log
✔️ 5cb40df #2 2024-05-07 13:50:44 ~5 min android-e2e 🤖apk 📲
✔️ 5cb40df #2 2024-05-07 13:52:20 ~7 min android 🤖apk 📲
✔️ 5cb40df #2 2024-05-07 13:54:55 ~9 min ios 📱ipa 📲
✔️ 31c986f #3 2024-05-07 14:23:48 ~4 min tests 📄log
✔️ 31c986f #3 2024-05-07 14:25:47 ~6 min android-e2e 🤖apk 📲
✔️ 31c986f #3 2024-05-07 14:25:50 ~6 min android 🤖apk 📲
31c986f #3 2024-05-07 14:28:40 ~9 min ios 📄log
✔️ 6d17457 #5 2024-05-07 14:54:10 ~3 min tests 📄log
✔️ 6d17457 #5 2024-05-07 14:55:50 ~5 min android-e2e 🤖apk 📲
✔️ 6d17457 #5 2024-05-07 14:57:22 ~7 min android 🤖apk 📲
✔️ 6d17457 #5 2024-05-07 14:59:57 ~9 min ios 📱ipa 📲
✔️ 5ec8e17 #7 2024-05-07 15:19:27 ~4 min tests 📄log
✔️ 5ec8e17 #7 2024-05-07 15:21:53 ~6 min android 🤖apk 📲
✔️ 5ec8e17 #7 2024-05-07 15:23:22 ~8 min android-e2e 🤖apk 📲
✔️ 5ec8e17 #7 2024-05-07 15:24:38 ~9 min ios 📱ipa 📲
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ ff5db2a #8 2024-05-09 18:15:15 ~5 min android-e2e 🤖apk 📲
✔️ ff5db2a #8 2024-05-09 18:16:13 ~6 min android 🤖apk 📲
✔️ ff5db2a #8 2024-05-09 18:19:07 ~9 min ios 📱ipa 📲
✔️ c9544a9 #9 2024-05-10 15:58:43 ~4 min tests 📄log
✔️ c9544a9 #9 2024-05-10 16:02:16 ~8 min android-e2e 🤖apk 📲
✔️ c9544a9 #9 2024-05-10 16:02:19 ~8 min android 🤖apk 📲
✔️ c9544a9 #9 2024-05-10 16:03:43 ~9 min ios 📱ipa 📲

Copy link
Member

@seanstrom seanstrom left a comment

Choose a reason for hiding this comment

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

Looks good ✅
Thanks for setting this up 🙏

shadow-cljs.edn Outdated Show resolved Hide resolved
@ilmotta ilmotta force-pushed the ilmotta/preload-user-namespace branch from 5cb40df to 31c986f Compare May 7, 2024 14:19
Copy link
Member

@clauxx clauxx left a comment

Choose a reason for hiding this comment

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

@ilmotta Thank you for this. So many times I reset the user ns accidentally 😞

BTW Would it be possible to have both user and dev.user?

@ilmotta ilmotta force-pushed the ilmotta/preload-user-namespace branch from a3d49c8 to 6d17457 Compare May 7, 2024 14:49
@ilmotta
Copy link
Contributor Author

ilmotta commented May 7, 2024

@ilmotta Thank you for this. So many times I reset the user ns accidentally 😞

BTW Would it be possible to have both user and dev.user?

Yes, so many times! I can accommodate your suggestion @clauxx. @seanstrom does that sound okay for you?

@ilmotta ilmotta requested a review from J-Son89 May 7, 2024 14:54
@seanstrom
Copy link
Member

@ilmotta Thank you for this. So many times I reset the user ns accidentally 😞
BTW Would it be possible to have both user and dev.user?

Yes, so many times! I can accommodate your suggestion @clauxx. @seanstrom does that sound okay for you?

I'm happy to have both too 🙌

Copy link
Contributor

@OmarBasem OmarBasem left a comment

Choose a reason for hiding this comment

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

Thank you @ilmotta for this PR! 😄

@ilmotta ilmotta force-pushed the ilmotta/preload-user-namespace branch from 5ec8e17 to ff5db2a Compare May 9, 2024 18:09
@status-im-auto
Copy link
Member

85% of end-end tests have passed

Total executed tests: 52
Failed tests: 6
Expected to fail tests: 2
Passed tests: 44
IDs of failed tests: 727230,704613,727229,702807,727232,702775 
IDs of expected to fail tests: 703495,703503 

Failed tests (6)

Click to expand
  • Rerun failed tests

  • Class TestWalletMultipleDevice:

    1. test_wallet_send_asset_from_drawer, id: 727230

    # STEP: Getting ETH amount in the wallet of the sender before transaction
    Device 1: Find `WalletTab` by `accessibility id`: `wallet-stack-tab`

    critical/test_wallet.py:117: in test_wallet_send_asset_from_drawer
        sender_balance, receiver_balance, eth_amount_sender, eth_amount_receiver = self._get_balances_before_tx()
    critical/test_wallet.py:39: in _get_balances_before_tx
        self.wallet_1.wallet_tab.click()
    ../views/base_element.py:90: in click
        element = self.find_element()
    ../views/base_element.py:79: in find_element
        raise NoSuchElementException(
     Device 1: WalletTab by accessibility id: `wallet-stack-tab` is not found on the screen; For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors#no-such-element-exception
    



    2. test_wallet_send_eth, id: 727229

    Device 1: Swiping right on element SlideButton
    Device 1: Find SlideButton by xpath: //*[@resource-id='slide-button-track']

    critical/test_wallet.py:109: in test_wallet_send_eth
        self.wallet_1.send_asset(address=self.receiver['address'], asset_name='Ether', amount=amount_to_send)
    ../views/wallet_view.py:99: in send_asset
        self.confirm_transaction()
    ../views/wallet_view.py:86: in confirm_transaction
        self.slide_and_confirm_with_password()
    ../views/wallet_view.py:80: in slide_and_confirm_with_password
        self.slide_button_track.slide()
    ../views/base_view.py:257: in slide
        self.swipe_right_on_element(width_percentage=1.3, start_x=100)
    ../views/base_element.py:308: in swipe_right_on_element
        location, size = self.get_element_coordinates()
    ../views/base_element.py:294: in get_element_coordinates
        element = self.find_element()
    ../views/base_element.py:79: in find_element
        raise NoSuchElementException(
     Device 1: SlideButton by xpath: `//*[@resource-id='slide-button-track']` is not found on the screen; For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors#no-such-element-exception
    



    Class TestGroupChatMultipleDeviceMergedNewUI:

    1. test_group_chat_join_send_text_messages_push, id: 702807

    Device 2: Find Text by xpath: //*[starts-with(@text,'Hey, admin!')]/ancestor::android.view.ViewGroup[@content-desc='chat-item']//*[@content-desc='message-status']/android.widget.TextView
    Device 2: Text is Sent

    critical/chats/test_group_chat.py:95: in test_group_chat_join_send_text_messages_push
        self.chats[1].chat_element_by_text(message_to_admin).wait_for_status_to_be('Delivered', timeout=120)
    ../views/chat_view.py:225: in wait_for_status_to_be
        raise TimeoutException("Message status was not changed to %s, it's %s" % (expected_status, current_status))
     Message status was not changed to Delivered, it's Sent
    



    Device sessions

    Class TestWalletOneDevice:

    1. test_wallet_add_remove_watch_only_account, id: 727232

    Device 1: Find EditBox by accessibility id: add-address-to-watch
    Device 1: Type 0x8d2413447ff297d30bdc475f6d5cb00254685aae to EditBox

    critical/test_wallet.py:190: in test_wallet_add_remove_watch_only_account
        self.wallet_view.add_watch_only_account(address=address_to_watch, account_name=new_account_name)
    ../views/wallet_view.py:120: in add_watch_only_account
        self.account_has_activity_label.wait_for_visibility_of_element()
    ../views/base_element.py:147: in wait_for_visibility_of_element
        raise TimeoutException(
     Device 1: Text by accessibility id:`account-has-activity` is not found on the screen after wait_for_visibility_of_element
    



    Device sessions

    Class TestDeepLinksOneDevice:

    1. test_links_open_universal_links_from_chat, id: 704613

    Device 1: Find Button by xpath: //*[@text="open community"]
    Device 1: Tap on found: Button

    critical/test_deep_and_universal_links.py:70: in test_links_open_universal_links_from_chat
        self.errors.verify_no_errors()
    base_test_case.py:190: in verify_no_errors
        pytest.fail('\n '.join([self.errors.pop(0) for _ in range(len(self.errors))]))
     Community 'Open community for e2e' was not requested to join by the url https://status.app/c/G1AAAGR0G-IRb2YJD4lRXwLusAFnGrDHGNl6Wt55MIARwVYvarnO873011-fdVSz1kHSan-qq0G96vOaMqyTRhJnQV74KCUr#zQ3shb9irJR66rhG1E8sQZX8pDU3dpGm4daYSmPVDd2e73ewE
    



    Device sessions

    2. test_links_deep_links, id: 702775

    Device 1: Find BrowserTab by accessibility id: browser-stack-tab
    Device 1: Tap on found: BrowserTab

    critical/test_deep_and_universal_links.py:114: in test_links_deep_links
        self.errors.verify_no_errors()
    base_test_case.py:190: in verify_no_errors
        pytest.fail('\n '.join([self.errors.pop(0) for _ in range(len(self.errors))]))
     Community 'Open community for e2e' was not requested to join by the deep link status.app://c/G1AAAGR0G-IRb2YJD4lRXwLusAFnGrDHGNl6Wt55MIARwVYvarnO873011-fdVSz1kHSan-qq0G96vOaMqyTRhJnQV74KCUr#zQ3shb9irJR66rhG1E8sQZX8pDU3dpGm4daYSmPVDd2e73ewE
    



    Device sessions

    Expected to fail tests (2)

    Click to expand

    Class TestCommunityOneDeviceMerged:

    1. test_community_discovery, id: 703503

    Test is not run, e2e blocker  
    

    [[reason: [NOTRUN] Curated communities not loading, https://github.com//issues/17852]]

    Class TestGroupChatMultipleDeviceMergedNewUI:

    1. test_group_chat_mute_chat, id: 703495

    # STEP: Change device time so chat will be unmuted by timer
    Device 2: Long press on ChatElement

    critical/chats/test_group_chat.py:464: in test_group_chat_mute_chat
        self.errors.verify_no_errors()
    base_test_case.py:190: in verify_no_errors
        pytest.fail('\n '.join([self.errors.pop(0) for _ in range(len(self.errors))]))
     Chat is still muted after timeout 
    

    [[Chat is not unmuted after expected time: https://github.com//issues/19627]]

    Device sessions

    Passed tests (44)

    Click to expand

    Class TestCommunityMultipleDeviceMergedTwo:

    1. test_community_markdown_support, id: 702809
    Device sessions

    2. test_community_hashtag_links_to_community_channels, id: 702948
    Device sessions

    3. test_community_mentions_push_notification, id: 702786
    Device sessions

    4. test_community_leave, id: 702845
    Device sessions

    5. test_community_join_when_node_owner_offline, id: 703629
    Device sessions

    Class TestOneToOneChatMultipleSharedDevicesNewUiTwo:

    1. test_1_1_chat_delete_via_long_press_relogin, id: 702784
    Device sessions

    2. test_1_1_chat_is_shown_message_sent_delivered_from_offline, id: 702783
    Device sessions

    3. test_1_1_chat_mute_chat, id: 703496
    Device sessions

    Class TestActivityMultipleDevicePRTwo:

    1. test_activity_center_mentions, id: 702957
    Device sessions

    2. test_activity_center_admin_notification_accept_swipe, id: 702958
    Device sessions

    Class TestActivityMultipleDevicePR:

    1. test_navigation_jump_to, id: 702936
    Device sessions

    2. test_activity_center_reply_read_unread_delete_filter_swipe, id: 702947
    Device sessions

    Class TestCommunityOneDeviceMerged:

    1. test_restore_multiaccount_with_waku_backup_remove_switch, id: 703133
    Device sessions

    2. test_community_copy_and_paste_message_in_chat_input, id: 702742
    Device sessions

    3. test_community_undo_delete_message, id: 702869
    Device sessions

    4. test_community_navigate_to_channel_when_relaunch, id: 702846
    Device sessions

    5. test_community_mute_community_and_channel, id: 703382
    Device sessions

    Class TestActivityCenterContactRequestMultipleDevicePR:

    1. test_add_contact_field_validation, id: 702777
    Device sessions

    2. test_activity_center_contact_request_accept_swipe_mark_all_as_read, id: 702851
    Device sessions

    3. test_activity_center_contact_request_decline, id: 702850
    Device sessions

    Class TestCommunityMultipleDeviceMerged:

    1. test_community_several_images_send_reply, id: 703194
    Device sessions

    2. test_community_one_image_send_reply, id: 702859
    Device sessions

    3. test_community_emoji_send_copy_paste_reply, id: 702840
    Device sessions

    4. test_community_mark_all_messages_as_read, id: 703086
    Device sessions

    5. test_community_contact_block_unblock_offline, id: 702894
    Device sessions

    6. test_community_edit_delete_message_when_offline, id: 704615
    Device sessions

    7. test_community_message_delete, id: 702839
    Device sessions

    8. test_community_message_send_check_timestamps_sender_username, id: 702838
    Device sessions

    9. test_community_links_with_previews_github_youtube_twitter_gif_send_enable, id: 702844
    Device sessions

    10. test_community_message_edit, id: 702843
    Device sessions

    11. test_community_unread_messages_badge, id: 702841
    Device sessions

    Class TestWalletOneDevice:

    1. test_wallet_add_remove_regular_account, id: 727231
    Device sessions

    Class TestGroupChatMultipleDeviceMergedNewUI:

    1. test_group_chat_pin_messages, id: 702732
    Device sessions

    2. test_group_chat_send_image_save_and_share, id: 703297
    Device sessions

    3. test_group_chat_reactions, id: 703202
    Device sessions

    4. test_group_chat_offline_pn, id: 702808
    Device sessions

    Class TestOneToOneChatMultipleSharedDevicesNewUi:

    1. test_1_1_chat_emoji_send_reply_and_open_link, id: 702782
    Device sessions

    2. test_1_1_chat_text_message_delete_push_disappear, id: 702733
    Device sessions

    3. test_1_1_chat_push_emoji, id: 702813
    Device sessions

    4. test_1_1_chat_non_latin_messages_stack_update_profile_photo, id: 702745
    Device sessions

    5. test_1_1_chat_edit_message, id: 702855
    Device sessions

    6. test_1_1_chat_send_image_save_and_share, id: 703391
    Device sessions

    7. test_1_1_chat_pin_messages, id: 702731
    Device sessions

    8. test_1_1_chat_message_reaction, id: 702730
    Device sessions

    @shivekkhurana
    Copy link
    Contributor

    Finally <3

    image

    @ilmotta ilmotta force-pushed the ilmotta/preload-user-namespace branch from ff5db2a to c9544a9 Compare May 10, 2024 15:53
    @ilmotta ilmotta merged commit 225e3b1 into develop May 10, 2024
    6 checks passed
    @ilmotta ilmotta deleted the ilmotta/preload-user-namespace branch May 10, 2024 16:17
    ilmotta added a commit that referenced this pull request May 10, 2024
    ilmotta added a commit that referenced this pull request May 10, 2024
    Reverts the preloading mechanism from PR
    #19927, which introduced a
    problem I couldn't find any satisfactory solution. The namespaces user and
    dev.user were being preloaded by shadow-cljs, but the problem is that preloading
    will fail if those namespaces don't exist in your file system.
    
    I couldn't find any solution to conditionally preload namespaces via shadow-cljs
    and ClojureScript unfortunately doesn't support conditional requires like
    Clojure.
    
    At least we got to keep the code to not lint them and the whole idea to start to
    commit dev-only code inside src/dev/.
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    Archived in project
    Archived in project
    Development

    Successfully merging this pull request may close these issues.

    7 participants