-
-
Notifications
You must be signed in to change notification settings - Fork 314
Expand file tree
/
Copy pathtest-tailwindcss-integration.yml
More file actions
103 lines (85 loc) · 3.32 KB
/
Copy pathtest-tailwindcss-integration.yml
File metadata and controls
103 lines (85 loc) · 3.32 KB
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
96
97
98
99
100
101
102
103
name: TailwindCSS integration test
on:
pull_request:
branches:
- main
- 4-dev
push:
branches:
- main
- 4-dev
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
tailwindcss_integration_test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
repository: avo-hq/avo_tailwindcss_test_repo
ref: avo-1147/tailwindcss-integration
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: 22
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
bundler: default
ruby-version: 3.4.8
- name: Add Avo
run: |
# ruby/setup-ruby with bundler-cache runs Bundler in a frozen/deployment-like mode.
# This step intentionally changes the Gemfile.lock, so we must unfreeze Bundler here.
bundle config set frozen false
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 custom tool
run: |
bin/rails generate avo:tool custom_tool
- name: Add Tailwind test inputs
run: |
# Classes from the host app views must be picked up by Avo's Tailwind v4 build.
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
# Host app stylesheets under app/assets/stylesheets/avo/*.css must also be included.
mkdir -p ./app/assets/stylesheets/avo
cat <<'EOF' > ./app/assets/stylesheets/avo/integration_test.css
.ci-avo-host-stylesheet {
color: rebeccapurple;
}
EOF
- 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
compiled_file = File.join(File.dirname(__FILE__), "app", "assets", "builds", "avo", "application.css")
if File.exist?(compiled_file)
File.read(compiled_file)
else
raise "Compiled file '#{compiled_file}' not found."
end
end
# Classes present in custom_tool.html.erb and unlikely to be present 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
raise "Failed to find host Avo stylesheet marker class." unless contents.include?("ci-avo-host-stylesheet")
puts "[Avo->] Found ci-avo-host-stylesheet."
write-mode: append
- name: Run test
run: |
ruby ${{github.workspace}}/test.rb