Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
name: CI
on: [push, pull_request]

permissions:
contents: read

jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
entry:
- { ruby: '2.6', mongodb: '4.4', gemfile: 'mongoid-4.0', bundler: '1.17.3' }
Expand All @@ -24,20 +28,29 @@ jobs:
- { ruby: '3.3', mongodb: '4', gemfile: 'mongoid-9.0' }
- { ruby: '3.3', mongodb: '5', gemfile: 'mongoid-9.0' }
- { ruby: '3.3', mongodb: '6', gemfile: 'mongoid-9.0' }
- { ruby: '3.4', mongodb: '7.0', gemfile: 'mongoid-9.0', bundler: '2.7.2' }
- { ruby: '3.4', mongodb: '8.0', gemfile: 'mongoid-9.0', bundler: '2.7.2' }
- { ruby: '4.0', mongodb: '8.0', gemfile: 'mongoid-9.0', bundler: '2.7.2' }
name: test (ruby=${{ matrix.entry.ruby }}, mongodb=${{ matrix.entry.mongodb }}), gemfile=${{ matrix.entry.gemfile }})
env:
BUNDLE_GEMFILE: gemfiles/${{ matrix.entry.gemfile }}.gemfile
services:
mongodb:
image: mongo:${{ matrix.entry.mongodb }}
ports:
- 27017:27017
options: >-
--health-cmd "mongosh --quiet --eval 'db.adminCommand({ping: 1})' || mongo --quiet --eval 'db.adminCommand({ping: 1})'"
--health-interval 10s
--health-timeout 5s
--health-retries 10
steps:
- name: Set up MongoDB ${{ matrix.entry.mongodb }}
uses: supercharge/mongodb-github-action@1.8.0
with:
mongodb-version: ${{ matrix.entry.mongodb }}
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.entry.ruby }}
bundler: '${{ matrix.entry.bundler || 1 }}'
bundler: '${{ matrix.entry.bundler || ''2.4.22'' }}'
bundler-cache: true
- name: Run tests
run: bundle exec rake
17 changes: 17 additions & 0 deletions .github/workflows/danger-comment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Danger Comment

on:
workflow_run:
workflows: [Danger]
types: [completed]

permissions:
contents: read
actions: read
issues: write
pull-requests: write

jobs:
comment:
uses: numbata/danger-pr-comment/.github/workflows/danger-comment.yml@v0.1.0
secrets: inherit
39 changes: 30 additions & 9 deletions .github/workflows/danger.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,40 @@
name: PR Linter
on: [pull_request]
name: Danger

on:
pull_request:
types: [opened, reopened, edited, synchronize]

permissions:
contents: read

jobs:
danger:
runs-on: ubuntu-latest
env:
BUNDLE_GEMFILE: ${{ github.workspace }}/Gemfile.danger
BUNDLE_GEMFILE: Gemfile.danger
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7
ruby-version: '3.4'
bundler-cache: true
- run: |
# the personal token is public, this is ok, base64 encode to avoid tripping Github
TOKEN=$(echo -n Z2hwX0xNQ3VmanBFeTBvYkZVTWh6NVNqVFFBOEUxU25abzBqRUVuaAo= | base64 --decode)
DANGER_GITHUB_API_TOKEN=$TOKEN bundle exec danger --verbose
- name: Run Danger
id: danger
continue-on-error: true
env:
DANGER_GITHUB_API_TOKEN: ${{ github.token }}
GITHUB_TOKEN: ${{ github.token }}
DANGER_REPORT_PATH: ${{ runner.temp }}/danger-report.json
run: bundle exec danger dry_run
- name: Upload Danger report
if: ${{ always() }}
uses: actions/upload-artifact@v4
with:
name: danger-report
path: ${{ runner.temp }}/danger-report.json
if-no-files-found: error
- name: Fail if Danger failed
if: ${{ steps.danger.outcome == 'failure' }}
run: exit 1
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ test/db.yml
TODO
*.sw*
Gemfile.lock
Gemfile.danger.lock
gemfiles/*.lock
pkg/*
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
### 2.6.1 (Next)

* [#84](https://github.com/mongoid/mongoid-grid_fs/pull/84): Migrate Danger to danger-pr-comment workflows - [@dblock](https://github.com/dblock).
* [#84](https://github.com/mongoid/mongoid-grid_fs/pull/84): Modernize CI through Ruby 4.0 and MongoDB 8 with Mongoid 9, use Bundler 2 for modern Rails, and explicitly load Logger for Rails 6 - [@dblock](https://github.com/dblock).
* Your contribution here.

### 2.6.0 (2024/11/19)
Expand Down
6 changes: 5 additions & 1 deletion Dangerfile
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
danger.import_dangerfile(gem: 'mongoid-danger')
# frozen_string_literal: true

danger.import_dangerfile(gem: 'danger-pr-comment')

changelog.check!
6 changes: 3 additions & 3 deletions Gemfile.danger
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
source 'https://rubygems.org'

group :test do
gem 'mongoid-danger', '~> 0.2.0'
end
gem 'danger', '~> 9.5', require: false
gem 'danger-changelog', '~> 0.9.0', require: false
gem 'danger-pr-comment', '~> 0.1.0', require: false
3 changes: 3 additions & 0 deletions gemfiles/mongoid-9.0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@ source 'https://rubygems.org'

gem 'mongoid', '~> 9.0.0'
gem 'rails', '~> 7.0'
gem 'base64'
gem 'bigdecimal'
gem 'logger'

gemspec path: '../'
3 changes: 1 addition & 2 deletions mongoid-grid_fs.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ Gem::Specification.new do |spec|
spec.test_files = Dir['test/**/*']
spec.require_path = 'lib'

spec.add_development_dependency 'minitest'
spec.add_development_dependency 'mongoid-danger', '~> 0.2'
spec.add_development_dependency 'minitest', '~> 5.0'
spec.add_development_dependency 'pry'
spec.add_development_dependency 'rails'
spec.add_development_dependency 'rubocop', '~> 1.36.0'
Expand Down
1 change: 1 addition & 0 deletions test/helper.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
require 'logger'
require 'rails'
require 'stringio'

Expand Down
Loading