diff --git a/Rakefile b/Rakefile index d6c11948..065105ec 100644 --- a/Rakefile +++ b/Rakefile @@ -27,6 +27,7 @@ def run_command(command, opts={}) begin Bundler.unbundled_system(command) rescue Exception => e + puts e puts e.backtrace end puts @@ -240,14 +241,15 @@ def create_pull_request(project_name, branch, custom_pr_comment, base=BASE_BRANC ) end -namespace :travis do +namespace :ci do ReadFile = Struct.new(:file_name, :contents, :mode) - def update_travis_files_in_repos(opts={}) - update_files_in_repos('travis build scripts', '', opts) do |name| - around_update_travis_build do - travis_files_with_comments.each do |file| + def update_ci_files_in_repos(opts={}) + update_files_in_repos('ci build scripts', '', opts) do |name| + around_update_ci_build do + ci_files_with_comments.each do |file| full_file_name = ReposPath.join(name, file.file_name) + ensure_directory_exists(File.dirname(full_file_name)) full_file_name.write(file.contents) full_file_name.chmod(file.mode) # ensure executables are set end @@ -257,9 +259,12 @@ namespace :travis do end end - def travis_files_with_comments - travis_root = BaseRspecPath.join('travis') - file_names = Pathname.glob(travis_root.join('**', '{*,.*}')).select do |f| + def ci_files_with_comments + ci_root = BaseRspecPath.join('ci') + file_names = Pathname.glob(ci_root.join('**', '{*,.*}')).select do |f| + f.file? + end + file_names += Pathname.glob(ci_root.join('.github', '**', '{*,.*}')).select do |f| f.file? end @@ -278,13 +283,18 @@ namespace :travis do end ReadFile.new( - file.relative_path_from(travis_root), + file.relative_path_from(ci_root), lines.join, file.stat.mode ) end end + def ensure_directory_exists(dirname) + return if Dir.exist?(dirname) + Dir.mkdir(dirname) + end + def update_maintenance_branch File.write("./maintenance-branch", BASE_BRANCH) unless File.exist?('./maintenance-branch') end @@ -293,22 +303,24 @@ namespace :travis do sh script_file if File.exist?(script_file) end - def around_update_travis_build + def around_update_ci_build run_if_exists './script/before_update_travis_build.sh' + run_if_exists './script/before_update_build.sh' yield if block_given? ensure + run_if_exists './script/after_update_build.sh' run_if_exists './script/after_update_travis_build.sh' end - desc "Update travis build files" + desc "Update build files" task :update_files do - update_travis_files_in_repos + update_ci_files_in_repos end - desc "Updates the travis files and creates a PR" + desc "Updates the CI files and creates a PR" task :create_pr_with_updates, :custom_pr_comment do |t, args| opts = { except: %w[ rspec-rails ] } - force_update(update_travis_files_in_repos(opts), args[:custom_pr_comment], opts) + force_update(update_ci_files_in_repos(opts), args[:custom_pr_comment], opts) end end diff --git a/ci/.github/workflows/ci.yml b/ci/.github/workflows/ci.yml new file mode 100644 index 00000000..530be01e --- /dev/null +++ b/ci/.github/workflows/ci.yml @@ -0,0 +1,35 @@ +name: RSpec CI +on: [pull_request, push] +jobs: + test: + name: Ruby ${{ matrix.ruby }} + runs-on: ubuntu-20.04 + strategy: + matrix: + ruby: + - 3.0.0-preview1 + - 2.7 + - 2.6 + - 2.5 + - 2.4 + - 2.3 + - 2.2 + - 2.1.9 + - ruby-head + fail-fast: false + continue-on-error: ${{ matrix.ruby == 'jruby-9.2.13.0' || endsWith(matrix.ruby, 'head') }} + steps: + - uses: actions/checkout@v2 + - uses: ruby/setup-ruby@v1 + with: + bundler: ${{ (matrix.ruby == 'jruby-9.1.17.0' && 1) || 2 }} + ruby-version: ${{ matrix.ruby }} + bundler-cache: true + - uses: actions/cache@v2 + with: + path: ../bundle + key: ${{ runner.os }}-${{ matrix.ruby }} + - run: script/update_rubygems_and_install_bundler + - run: script/clone_all_rspec_repos + - run: bundle install --binstubs --standalone + - run: script/run_build diff --git a/travis/.rubocop_rspec_base.yml b/ci/.rubocop_rspec_base.yml similarity index 100% rename from travis/.rubocop_rspec_base.yml rename to ci/.rubocop_rspec_base.yml diff --git a/travis/.travis.yml b/ci/.travis.yml similarity index 89% rename from travis/.travis.yml rename to ci/.travis.yml index 79b3d785..9e647cb6 100644 --- a/travis/.travis.yml +++ b/ci/.travis.yml @@ -16,15 +16,6 @@ rvm: - 1.9.2 - 1.9.3 - 2.0.0 - - 2.1 - - 2.2.10 - - 2.3.8 - - 2.4.10 - - 2.5.8 - - 2.6.6 - - 2.7.1 - - ruby-3.0.0-preview1 - - ruby-head - ree - rbx-3 - jruby-9.1.7.0 # pin JRuby to this until travis/rvm can install later versions @@ -49,3 +40,4 @@ branches: only: - main - /^\d+-\d+-maintenance$/ + - /^\d+-\d+-dev$/ diff --git a/travis/appveyor.yml b/ci/appveyor.yml similarity index 100% rename from travis/appveyor.yml rename to ci/appveyor.yml diff --git a/travis/script/travis_functions.sh b/ci/script/ci_functions.sh similarity index 100% rename from travis/script/travis_functions.sh rename to ci/script/ci_functions.sh diff --git a/travis/script/clone_all_rspec_repos b/ci/script/clone_all_rspec_repos similarity index 100% rename from travis/script/clone_all_rspec_repos rename to ci/script/clone_all_rspec_repos diff --git a/travis/script/functions.sh b/ci/script/functions.sh similarity index 99% rename from travis/script/functions.sh rename to ci/script/functions.sh index 746462d0..4f876b0f 100644 --- a/travis/script/functions.sh +++ b/ci/script/functions.sh @@ -1,5 +1,5 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -source $SCRIPT_DIR/travis_functions.sh +source $SCRIPT_DIR/ci_functions.sh source $SCRIPT_DIR/predicate_functions.sh # If JRUBY_OPTS isn't set, use these. diff --git a/travis/script/predicate_functions.sh b/ci/script/predicate_functions.sh similarity index 100% rename from travis/script/predicate_functions.sh rename to ci/script/predicate_functions.sh diff --git a/travis/script/run_build b/ci/script/run_build similarity index 100% rename from travis/script/run_build rename to ci/script/run_build diff --git a/travis/script/update_rubygems_and_install_bundler b/ci/script/update_rubygems_and_install_bundler similarity index 100% rename from travis/script/update_rubygems_and_install_bundler rename to ci/script/update_rubygems_and_install_bundler