8000 RFC: Consistent scripts to rule them all by haacked · Pull Request #309 · PostHog/meta · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

RFC: Consistent scripts to rule them all #309

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

haacked
Copy link
@haacked haacked commented Apr 15, 2025

Proposal for adopting and adapting a consistent set of scripts across our OSS repositories:

Being able to get from git clone to an up-and-running project in a development environment is imperative for fast, reliable contributions.

Proposal for adopting and adapting a consistent set of scripts across our OSS repositories:

> Being able to get from git clone to an up-and-running project in a development environment is imperative for fast, reliable contributions.
Copy link
@timgl timgl left a comment

Choose a reason for hiding this comment

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

I like it

Copy link
Member
@rafaeelaudibert rafaeelaudibert left a comment

Choose a reason for hiding this comment

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

+1 from me, but suggest we keep the bin folder for now. If we ever have to build something we can use out

haacked added a commit to PostHog/posthog-ios that referenced this pull request Apr 18, 2025
See PostHog/meta#309 for con
8000
text.

## Solution

Adopt and adapt GitHub's approach of [scripts to rule them all](https://github.blog/engineering/engineering-principles/scripts-to-rule-them-all/) to
Copy link
Member

Choose a reason for hiding this comment

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

TIL github approach for scripts

Comment on lines +54 to +55
My recommendation is to still standardize on `bin` scripts so that it's consistent across the board. Some of the bin scripts are pretty complicated and it'll be hard to port to `make`.
If some repos have `make` files, that's fine. The bin scripts can call the `make` commands.
Copy link
Member
@marandaneto marandaneto Apr 19, 2025

Choose a reason for hiding this comment

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

the only downside here is that we have a bit of duplication (which is fine since only Mobile has the make files anyway)

* `bin/build` - Build the project, for projects that are compiled such as C#, Java, etc.
* `bin/start` - Start the project. For SDKs, this might start an example server.
* `bin/test` - Run tests (Ex. `npm test`, `bundle exec rspec`, etc.). Also includes linting, formatting, etc.
* `bin/fmt` - Optional: Format/lint code. This can be called by `test`.
Copy link
Member

Choose a reason for hiding this comment

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

I think fmt and lint should be different tasks

Copy link
Author

Choose a reason for hiding this comment

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

Maybe lint should just go into the bin/build task? Hear me out.

It seems to me that linting for a dynamic language serves a similar purpose to compilation in a compiled language in that it points out obvious errors.

So for a language like python, bin/build could run both mypy and flake8. Thoughts?

Copy link
Author

Choose a reason for hiding this comment

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

I'm open to just having it be a separate script as well.

Copy link
Member

Choose a reason for hiding this comment

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

I think for speedy, i prefer the lint to be its own thing, but it really depends on the tooling.
what i did in the past and worked really well is that i have a cmd for each step (fmt, lint, etc), and a cmd that does it all (eg build) that will run all its dependencies (fmt lint, etc).
eg https://github.com/PostHog/posthog-android/blob/9906ac8ac333a0e4990b64dceeca892453d81303/Makefile#L6-L7
^ runs everything else, so in CI I just do that, but locally if i want to check something, i can just make format

Copy link
Author

Choose a reason for hiding this comment

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

I like that! I think what this "spec" will define is a recommended minimum set of scripts. So if you only have build, it should do all these things. But you can optionally break down build into multiple steps, each with their own script. That's a pretty good pattern for this.


* What other scripts do we need?
* What should the scripts be named?
* Should we use `bin` or something else?
Copy link
Member

Choose a reason for hiding this comment

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

I'd rather use just scripts, bin is used by some other languages/frameworks (eg a dart project will have its executable and other entry points in the bin folder) as part of the folder structure and our scripts will be among many different files, a bit confusing

Copy link
Author

Choose a reason for hiding this comment

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

I'll let you and @rafaeelaudibert debate bin vs scripts. 😆

Copy link
Member

Choose a reason for hiding this comment

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

I vouched for bin because we're already using and I don't wanna hurt our muscle memory.

It is true bin is used in stuff like Ruby/Rails as well to include default scripts, but isn't this just the same as we already have here? The only difference is that they might have some extra files inside bin that don't exist in Django/JS land, for example

If that's not the case, and they're more than just scripts, I'm fine changing to scripts. it will hurt in the short-term, but it doesnt really matter in the long-term

Copy link
Member

Choose a reason for hiding this comment

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

Some languages/frameworks have bin as part of .gitignore btw, you'd need to remove from gitignore and add all the other files that should not be checked under the source control.
no strong opinions here, I just think that scripts would be cleaner and avoid this known pitfall.
for muscle memory, you could either set up your own alias or even have a symbolic file linked to the correct one so if you do eg ./lint in the root folder, it just works it does not matter if its within the bin or scripts really

@marandaneto
Copy link
Member

nice, thanks for the initiative @haacked
As you mentioned, I did that with the mobile SDKs using makefiles (more common for mobile development), so I can't agree more.

@marandaneto marandaneto requested a review from a team April 19, 2025 06:01
* `script/cibuild` - used by the CI system to run tests, build, etc.
* `script/console` - is used to open a console for your application.

## Design
Copy link
Member

Choose a reason for hiding this comment

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

Love the idea!

I'd love to also standardise the release process for new versions of a library, I don't think you need to do that in this PR though

Copy link
Author

Choose a reason for hiding this comment

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

I'd love to also standardise the release process for new versions of a library, I don't think you need to do that in this PR though

Same! It's on my list of things to do. With RELEASING, I think I'll document the many ways we do it today and propose a couple ideas for how we can consolidate it into a common approach. Obviously, not all things can be released in exactly the same way, but we can probably come up with a framework for releasing things that's fairly consistent.

Copy link
Member

Choose a reason for hiding this comment

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

You can inspire from (or even use it) https://github.com/getsentry/craft
We built craft at sentry exactly for this reason

Copy link
Member

Choose a reason for hiding this comment

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

I'd also recommend having the release and contributing markdown in the repos
eg https://github.com/PostHog/posthog-android/blob/main/RELEASING.md
https://github.com/PostHog/posthog-android/blob/main/CONTRIBUTING.md
so that open source contributors (and new employees) know how to build, run, and release things.

ioannisj pushed a commit to PostHog/posthog-ios that referenced this pull request Apr 23, 2025
* Add bin scripts

See PostHog/meta#309 for context.

* Reimplement `isfeatureEnabled` using `getFeatureFlag`

Changes `isFeatureEnabled` to delegate to `getFeatureFlag` in order to get the result. This ensures that the `$feature_flag_called` event sends the correct `$feature_flag_response`.

Fixes #336

* Add changelog entry

* Remove unused method and update tests

* Update date in CHANGELOG.md

Co-authored-by: Manoel Aranda Neto <5731772+marandaneto@users.noreply.github.com>

---------

Co-authored-by: Manoel Aranda Neto <5731772+marandaneto@users.noreply.github.com>
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
0