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

Browser working from git source #1187

Merged
merged 10 commits into from
Sep 15, 2022
Merged

Browser working from git source #1187

merged 10 commits into from
Sep 15, 2022

Conversation

mostlyobvious
Copy link
Member

@mostlyobvious mostlyobvious commented Sep 11, 2021

It was never possible to use rails_event_store from git source and have a functioning browser:
#583.

gem 'rails_event_store', github: 'RailsEventStore/rails_event_store', branch: 'store-ci-assets'

We only version sources. Assets are bundled and baked into released browser gem.

Yet, with little help of:

  • CI building assets out of every pushed commit
  • S3 storing each of built assets and making them addressable by sha/name
  • Cloudfront CDN making fetching assets quick
  • Bundler letting us know that activated gem comes from git

we're finally able to make this surprise thing of a past. Also unblock some early adopters 😀

That's mostly proof of concept. It works but needs rewrite, and actually building assets of all pushed commits, not only the last one.

Seeing is believing:

 $LOAD_PATH.select { |x| x.end_with? "ruby_event_store-browser/lib" }
=> ["/Users/mostlyobvious/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/bundler/gems/rails_event_store-151d0dfbec24/ruby_event_store-browser/lib"]
http://d3iay4bmfswobf.cloudfront.net/151d0dfbec24/ruby_event_store_browser.css

Zrzut ekranu 2021-09-12 o 22 38 08

Zrzut ekranu 2021-09-12 o 22 54 06

What do you think?

@mostlyobvious mostlyobvious force-pushed the store-ci-assets branch 10 times, most recently from 151d0df to eb5093d Compare September 12, 2021 20:35
@mostlyobvious mostlyobvious changed the title Action to build and store assets on CI Browser working from git source Sep 12, 2021
@mostlyobvious mostlyobvious changed the title Browser working from git source POC: Browser working from git source Sep 12, 2021
@jandudulski
Copy link
Contributor

What's stopping us here?

@mostlyobvious
Copy link
Member Author

What's stopping us here?

Probably one more rebase since I had to resurrect separate CSS assets for [#1346] 🙃

I'd love to have it to experiment with some browser ideas on more production-like data!

@mostlyobvious mostlyobvious changed the title POC: Browser working from git source Browser working from git source Sep 14, 2022
On every push we bulld browser JS and CSS files. These are uploaded as
artifacts as a result of the build. There's not much use of these
artifacts other than seeing the output of the source on particular
commit.
In order to be able to use assets built per commit, they have to have
guessable URL. By design github action artifact URLs are not.

We send assets to S3 bucket, connected to Cloudfront CDN. Assets are
prefixed by commit SHA, which makes their URL guessable.

Short, 12-char SHA are in use to match with those used by Bundler in gem
paths:
https://github.com/rubygems/bundler/blob/35be6d9a603084f719fec4f4028c18860def07f6/lib/bundler/source/git.rb#L275-L281
When you use ruby_event_store-browser gem from git source, it lacks CSS
and JS that built just before packaging gem.

We're not versioning output files, only the source.

In this commit we're enabling reaching for CDN hosted assets, that are
built for every commit, when local assets are not available. This makes
browser work, even when RES is used from git source.

Related:
#583
Not the most elegant but works.
Now we explicitly check if gem is from git-via-bundler, so presence of
files should no longer be relevant for the logic.
@mostlyobvious
Copy link
Member Author

not to myself: alias CDN domain

@mostlyobvious mostlyobvious merged commit c8983c9 into master Sep 15, 2022
@mostlyobvious mostlyobvious deleted the store-ci-assets branch September 15, 2022 09:49
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