Skip to content

Commit ab501b4

Browse files
author
Mattia Roccoberton
authored
Merge pull request #21 from blocknotes/ruby-3.0-support
Ruby 3.0 support
2 parents a17a623 + 8db5a25 commit ab501b4

11 files changed

Lines changed: 98 additions & 68 deletions

File tree

.github/workflows/specs_mysql.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313

1414
strategy:
1515
matrix:
16-
ruby: ['2.6', '2.7']
16+
ruby: ['2.6', '2.7', '3.0']
1717
gemfile: ['rails_6_1_mysql', 'rails_6_0_mysql']
1818

1919
env:

.github/workflows/specs_mysql_rails7.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313

1414
strategy:
1515
matrix:
16-
ruby: ['2.7']
16+
ruby: ['2.7', '3.0']
1717
gemfile: ['rails_7_0_mysql']
1818

1919
env:

.github/workflows/specs_postgres.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313

1414
strategy:
1515
matrix:
16-
ruby: ['2.6', '2.7']
16+
ruby: ['2.6', '2.7', '3.0']
1717
gemfile: ['rails_6_1_postgres', 'rails_6_0_postgres']
1818

1919
env:

.github/workflows/specs_postgres_rails7.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313

1414
strategy:
1515
matrix:
16-
ruby: ['2.7']
16+
ruby: ['2.7', '3.0']
1717
gemfile: ['rails_7_0_postgres']
1818

1919
env:

extra/Dockerfile_26

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ RUN gem install bundler
88
# App setup
99
WORKDIR /usr/src/app
1010
COPY .. .
11-
RUN bundle install
1211

1312
# Setup the entrypoint script
1413
COPY extra/entrypoint.sh /usr/bin/

extra/Dockerfile_27

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ RUN apk add --no-cache --update build-base dpkg gcompat mysql-dev postgresql-dev
77
# App setup
88
WORKDIR /usr/src/app
99
COPY .. .
10-
RUN bundle install
1110

1211
# Setup the entrypoint script
1312
COPY extra/entrypoint.sh /usr/bin/

extra/Dockerfile_30

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM ruby:3.0-alpine
2+
3+
ARG DB_TEST
4+
5+
RUN apk add --no-cache --update build-base dpkg gcompat mysql-dev postgresql-dev tzdata
6+
7+
# App setup
8+
WORKDIR /usr/src/app
9+
COPY .. .
10+
11+
# Setup the entrypoint script
12+
COPY extra/entrypoint.sh /usr/bin/
13+
RUN chmod +x /usr/bin/entrypoint.sh
14+
15+
ENTRYPOINT ["entrypoint.sh"]

extra/docker-compose.yml

Lines changed: 65 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,15 @@
22
version: "3.3"
33

44
x-defaults:
5-
tests: &base_tests
6-
environment: &base_enviroment
5+
tests_mysql: &tests_mysql
6+
environment:
77
CI: 1
8+
DB_TEST: mysql
9+
DB_PORT: 3306
10+
MYSQL_DB_HOST: mysql
11+
MYSQL_DB_NAME: test_db
12+
MYSQL_DB_USERNAME: root
13+
MYSQL_DB_PASSWORD: password
814
RAILS_ENV: test
915
command:
1016
- sh
@@ -17,6 +23,36 @@ x-defaults:
1723
bin/setup
1824
cd ../..
1925
bin/rspec
26+
volumes:
27+
- ..:/usr/src/app:delegated
28+
depends_on:
29+
- mysql
30+
31+
tests_postgres: &tests_postgres
32+
environment:
33+
CI: 1
34+
DB_TEST: postgres
35+
DB_PORT: 5432
36+
PG_DB_HOST: postgres
37+
PG_DB_NAME: test_db
38+
PG_DB_USERNAME: postgres
39+
PG_DB_PASSWORD: password
40+
RAILS_ENV: test
41+
command:
42+
- sh
43+
- -c
44+
- |
45+
while ! nc -z $${DB_TEST} $${DB_PORT} </dev/null
46+
do echo "Waiting for DB ($${DB_TEST})..." && sleep 5; done
47+
echo "DB is now available!"
48+
cd spec/dummy
49+
bin/setup
50+
cd ../..
51+
bin/rspec
52+
volumes:
53+
- ..:/usr/src/app:delegated
54+
depends_on:
55+
- postgres
2056

