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

feat: create script to download and then execute local binary tools #1

Merged
merged 4 commits into from
Sep 18, 2023

Conversation

levibostian
Copy link
Contributor

@levibostian levibostian commented Sep 14, 2023

TL;DR - this is a tool as part of fall cleaning. It fixes a problem our iOS SDK has where all mobile engineers and CI server uses different versions of tools such as swiftlint, swiftformat, and sourcery. When computers are on different versions of these tools, PRs are harder to review and weird linting errors can occur. This tool is a way to make sure that everyone is on the same hard-coded version of each tool. Bonus: The tool actually installs and updates all of these tools for you meaning that setup of our SDK development environment is simplified!

This PR contains the code for a new tool to use in the iOS SDK as described in the fall cleaning project description.

The script contains some comments at the top of the file and this readme PR also explains the tool in more detail.

Why is this project inside of it's own github repo instead of the iOS SDK repo?

  • So the tool can be re-used by multiple projects more easily.
  • This tool has a different deployment strategy compared to the iOS SDK. The benefit we gain is: this script can be compiled into a binary that team members install into their machine and executed without having to install any dependencies.

@levibostian levibostian marked this pull request as ready for review September 14, 2023 18:46
@levibostian levibostian requested a review from a team September 14, 2023 18:50
@levibostian levibostian changed the title create script to download and then execute local binary tools feat: create script to download and then execute local binary tools Sep 14, 2023
Copy link

@Shahroz16 Shahroz16 left a comment

Choose a reason for hiding this comment

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

I couldn't find it in the notion or readme What is the version update strategy like for tools (swift lint etc)? e.g. where does the binny-tools.yml live?

EDIT: Found in another PR for readme.

const downloadedZipFilePath = `/tmp/${tool.name}_${tool.version}.zip`; // We save the tool into the /tmp directory as we do not need it after we unzip the file.

// download zip file into the /tmp directory
const response = await fetch(downloadZipUrl);

Choose a reason for hiding this comment

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

Whats the strategy if this network call fails/times out and it doesn't return in success? should we have exception handling?

Copy link
Contributor Author

@levibostian levibostian Sep 15, 2023

Choose a reason for hiding this comment

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

Because this tool is only used as an internal tool at the moment and I believe that network request errors would be rare, I decided to put in less error handling into the tool, such as this scenario.

Therefore, at this time, if a network connection fails the tool will throw an exception and display the stacktrace in the terminal.

Choose a reason for hiding this comment

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

As long as this doesn't hurt us while working with CI, I honestly hate CI failing us because of some issues and then coming back to it and fixing it. But yeah not a blocker at all.

Copy link
Contributor Author

@levibostian levibostian Sep 18, 2023

Choose a reason for hiding this comment

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

That is a good point. I also want the CI to be stable while using this tool.

I see it being a rare occurrence for the CI to encounter failures for this line of code. Especially because the CI running on GitHub servers is downloading .zip files from GitHub, even more rare.

If you have any scenarios that you can think of on the CI that would make this script fail often, please share it as I would consider that a bug.

binny.ts Show resolved Hide resolved
binny.ts Show resolved Hide resolved
@levibostian levibostian requested review from Shahroz16 and a team September 15, 2023 15:06
const downloadedZipFilePath = `/tmp/${tool.name}_${tool.version}.zip`; // We save the tool into the /tmp directory as we do not need it after we unzip the file.

// download zip file into the /tmp directory
const response = await fetch(downloadZipUrl);

Choose a reason for hiding this comment

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

As long as this doesn't hurt us while working with CI, I honestly hate CI failing us because of some issues and then coming back to it and fixing it. But yeah not a blocker at all.

@levibostian levibostian merged commit a7a9e50 into main Sep 18, 2023
@levibostian levibostian deleted the levi/script branch September 18, 2023 20:02
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.

2 participants