Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI experiments #59

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open
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
31 changes: 11 additions & 20 deletions .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby

name: Ruby

on:
Expand All @@ -23,20 +16,18 @@ jobs:
solargraph-version:
- "0.48.0"
- "0.49.0"
fail-fast: false
rails-version:
- "7"
fail-fast: true

steps:
- uses: actions/checkout@v2
- name: Cache RVM
uses: actions/cache@v3
id: rvm
- uses: ruby/setup-ruby@v1
with:
key: ${{ runner.os }}-rvm-${{ matrix.ruby-version }}
path: |
/home/runner/.rvm
/home/runner/.yardoc
#/usr/local/rvm/
#- name: Setup upterm session
# uses: lhotari/action-upterm@v1
- name: Test
run: "/bin/bash ./ci.sh ${{ matrix.ruby-version }} ${{ matrix.solargraph-version}}"
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: true
- name: bundle list
run: bundle list && cat Gemfile.lock && find vendor -name Gemfile
- name: RSpec
run: bundle exec rspec spec/solargraph-rails

5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
/spec/reports/
/tmp/
.DS_Store
spec/rails5/log/
spec/rails5/tmp/
spec/rails6/log/
spec/rails6/tmp/
spec/rails7/log/
spec/rails7/tmp/
.projections.json
Expand All @@ -19,3 +15,4 @@ spec/rails7/tmp/
# rspec failure tracking
.rspec_status
Gemfile.lock
vendor
26 changes: 5 additions & 21 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,20 @@

1. create fork and clone the repo
2. install gem deps `bundle install`
3. install dummy rails5 app deps and build its yard cache

```
$ cd spec/rails5
$ bundle install && yard gems
$ cd ../../
```

3. install dummy rails6 app deps and build its yard cache

```
$ cd spec/rails6
$ bundle install && yard gems
$ cd ../../
```

4. install dummy rails7 app deps and build its yard cache
3. install dummy Rails app deps and build its yard cache

```
$ cd spec/rails7
$ bundle install && yard gems
$ cd ../../
```
5. now tests should pass locally and you can try different changes
6. sumbit PR
4. now tests should pass locally and you can try different changes
5. sumbit PR

## Completion coverage tracking

Solargraph-Rails uses a [set of yaml files](https://github.com/iftheshoefritz/solargraph-rails/tree/master/spec/definitions) to track coverage of found completions.
Those yaml files are generated at runtime from a dummy [rails5](https://github.com/iftheshoefritz/solargraph-rails/tree/master/spec/rails5) or [rails6](https://github.com/iftheshoefritz/solargraph-rails/tree/master/spec/rails6) app.
Those yaml files are generated at runtime from a dummy [Rails 7 app](https://github.com/iftheshoefritz/solargraph-rails/tree/master/spec/rails7).

The main goal is to catch any regressions in case of any change. In case a method completion is marked completed and it is not found in solargraph completions, the tests will fail.

Expand Down Expand Up @@ -85,7 +69,7 @@ In case a new set of assertion files has to be created (for a new Rails version
All you have to do is execute the script and pass it a path to rails app:

```
ruby script/generate_definitions.rb spec/rails6
ruby script/generate_definitions.rb spec/rails7
```

Make sure to review the script and uncomment relevant parts
17 changes: 14 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
source "https://rubygems.org"
source 'https://rubygems.org'

git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }

# Kind of ugly, but works. The setup-ruby action forces gems to be installed to vendor/bundle
# If we use it naively we end up with vendor/bundle and spec/rails7/vendor/bundle, which
# breaks all the tests because docs are generated in two different directories.
#
# So if we just install the rails deps at the same time, we have a single cache and a single
# directory for gems.
plugin 'auto_yard', path: './ci/auto_yard'
rails_version = ENV['MATRIX_RAILS_VERSION'] || '7'
instance_eval File.read("spec/rails#{rails_version}/Gemfile")

group :development, :test do
gem 'byebug'
gem 'bundler-audit'
gem 'debug'
gem 'byebug'
end

# Specify your gem's dependencies in solargraph_rails.gemspec
gemspec
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,11 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/ifthes
3. install dummy rails app deps and build the yard cache:

```
$ cd spec/rails5
$ cd spec/rails7
$ bundle install && yard gems
$ cd ../../
```

(and the same for rails 6 and rails 7)

4. now tests should pass locally and you can try different changes

5. sumbit PR
Expand Down
34 changes: 0 additions & 34 deletions ci.sh

This file was deleted.

8 changes: 8 additions & 0 deletions ci/auto_yard/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/.bundle/
/.yardoc
/_yardoc/
/coverage/
/doc/
/pkg/
/spec/reports/
/tmp/
18 changes: 18 additions & 0 deletions ci/auto_yard/auto_yard.gemspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# frozen_string_literal: true

Gem::Specification.new do |spec|
spec.name = 'auto_yard'
spec.version = '0.0.1'
spec.authors = ['Stephen Sugden']
spec.email = ['grncdr@users.noreply.github.com']

spec.summary = 'Run yard gems automatically after bundle install'
spec.description = spec.summary
spec.license = 'MIT'
spec.required_ruby_version = '>= 2.6.0'

spec.homepage = 'https://github.com'
spec.metadata['homepage_uri'] = spec.homepage

spec.files = ['plugins.rb']
end
3 changes: 3 additions & 0 deletions ci/auto_yard/plugins.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Bundler::Plugin.add_hook('after-install-all') do
system('bundle exec yard gems')
end
3 changes: 3 additions & 0 deletions lib/solargraph/rails/annotations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,11 @@
# def draw; end
# end
# class ActiveRecord::Base
# extend Enumerable
# extend ActiveRecord::QueryMethods
# extend ActiveRecord::FinderMethods
# extend ActiveRecord::Calculations
# extend ActiveRecord::Batches
# extend ActiveRecord::Associations::ClassMethods
# extend ActiveRecord::Inheritance::ClassMethods
# extend ActiveRecord::ModelSchema::ClassMethods
Expand Down
5 changes: 4 additions & 1 deletion solargraph-rails.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'solargraph/rails/version'


solargraph_version = (ENV['CI'] && ENV['MATRIX_SOLARGRAPH_VERSION']) || ">= 0.48.0"

Gem::Specification.new do |spec|
spec.name = 'solargraph-rails'
spec.version = Solargraph::Rails::VERSION
Expand All @@ -27,6 +30,6 @@ Gem::Specification.new do |spec|
spec.add_development_dependency 'rake', '~> 12.3.3'
spec.add_development_dependency 'rspec', '~> 3.0'

spec.add_runtime_dependency 'solargraph'
spec.add_runtime_dependency 'solargraph', solargraph_version
spec.add_runtime_dependency 'activesupport'
end
Loading