2157
services:
2258
postgres:
@@ -30,74 +66,50 @@ services:
3066
environment:
3167
MYSQL_ROOT_PASSWORD: password
3268

33-
tests_26_pg:
34-
<<: *base_tests
69+
tests_26_mysql:
70+
<<: *tests_mysql
3571
build:
3672
context: ..
37-
dockerfile: extra/Dockerfile_27
73+
dockerfile: extra/Dockerfile_26
3874
args:
39-
DB_TEST: postgres
40-
environment:
41-
<<: *base_enviroment
42-
DB_TEST: postgres
43-
DB_PORT: 5432
44-
PG_DB_HOST: postgres
45-
PG_DB_NAME: postgres_26
46-
PG_DB_USERNAME: postgres
47-
PG_DB_PASSWORD: password
48-
depends_on:
49-
- postgres
75+
DB_TEST: mysql
5076

51-
tests_26_mysql:
52-
<<: *base_tests
77+
tests_26_postgres:
78+
<<: *tests_postgres
5379
build:
5480
context: ..
5581
dockerfile: extra/Dockerfile_26
82+
args:
83+
DB_TEST: postgres
84+
85+
tests_27_mysql:
86+
<<: *tests_mysql
87+
build:
88+
context: ..
89+
dockerfile: extra/Dockerfile_27
5690
args:
5791
DB_TEST: mysql
58-
environment:
59-
<<: *base_enviroment
60-
DB_TEST: mysql
61-
DB_PORT: 3306
62-
MYSQL_DB_HOST: mysql
63-
MYSQL_DB_NAME: mysql_26
64-
MYSQL_DB_USERNAME: root
65-
MYSQL_DB_PASSWORD: password
66-
depends_on:
67-
- mysql
6892

69-
tests_27_pg:
70-
<<: *base_tests
93+
tests_27_postgres:
94+
<<: *tests_postgres
7195
build:
7296
context: ..
7397
dockerfile: extra/Dockerfile_27
7498
args:
7599
DB_TEST: postgres
76-
environment:
77-
<<: *base_enviroment
78-
DB_TEST: postgres
79-
DB_PORT: 5432
80-
PG_DB_HOST: postgres
81-
PG_DB_NAME: postgres_27
82-
PG_DB_USERNAME: postgres
83-
PG_DB_PASSWORD: password
84-
depends_on:
85-
- postgres
86100

87-
tests_27_mysql:
88-
<<: *base_tests
101+
tests_30_mysql:
102+
<<: *tests_mysql
89103
build:
90104
context: ..
91-
dockerfile: extra/Dockerfile_27
105+
dockerfile: extra/Dockerfile_30
92106
args:
93107
DB_TEST: mysql
94-
environment:
95-
<<: *base_enviroment
96-
DB_TEST: mysql
97-
DB_PORT: 3306
98-
MYSQL_DB_HOST: mysql
99-
MYSQL_DB_NAME: mysql_27
100-
MYSQL_DB_USERNAME: root
101-
MYSQL_DB_PASSWORD: password
102-
depends_on:
103-
- mysql
108+
109+
tests_30_postgres:
110+
<<: *tests_postgres
111+
build:
112+
context: ..
113+
dockerfile: extra/Dockerfile_30
114+
args:
115+
DB_TEST: postgres

lib/active_storage/service/db_service.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
module ActiveStorage
44
class Service::DBService < Service
5-
def initialize(**_options)
5+
def initialize(**)
66
@chunk_size = ENV.fetch('ASDB_CHUNK_SIZE') { 1.megabytes }
77
end
88

spec/rails_helper.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
config.before(:suite) do
3838
intro = ('-' * 80)
3939
intro << "\n"
40+
intro << "- Ruby: #{RUBY_VERSION}\n"
4041
intro << "- Rails: #{Rails.version}\n"
4142
intro << "- ActiveStorage: #{ActiveStorage.version}\n"
4243
intro << "- DB_TEST: #{ENV['DB_TEST']}\n"

0 commit comments

Comments
 (0)