-
Notifications
You must be signed in to change notification settings - Fork 312
155 lines (137 loc) · 5.74 KB
/
rubyonrails.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
name: Ruby on Rails CI
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
jobs:
test:
runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref }}-test
cancel-in-progress: true
timeout-minutes: 10
services:
postgres:
image: postgres:16.1
ports:
- "5432:5432"
env:
POSTGRES_DB: hostedgpt_test
POSTGRES_USER: rails
POSTGRES_PASSWORD: password
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
RAILS_ENV: test
DATABASE_URL: "postgres://rails:password@localhost:5432/hostedgpt_test"
APP_URL_PROTOCOL: "http"
APP_URL_HOST: "localhost"
APP_URL_PORT: "3000"
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install ImageMagick
run: |
sudo apt-get update && sudo apt-get install -y imagemagick
sudo sed -i 's/rights="none" pattern="PDF"/rights="read|write" pattern="PDF"/' /etc/ImageMagick-6/policy.xml
sudo sed -i 's/<policy domain="coder" rights="none" pattern="PS" \/>/<policy domain="coder" rights="read|write" pattern="PS" \/>/' /etc/ImageMagick-6/policy.xml
sudo sed -i 's/<policy domain="coder" rights="none" pattern="EPS" \/>/<policy domain="coder" rights="read|write" pattern="EPS" \/>/' /etc/ImageMagick-6/policy.xml
sudo sed -i 's/<policy domain="coder" rights="none" pattern="PDF" \/>/<policy domain="coder" rights="read|write" pattern="PDF" \/>/' /etc/ImageMagick-6/policy.xml
sudo sed -i 's/<policy domain="coder" rights="none" pattern="XPS" \/>/<policy domain="coder" rights="read|write" pattern="XPS" \/>/' /etc/ImageMagick-6/policy.xml
sudo sed -i 's/<policy domain="path" rights="none" pattern="@\*" \/>/<policy domain="path" rights="read|write" pattern="@\*" \/>/' /etc/ImageMagick-6/policy.xml
- uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- name: Set up database schema
run: bin/rails db:prepare
- name: Build CSS
run: bin/rails tailwindcss:build
- name: Run tests
run: bin/rails test
system_tests:
if: github.repository == 'AllYourBot/hostedgpt'
runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref }}-system
cancel-in-progress: true
services:
postgres:
image: postgres:16.1
ports:
- "5432:5432"
env:
POSTGRES_DB: hostedgpt_test
POSTGRES_USER: rails
POSTGRES_PASSWORD: password
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
RAILS_ENV: test
DATABASE_URL: "postgres://rails:password@localhost:5432/hostedgpt_test"
APP_URL_PROTOCOL: "http"
APP_URL_HOST: "localhost"
APP_URL_PORT: "3000"
DISPLAY: "=:99"
CHROME_VERSION: "127.0.6533.119"
steps:
- name: Install Chrome
run: |
# Download specific Chrome version
wget https://dl.google.com/linux/chrome/deb/pool/main/g/google-chrome-stable/google-chrome-stable_${CHROME_VERSION}-1_amd64.deb
# Install Chrome
sudo apt-get install -y --allow-downgrades ./google-chrome-stable_${CHROME_VERSION}-1_amd64.deb
- uses: nanasess/setup-chromedriver@v2
- name: Start chromedriver
run: |
set -x
chromedriver --url-base=/wd/hub &
# sudo Xvfb -ac :99 -screen 0 1280x1024x24 > /dev/null 2>&1 & # optional
- name: Checkout code
uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- name: Install ImageMagick
run: |
sudo apt-get update && sudo apt-get install -y imagemagick
sudo sed -i 's/rights="none" pattern="PDF"/rights="read|write" pattern="PDF"/' /etc/ImageMagick-6/policy.xml
sudo sed -i 's/<policy domain="coder" rights="none" pattern="PS" \/>/<policy domain="coder" rights="read|write" pattern="PS" \/>/' /etc/ImageMagick-6/policy.xml
sudo sed -i 's/<policy domain="coder" rights="none" pattern="EPS" \/>/<policy domain="coder" rights="read|write" pattern="EPS" \/>/' /etc/ImageMagick-6/policy.xml
sudo sed -i 's/<policy domain="coder" rights="none" pattern="PDF" \/>/<policy domain="coder" rights="read|write" pattern="PDF" \/>/' /etc/ImageMagick-6/policy.xml
sudo sed -i 's/<policy domain="coder" rights="none" pattern="XPS" \/>/<policy domain="coder" rights="read|write" pattern="XPS" \/>/' /etc/ImageMagick-6/policy.xml
sudo sed -i 's/<policy domain="path" rights="none" pattern="@\*" \/>/<policy domain="path" rights="read|write" pattern="@\*" \/>/' /etc/ImageMagick-6/policy.xml
- name: Set up database schema
run: bin/rails db:prepare
- name: Build CSS
run: bin/rails tailwindcss:build
- name: Run system tests
run: |
sed -i 's/hoverOnlyWhenSupported: true/hoverOnlyWhenSupported: false/' config/tailwind.config.js
PARALLEL_WORKERS=2 bin/rails test:system
- name: Upload screenshots
uses: actions/upload-artifact@v4
if: failure()
with:
name: System Test Screenshots
path: tmp/screenshots/
if-no-files-found: ignore
lint:
runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref }}-lint
cancel-in-progress: true
steps:
- name: Checkout code
uses: actions/checkout@v3
- uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- name: Lint Ruby files
run: bin/rubocop