-
-
Notifications
You must be signed in to change notification settings - Fork 519
107 lines (98 loc) · 2.88 KB
/
main.yml
File metadata and controls
107 lines (98 loc) · 2.88 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
104
105
106
107
name: CI
on:
push:
branches:
- main
pull_request:
jobs:
build:
runs-on: ubuntu-latest
name: Ruby ${{ matrix.ruby }}
strategy:
matrix:
ruby:
- '3.4.7'
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- name: Run the default task
run: bundle exec rake
test-template:
runs-on: ubuntu-latest
services:
postgres:
image: postgres
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
ports:
- 5432:5432
options: --health-cmd="pg_isready" --health-interval=10s --health-timeout=5s --health-retries=3
redis:
image: valkey/valkey:8
ports:
- 6379:6379
options: --health-cmd "redis-cli ping" --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- name: Checkout template
uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.4.7'
bundler-cache: false
- name: Install Rails
run: gem install rails
- name: Install dependencies
run: bundle install
- name: Install Suspenders
run: bundle exec rake install
- name: Generate new Rails app with template
run: |
cd /tmp
suspenders new test_app
- name: Set up generated app
env:
DATABASE_URL: postgres://postgres:postgres@localhost:5432
working-directory: /tmp/test_app
run: |
bundle install
bin/setup --skip-server
bin/rails db:migrate
bundle add high_voltage
mkdir app/views/pages
touch app/views/pages/home.html.erb
echo '<h1>Hello World!</h1>' >> app/views/pages/home.html.erb
touch spec/system/demo_system_spec.rb
cat << 'EOF' >> spec/system/demo_system_spec.rb
require "rails_helper"
RSpec.describe "Static page", type: :system do
it "passes" do
visit "/pages/home"
expect(page).to have_text("Hello World!")
end
end
EOF
- name: Run tests in generated app
env:
RAILS_ENV: test
DATABASE_URL: postgres://postgres:postgres@localhost:5432
working-directory: /tmp/test_app
run: |
bin/rails db:setup
bin/rails spec
- name: Verify app can start
env:
DATABASE_URL: postgres://postgres:postgres@localhost:5432
REDIS_URL: redis://localhost:6379/0
working-directory: /tmp/test_app
run: |
timeout 10 bin/dev > /dev/null 2>&1 &
sleep 5
curl -f http://localhost:3000 || exit 1