-
-
Notifications
You must be signed in to change notification settings - Fork 256
95 lines (78 loc) · 2.99 KB
/
test-tailwindcss-integration.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
name: TailwindCSS integration test
on:
pull_request:
branches:
- main
push:
branches:
- main
jobs:
tailwindcss_integration_test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
repository: avo-hq/avo_tailwindcss_test_repo
- uses: actions/cache@v3
with:
path: vendor/bundle
key: ${{ runner.os }}-test-gems-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: |
${{ runner.os }}-test-gems-${{ hashFiles('**/Gemfile.lock') }}
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
bundler: default
ruby-version: 3.3.0
- name: Bundle install
run: |
bundle config path vendor/bundle
bundle install --jobs 4 --retry 3
- name: Add Avo
run: |
bundle add "avo" --git='https://github.com/avo-hq/avo.git' --ref="${{ github.sha }}"
bundle install
bin/rails generate avo:install
bundle exec rake avo:build-assets
- name: Add the TailwindCSS integration
run: |
yarn init --yes
bin/rails generate avo:tailwindcss:install
bin/rails generate avo:tool custom_tool
- name: Add custom CSS
run: |
echo '<div class="aspect-video break-before-avoid float-end order-9 col-end-13 box-decoration-slice bg-gradient-to-r from-indigo-600 to-pink-500 text-white text-2xl font-bold">Test<br>DIV</div>' >> ./app/views/avo/tools/custom_tool.html.erb
- name: Compile assets
run: |
bundle exec rake assets:precompile
- name: Write test file
uses: DamianReeves/write-file-action@master
with:
path: ${{github.workspace}}/test.rb
contents: |
#!/usr/bin/env ruby
def get_compiled_file_contents
asset_name = 'avo.tailwind'
compiled_assets_path = File.join(File.dirname(__FILE__), 'public', 'assets').to_s
# Find the compiled file with a matching name
compiled_file = Dir[File.join(compiled_assets_path, "#{asset_name}-*")].first
# Read the contents of the file, if it exists
if compiled_file
File.read(compiled_file)
else
# Handle the case where the file is not found
raise "Compiled file for '#{asset_name}' not found."
end
end
# Classes that are available in custom_tool.html.erb and most likely not available in the base Avo bundle
test_classes = %w(aspect-video break-before-avoid float-end order-9 col-end-13 box-decoration-slice bg-gradient-to-r from-indigo-600 to-pink-500)
contents = get_compiled_file_contents
# Test if the built assets containe these classes
test_classes.each do |class_name|
raise "Failed to find the custom classes." unless contents.include?(class_name)
puts "[Avo->] Found #{class_name}."
end
write-mode: append
- name: Run test
run: |
ruby ${{github.workspace}}/test.rb