Skip to content

Commit 1d869bc

Browse files
dblockCopilot
andcommitted
Modernize CI and add Ruby 4 and Grape 4 coverage
Retain existing compatibility combinations while adding current ORM/database versions, native service containers, dependency caching, and maintained browser setup. Update pagination test query decoding for Ruby 4. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 2e8c460 commit 1d869bc

7 files changed

Lines changed: 108 additions & 67 deletions

File tree

‎.github/workflows/rubocop.yml‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
11
---
22
name: lint
33
on: [push, pull_request]
4+
permissions:
5+
contents: read
6+
concurrency:
7+
group: rubocop-${{ github.ref }}
8+
cancel-in-progress: true
49
jobs:
510
lint:
611
name: RuboCop
7-
runs-on: ubuntu-latest
12+
runs-on: ubuntu-24.04
13+
timeout-minutes: 10
814
steps:
9-
- uses: actions/checkout@v3
15+
- uses: actions/checkout@v7
1016
- name: Set up Ruby
1117
uses: ruby/setup-ruby@v1
1218
with:
13-
ruby-version: 3.4
19+
ruby-version: '4.0'
1420
bundler-cache: true
1521
- name: Run RuboCop
1622
run: bundle exec rubocop

‎.github/workflows/test-mongodb.yml‎

