diff --git a/.github/workflows/danger.yml b/.github/workflows/danger.yml new file mode 100644 index 0000000..0c256ae --- /dev/null +++ b/.github/workflows/danger.yml @@ -0,0 +1,18 @@ +--- +name: danger +on: [pull_request] +jobs: + danger: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v1 + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: 2.6 + bundler-cache: true + - name: Run Danger + run: | + # the personal token is public, this is ok, base64 encode to avoid tripping Github + TOKEN=$(echo -n NWY1ZmM5MzEyMzNlYWY4OTZiOGU3MmI3MWQ3Mzk0MzgxMWE4OGVmYwo= | base64 --decode) + DANGER_GITHUB_API_TOKEN=$TOKEN bundle exec danger --verbose \ No newline at end of file diff --git a/.github/workflows/rubocop.yml b/.github/workflows/rubocop.yml new file mode 100644 index 0000000..b68a5f7 --- /dev/null +++ b/.github/workflows/rubocop.yml @@ -0,0 +1,16 @@ +--- +name: test +on: [push, pull_request] +jobs: + lint: + name: RuboCop + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: 2.7 + bundler-cache: true + - name: Run RuboCop + run: bundle exec rubocop \ No newline at end of file diff --git a/.github/workflows/test-mongodb.yml b/.github/workflows/test-mongodb.yml new file mode 100644 index 0000000..38bc38b --- /dev/null +++ b/.github/workflows/test-mongodb.yml @@ -0,0 +1,32 @@ +--- +name: test +on: [push, pull_request] +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + entry: + - { ruby: 2.6.2, mongoid: 6.4.8, mongodb: 4.4 } + - { ruby: 2.6.2, mongoid: 7.2.3, mongodb: 4.4 } + - { ruby: 2.6.2, mongoid: 7.3.0, mongodb: 4.4 } + name: test (ruby=${{ matrix.entry.ruby }}, mongoid=${{ matrix.entry.mongoid }}, mongodb=${{ matrix.entry.mongodb }}) + steps: + - uses: actions/checkout@v2 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.entry.ruby }} + - uses: browser-actions/setup-geckodriver@latest + - run: geckodriver --version + - uses: supercharge/mongodb-github-action@1.7.0 + with: + mongodb-version: ${{ matrix.entry.mongodb }} + - name: Test + uses: GabrielBB/xvfb-action@v1 + env: + DATABASE_ADAPTER: mongoid + MONGOID_VERSION: ${{ matrix.entry.mongoid }} + with: + run: | + bundle install + bundle exec rake spec diff --git a/.github/workflows/test-postgresql.yml b/.github/workflows/test-postgresql.yml new file mode 100644 index 0000000..6c79652 --- /dev/null +++ b/.github/workflows/test-postgresql.yml @@ -0,0 +1,33 @@ +--- +name: test +on: [push, pull_request] +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + entry: + - { ruby: 2.6.2, postgresql: 11 } + name: test (ruby=${{ matrix.entry.ruby }}, postgresql=${{ matrix.entry.postgresql }}) + steps: + - uses: actions/checkout@v2 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.entry.ruby }} + - uses: browser-actions/setup-geckodriver@latest + - run: geckodriver --version + - uses: harmon758/postgresql-action@v1 + with: + postgresql version: ${{ matrix.entry.postgresql }} + postgresql db: slack_ruby_bot_server_test + postgresql user: test + postgresql password: password + - name: Test + uses: GabrielBB/xvfb-action@v1 + env: + DATABASE_ADAPTER: activerecord + DATABASE_URL: postgres://test:password@localhost/slack_ruby_bot_server_test + with: + run: | + bundle install + bundle exec rake spec diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index fd2a9d8..0000000 --- a/.travis.yml +++ /dev/null @@ -1,49 +0,0 @@ -language: ruby - -cache: bundler - -matrix: - include: - - rvm: 2.6.2 - script: - - bundle exec danger - services: - - xvfb - - rvm: 2.6.2 - env: DATABASE_ADAPTER=activerecord - services: - - xvfb - - postgresql - - rvm: 2.6.2 - env: - - DATABASE_ADAPTER=mongoid - - MONGOID_VERSION=6.4.8 - services: - - xvfb - - mongodb - - rvm: 2.6.2 - env: - - DATABASE_ADAPTER=mongoid - - MONGOID_VERSION=7.2.3 - services: - - xvfb - - mongodb - - rvm: 2.6.2 - env: - - DATABASE_ADAPTER=mongoid - - MONGOID_VERSION=7.3.0 - services: - - xvfb - - mongodb - -addons: - firefox: 54.0 - -before_install: - - wget https://github.com/mozilla/geckodriver/releases/download/v0.18.0/geckodriver-v0.18.0-linux64.tar.gz - - mkdir geckodriver - - tar -xzf geckodriver-v0.18.0-linux64.tar.gz -C geckodriver - - export PATH=$PATH:$PWD/geckodriver - -script: - - bundle exec rake diff --git a/spec/database_adapters/activerecord/activerecord.rb b/spec/database_adapters/activerecord/activerecord.rb index 92fa0d0..5279125 100644 --- a/spec/database_adapters/activerecord/activerecord.rb +++ b/spec/database_adapters/activerecord/activerecord.rb @@ -1,4 +1,8 @@ -db_config = YAML.safe_load(File.read(File.expand_path('config/postgresql.yml', __dir__)), [], [], true)[ENV['RACK_ENV']] +db_config = YAML.safe_load( + ERB.new(File.read( + File.expand_path('config/postgresql.yml', __dir__) + )).result, [], [], true +)[ENV['RACK_ENV']] ActiveRecord::Tasks::DatabaseTasks.create(db_config) ActiveRecord::Base.establish_connection(db_config) ActiveRecord::Base.logger.level = :info diff --git a/spec/database_adapters/activerecord/config/postgresql.yml b/spec/database_adapters/activerecord/config/postgresql.yml index e932d3f..64ac088 100644 --- a/spec/database_adapters/activerecord/config/postgresql.yml +++ b/spec/database_adapters/activerecord/config/postgresql.yml @@ -10,6 +10,7 @@ development: test: <<: *default + url: <%= ENV["DATABASE_URL"] %> database: slack_ruby_bot_server_test production: