Skip to content

Make iOS update commands run in sequence instead of all at once#2024

Merged
ctkochan22 merged 4 commits into
masterfrom
Rory-iosUpdatePlistSynchronously
Mar 24, 2021
Merged

Make iOS update commands run in sequence instead of all at once#2024
ctkochan22 merged 4 commits into
masterfrom
Rory-iosUpdatePlistSynchronously

Conversation

@roryabraham

Copy link
Copy Markdown
Contributor

cc @tgolen because I reused a trick I saw you used in migrateOnyx to get these promises to run one after another instead of all at the same time (although in my case the order doesn't matter).

Details

My theory is that this workflow failed because we have multiple asynchronous commands attempting to read from and write to the same file at the same time. Ideas for how to verify that theory are welcome.

Fixed Issues

Fixes failed deploys

Tests

Not tested locally.

@roryabraham roryabraham requested a review from AndrewGable March 23, 2021 22:17
@roryabraham roryabraham self-assigned this Mar 23, 2021
@roryabraham roryabraham requested a review from a team as a code owner March 23, 2021 22:17
@botify botify requested review from ctkochan22 and removed request for a team March 23, 2021 22:17
Comment thread .github/actions/bumpVersion/index.js Outdated
exec(`/usr/libexec/PlistBuddy -c "Set :CFBundleVersion ${cfVersion}" ${PLIST_PATH}`),
exec(`/usr/libexec/PlistBuddy -c "Set :CFBundleVersion ${cfVersion}" ${PLIST_PATH_TEST}`),
]
.reduce((previousPromise, currentPromise) => previousPromise.then(() => currentPromise()), Promise.resolve());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Cool! This is sure ugly code 🧌 It would be cool to make this into a utility at some point that we can use whenever we need it. Seems like it should work well for you in this case!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Another possible cure for this would be to use execSync(): https://nodejs.org/api/child_process.html#child_process_child_process_execsync_command_options so that they run synchronously.

@tgolen tgolen Mar 23, 2021

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Oh, and also... I think exec() in the array is already starting all the promises all at once. The code you added just makes sure that they are resolved one at a time... So to really get what you want, I think you need to do something more like this:

const updateCommands = [
    `/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString ${shortVersion}" ${PLIST_PATH}`,
    `/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString ${shortVersion}" ${PLIST_PATH_TEST}`,
    `/usr/libexec/PlistBuddy -c "Set :CFBundleVersion ${cfVersion}" ${PLIST_PATH}`,
    `/usr/libexec/PlistBuddy -c "Set :CFBundleVersion ${cfVersion}" ${PLIST_PATH_TEST}`
]
.reduce((previousPromise, command) => previousPromise.then(() => exec(command)), Promise.resolve());;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ahhh yeah execSync seems like a much better choice for my use case! Thanks!

@roryabraham

Copy link
Copy Markdown
Contributor Author

Updated!

@tgolen

tgolen commented Mar 24, 2021

Copy link
Copy Markdown
Contributor

@ctkochan22 All you!

@ctkochan22 ctkochan22 merged commit 03d513f into master Mar 24, 2021
@ctkochan22 ctkochan22 deleted the Rory-iosUpdatePlistSynchronously branch March 24, 2021 21:41
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.

4 participants