Lines changed: 41 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,54 @@
11
---
2-
name: test
2+
name: MongoDB
33
on: [push, pull_request]
4+
permissions:
5+
contents: read
6+
concurrency:
7+
group: mongodb-${{ github.ref }}
8+
cancel-in-progress: true
49
jobs:
510
test:
6-
runs-on: ubuntu-latest
11+
runs-on: ubuntu-24.04
12+
timeout-minutes: 20
13+
env:
14+
DATABASE_ADAPTER: mongoid
15+
MONGOID_VERSION: ${{ matrix.entry.mongoid }}
16+
GRAPE_VERSION: ${{ matrix.entry.grape || '>= 0' }}
717
strategy:
18+
fail-fast: false
819
matrix:
920
entry:
10-
- { ruby: 3.2, mongoid: 6.4.8, mongodb: 4.4 }
11-
- { ruby: 3.2, mongoid: 7.2.3, mongodb: 4.4 }
12-
- { ruby: 3.2, mongoid: 7.3.0, mongodb: 4.4 }
13-
- { ruby: 3.2, mongoid: 7.3.0, mongodb: 4.4 }
14-
- { ruby: 3.3, mongoid: 7.3.0, mongodb: 5.0 }
15-
- { ruby: 3.4, mongoid: 7.5.2, mongodb: 5.0 }
16-
- { ruby: 3.4, mongoid: 8.1.11, mongodb: 6.0 }
17-
- { ruby: 3.4, mongoid: 8.1.11, mongodb: 7.0 }
18-
- { ruby: 3.4, mongoid: 8.1.11, mongodb: 8.0 }
19-
name: test (ruby=${{ matrix.entry.ruby }}, mongoid=${{ matrix.entry.mongoid }}, mongodb=${{ matrix.entry.mongodb }})
21+
- { ruby: '3.2', mongoid: '6.4.8', mongodb: '4.4' }
22+
- { ruby: '3.2', mongoid: '7.2.3', mongodb: '4.4' }
23+
- { ruby: '3.2', mongoid: '7.3.0', mongodb: '4.4' }
24+
- { ruby: '3.3', mongoid: '7.3.0', mongodb: '5.0' }
25+
- { ruby: '3.4', mongoid: '7.5.2', mongodb: '5.0' }
26+
- { ruby: '3.4', mongoid: '8.1.11', mongodb: '6.0' }
27+
- { ruby: '3.4', mongoid: '8.1.11', mongodb: '7.0' }
28+
- { ruby: '3.4', mongoid: '8.1.11', mongodb: '8.0' }
29+
- { ruby: '3.3', mongoid: '~> 9.1', mongodb: '8.0', grape: '~> 3.2' }
30+
- { ruby: '3.4', mongoid: '~> 9.1', mongodb: '8.0', grape: '~> 4.0' }
31+
- { ruby: '4.0', mongoid: '~> 9.1', mongodb: '8.0', grape: '~> 4.0' }
32+
name: test (ruby=${{ matrix.entry.ruby }}, mongoid=${{ matrix.entry.mongoid }}, mongodb=${{ matrix.entry.mongodb }}, grape=${{ matrix.entry.grape || 'auto' }})
33+
services:
34+
mongodb:
35+
image: mongo:${{ matrix.entry.mongodb }}
36+
ports:
37+
- 27017:27017
38+
options: >-
39+
--health-cmd "mongosh --quiet --eval 'db.adminCommand({ ping: 1 })' || mongo --quiet --eval 'db.adminCommand({ ping: 1 })'"
40+
--health-interval 10s
41+
--health-timeout 5s
42+
--health-retries 10
2043
steps:
21-
- uses: actions/checkout@v2
44+
- uses: actions/checkout@v7
2245
- uses: ruby/setup-ruby@v1
2346
with:
2447
ruby-version: ${{ matrix.entry.ruby }}
25-
- uses: browser-actions/setup-geckodriver@latest
48+
bundler-cache: true
49+
cache-version: mongoid-${{ matrix.entry.mongoid }}-grape-${{ matrix.entry.grape || 'auto' }}
50+
- uses: browser-actions/setup-firefox@v1.7.2
2651
with:
27-
token: ${{ secrets.GITHUB_TOKEN }}
28-
- run: geckodriver --version
29-
- uses: supercharge/mongodb-github-action@1.7.0
30-
with:
31-
mongodb-version: ${{ matrix.entry.mongodb }}
52+
firefox-version: latest
3253
- name: Test
33-
uses: GabrielBB/xvfb-action@v1
34-
env:
35-
DATABASE_ADAPTER: mongoid
36-
MONGOID_VERSION: ${{ matrix.entry.mongoid }}
37-
with:
38-
run: |
39-
bundle install
40-
bundle exec rake spec
54+
run: xvfb-run --auto-servernum bundle exec rake spec
Lines changed: 46 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,59 @@
11
---
2-
name: test
2+
name: PostgreSQL
33
on: [push, pull_request]
4+
permissions:
5+
contents: read
6+
concurrency:
7+
group: postgresql-${{ github.ref }}
8+
cancel-in-progress: true
49
jobs:
510
test:
6-
runs-on: ubuntu-latest
11+
runs-on: ubuntu-24.04
12+
timeout-minutes: 20
13+
env:
14+
DATABASE_ADAPTER: activerecord
15+
ACTIVERECORD_VERSION: ${{ matrix.entry.active_record }}
16+
GRAPE_VERSION: ${{ matrix.entry.grape || '>= 0' }}
17+
DATABASE_URL: postgres://test:password@localhost/slack_ruby_bot_server_test
718
strategy:
19+
fail-fast: false
820
matrix:
921
entry:
10-
- { ruby: 3.2, postgresql: 11, active_record: '~> 6.0.0' }
11-
- { ruby: 3.2, postgresql: 11, active_record: '~> 6.1.0' }
12-
- { ruby: 3.2, postgresql: 14, active_record: '~> 7.0.0' }
13-
- { ruby: 3.3, postgresql: 14, active_record: '~> 7.2.0' }
14-
- { ruby: 3.4, postgresql: 14, active_record: '~> 7.2.0' }
15-
- { ruby: 3.4, postgresql: 15, active_record: '~> 8.0.2' }
16-
- { ruby: 3.4, postgresql: 16, active_record: '~> 8.0.2' }
17-
- { ruby: 3.4, postgresql: 17, active_record: '~> 8.0.2' }
18-
name: test (ruby=${{ matrix.entry.ruby }}, postgresql=${{ matrix.entry.postgresql }}, active_record=${{ matrix.entry.active_record }})
22+
- { ruby: '3.2', postgresql: '11', active_record: '~> 6.0.0' }
23+
- { ruby: '3.2', postgresql: '11', active_record: '~> 6.1.0' }
24+
- { ruby: '3.2', postgresql: '14', active_record: '~> 7.0.0' }
25+
- { ruby: '3.3', postgresql: '14', active_record: '~> 7.2.0' }
26+
- { ruby: '3.4', postgresql: '14', active_record: '~> 7.2.0' }
27+
- { ruby: '3.4', postgresql: '15', active_record: '~> 8.0.2' }
28+
- { ruby: '3.4', postgresql: '16', active_record: '~> 8.0.2' }
29+
- { ruby: '3.4', postgresql: '17', active_record: '~> 8.0.2' }
30+
- { ruby: '3.3', postgresql: '18', active_record: '~> 8.1', grape: '~> 3.2' }
31+
- { ruby: '3.4', postgresql: '18', active_record: '~> 8.1', grape: '~> 4.0' }
32+
- { ruby: '4.0', postgresql: '18', active_record: '~> 8.1', grape: '~> 4.0' }
33+
name: test (ruby=${{ matrix.entry.ruby }}, postgresql=${{ matrix.entry.postgresql }}, active_record=${{ matrix.entry.active_record }}, grape=${{ matrix.entry.grape || 'auto' }})
34+
services:
35+
postgresql:
36+
image: postgres:${{ matrix.entry.postgresql }}
37+
env:
38+
POSTGRES_DB: slack_ruby_bot_server_test
39+
POSTGRES_USER: test
40+
POSTGRES_PASSWORD: password
41+
ports:
42+
- 5432:5432
43+
options: >-
44+
--health-cmd "pg_isready -U test -d slack_ruby_bot_server_test"
45+
--health-interval 10s
46+
--health-timeout 5s
47+
--health-retries 10
1948
steps:
20-
- uses: actions/checkout@v2
49+
- uses: actions/checkout@v7
2150
- uses: ruby/setup-ruby@v1
2251
with:
2352
ruby-version: ${{ matrix.entry.ruby }}
24-
- uses: browser-actions/setup-geckodriver@latest
25-
with:
26-
token: ${{ secrets.GITHUB_TOKEN }}
27-
- run: geckodriver --version
28-
- uses: harmon758/postgresql-action@v1
53+
bundler-cache: true
54+
cache-version: activerecord-${{ matrix.entry.active_record }}-grape-${{ matrix.entry.grape || 'auto' }}
55+
- uses: browser-actions/setup-firefox@v1.7.2
2956
with:
30-
postgresql version: ${{ matrix.entry.postgresql }}
31-
postgresql db: slack_ruby_bot_server_test
32-
postgresql user: test
33-
postgresql password: password
57+
firefox-version: latest
3458
- name: Test
35-
uses: GabrielBB/xvfb-action@v1
36-
env:
37-
DATABASE_ADAPTER: activerecord
38-
ACTIVERECORD_VERSION: ${{ matrix.entry.active_record }}
39-
DATABASE_URL: postgres://test:password@localhost/slack_ruby_bot_server_test
40-
with:
41-
run: |
42-
bundle install
43-
bundle exec rake spec
59+
run: xvfb-run --auto-servernum bundle exec rake spec

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
### 2.2.1 (Next)
44

