Skip to content

Commit

Permalink
feat: update mrml and set up github action matrix (#44)
Browse files Browse the repository at this point in the history
* feat: update mrml and set up github action matrix

* feat: add rust matrix

* fix

* fixes
  • Loading branch information
jnylen authored Nov 3, 2022
1 parent 2b35fe4 commit 017a02e
Show file tree
Hide file tree
Showing 10 changed files with 84 additions and 162 deletions.
72 changes: 38 additions & 34 deletions .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,38 +9,42 @@ on:
jobs:
build:
name: ruby
runs-on: ubuntu-latest

strategy:
matrix:
os: [ubuntu-latest, macos-latest]
ruby: ["2.7", "3.0", "3.1"]
rust: ["1.51.0", "1.54.0", "1.60.0", "1.62.1", "1.65.0"]
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v2
with:
persist-credentials: false
- name: Read .tool-versions
uses: marocchino/tool-versions-action@v1
id: versions
- name: Set up Ruby
uses: ruby/setup-ruby@v1
- name: Set up Rust
uses: hecrj/setup-rust-action@v1
with:
rust-version: ${{ steps.versions.outputs.rust}}
- name: Cache gems
uses: actions/cache@v1
with:
path: vendor/bundle
key: ${{ runner.os }}-gems-${{ hashFiles('.tool-versions') }}-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: |
${{ runner.os }}-gems-${{ hashFiles('.tool-versions') }}-${{ hashFiles('**/Gemfile.lock') }}
- name: Run yarn
run: yarn
- name: Install dependencies
run: |
gem install bundler
bundle config path vendor/bundle
bundle install --jobs 4 --retry 3
env:
RAILS_ENV: test
- name: Run tests
run: bundle exec rake spec
env:
RAILS_ENV: test
- uses: actions/checkout@v2
with:
persist-credentials: false
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
- name: Set up Rust
uses: hecrj/setup-rust-action@v1
with:
rust-version: ${{ matrix.rust }}
- name: Cache gems
uses: actions/cache@v1
with:
path: vendor/bundle
key: ${{ runner.os }}-gems-${{ hashFiles('.tool-versions') }}-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: |
${{ runner.os }}-gems-${{ hashFiles('.tool-versions') }}-${{ hashFiles('**/Gemfile.lock') }}
- name: Run yarn
run: yarn
- name: Install dependencies
run: |
gem install bundler
bundle config path vendor/bundle
bundle install --jobs 4 --retry 3
env:
RAILS_ENV: test
- name: Run tests
run: bundle exec rake spec
env:
RAILS_ENV: test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@
# rspec failure tracking
.rspec_status
*.gem
Gemfile.lock
4 changes: 2 additions & 2 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
ruby 2.7.5
rust 1.59.0
ruby 3.1.2
rust 1.65.0
120 changes: 0 additions & 120 deletions Gemfile.lock

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE.txt → LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2021 Joakim Nylén
Copyright (c) 2021-2022 Joakim Nylén, Odd Camp AB

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

`mrml-rails` is a ActionMailer templating engine that uses the Rust-based MRML compiler in order to compile MJML files into pure HTML.

**Minimum Rust version supported is `1.51.0`**

## Installation

Add this line to your application's Gemfile:
Expand Down Expand Up @@ -36,7 +38,7 @@ I.e.: `sign_up.mjml`, `notification.mjml`
2. Add a RustConfig with:

```
VERSION=1.57.0
VERSION=1.65.0
RUST_SKIP_BUILD=1
```

Expand Down
3 changes: 2 additions & 1 deletion lib/mrml/rails/handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ def call(template, source = nil)
end

if compiled_source =~ /<mjml.*?>/i
"MRML.to_html(begin;#{compiled_source};end).html_safe"
# "MRML.to_html(begin;#{compiled_source};end).html_safe"
"MRML::Template.new(begin;#{compiled_source};end).to_html"
else
compiled_source
end
Expand Down
2 changes: 1 addition & 1 deletion mrml-rails.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
spec.metadata['changelog_uri'] = 'https://github.com/oddcamp/mrml-rails/releases'

spec.add_runtime_dependency 'actionmailer', '>= 3.1'
spec.add_runtime_dependency 'mrml', '>= 0.2', '< 0.9'
spec.add_runtime_dependency 'mrml', '~> 1.0'
spec.add_runtime_dependency 'railties', '>= 3.1'
spec.add_development_dependency 'rspec', '~> 3.10'
spec.add_development_dependency 'rspec-rails', '>= 4.0.2', '~> 5.0'
Expand Down
32 changes: 31 additions & 1 deletion spec/support/templates/layouts/mailer.mjml
Original file line number Diff line number Diff line change
@@ -1,5 +1,35 @@
<%
@font_family = 'Helvetica Neue'
%>

<mjml>
<mj-body>
<mj-head>
<mj-attributes>
<mj-all padding="0" font-family="<%= @font_family %>" />

<mj-text font-size="16px" />

<mj-table font-size="16px" />
</mj-attributes>

<mj-breakpoint width="640px" />

<mj-style>
ul {
list-style: none;
margin: 0;
padding: 0;
}

@media (max-width:640px) {
.hidden {
display: none !important;
}
}
</mj-style>
</mj-head>

<mj-body css-class="container" width="900px">
<%= yield %>
</mj-body>
</mjml>
6 changes: 5 additions & 1 deletion spec/support/templates/mrml_test_mailer/normal_email.mjml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
<%
text = 'something'
%>

<mjml>
<mj-body>
<mj-section>
Expand All @@ -7,7 +11,7 @@
</mj-section>
<mj-section>
<mj-column>
<h2>We inform you about something</h2>
<h2>We inform you about <%= text %></h2>
<p>Please visit <a href="https://www.example.com">this link</a></p>
</mj-column>
</mj-section>
Expand Down

0 comments on commit 017a02e

Please sign in to comment.