55
* Your contribution here.
6+
* [#182](https://github.com/slack-ruby/slack-ruby-bot-server/pull/182): Modernize CI with current actions, native database services, dependency caching, and explicit Ruby 4, Mongoid 9, Active Record 8.1, PostgreSQL 18, and Grape 3/4 coverage while retaining existing compatibility combinations - [@dblock](https://github.com/dblock), [@Copilot](https://github.com/apps/copilot-swe-agent).
67
* [#181](https://github.com/slack-ruby/slack-ruby-bot-server/pull/181): Migrated Danger to `danger-pr-comment` workflow - [@dblock](https://github.com/dblock).
78
* [#180](https://github.com/slack-ruby/slack-ruby-bot-server/pull/180): Add support for Grape v3 - [@markokajzer](https://github.com/markokajzer).
89

‎CONTRIBUTING.md‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,18 @@ git checkout -b my-feature-branch
2828

2929
## Bundle Install and Test
3030

31-
Ensure that you can build the project and run tests.
31+
Select a database adapter before installing dependencies. For example, to match the Ruby 4 MongoDB/Grape 4 job, start MongoDB locally and run:
3232

33-
```
33+
```sh
34+
export DATABASE_ADAPTER=mongoid MONGOID_VERSION='~> 9.1' GRAPE_VERSION='~> 4.0'
35+
export DATABASE_URL=mongodb://localhost/slack_ruby_bot_server_test
3436
bundle install
3537
bundle exec rake
3638
```
3739

38-
If you are a linux user, you will need to install [geckodriver](https://github.com/mozilla/geckodriver/releases), [firefox](https://download-installer.cdn.mozilla.net/pub/firefox/releases/), and `Xvfb`.
39-
And, to get a display for the headless browser, run `Xvfb` manually. You can see more explanations [here](http://elementalselenium.com/tips/38-headless).
40+
For PostgreSQL, set `DATABASE_ADAPTER=activerecord`, `ACTIVERECORD_VERSION`, and `DATABASE_URL` instead. `GRAPE_VERSION` optionally constrains the Grape version for either adapter; without it, Bundler selects a compatible version. CI preserves the older compatibility combinations and adds explicit Grape 3 and 4 jobs with current ORM versions, including Ruby 4. Each database runs in a health-checked service container, while Firefox runs under Xvfb. Selenium Manager provisions the matching driver.
41+
42+
On Linux, install [Firefox](https://www.mozilla.org/firefox/) and `Xvfb`, then run:
4043

4144
```
4245
xvfb-run --auto-servernum bundle exec rake
@@ -121,7 +124,7 @@ git push origin my-feature-branch -f
121124

122125
## Check on Your Pull Request
123126

124-
Go back to your pull request after a few minutes and see whether it passed muster with Travis-CI. Everything should look green, otherwise fix issues and amend your commit as described above.
127+
Go back to your pull request after a few minutes and check its GitHub Actions results. Everything should look green, otherwise fix issues and update your commit as described above.
125128

126129
## Be Patient
127130

‎Gemfile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ gem 'fabrication'
3131
gem 'faker'
3232
gem 'faraday'
3333
gem 'faraday-rack'
34+
gem 'grape', ENV.fetch('GRAPE_VERSION', '>= 0')
3435
gem 'hyperclient'
3536
gem 'mutex_m'
3637
gem 'rack'

‎spec/support/api/endpoints/it_behaves_like_a_cursor_api.rb‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
models_ids.concat(response.map { |instance| instance._links.self._url.gsub("http://example.org/api/#{model_ps}/", '') })
3232
break unless response._links[:next]
3333

34-
next_cursor = CGI.parse(URI.parse(response._links.next._url).query).map { |a| [a[0], a[1][0]] }.to_h
34+
next_cursor = URI.decode_www_form(URI.parse(response._links.next._url).query).to_h
3535
end
3636
expect(models_ids.uniq.count).to eq model.all.count
3737
end
@@ -44,7 +44,7 @@
4444
models_ids.concat(response.map { |instance| instance._links.self._url.gsub("http://example.org/api/#{model_ps}/", '') })
4545
break unless response._links[:next]
4646

47-
next_cursor = CGI.parse(URI.parse(response._links.next._url).query).map { |a| [a[0], a[1][0]] }.to_h
47+
next_cursor = URI.decode_www_form(URI.parse(response._links.next._url).query).to_h
4848
end
4949
expect(models_ids.uniq.count).to eq model.all.count - 3
5050
end

0 commit comments

Comments
 (0)