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

Start switching to Github Actions for CI #254

Merged
merged 4 commits into from Nov 16, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
40 changes: 26 additions & 14 deletions Rakefile
Expand Up @@ -27,6 +27,7 @@ def run_command(command, opts={})
begin
Bundler.unbundled_system(command)
rescue Exception => e
puts e
puts e.backtrace
end
puts
Expand Down Expand Up @@ -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
Expand All @@ -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

Expand All @@ -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
Expand All @@ -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

Expand Down
35 changes: 35 additions & 0 deletions ci/.github/workflows/ci.yml
@@ -0,0 +1,35 @@
name: RSpec CI
on: [pull_request, push]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this needs to be tweaked so we only run push on main/*-maintenance/*-dev

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah agreed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something like? I am not sur for pull_request.

on:
  # Trigger the workflow on push or pull request,
  # but only for the main branch
  push:
    branches:
      - main
      - *-maintenance
      - *-dev
  pull_request:
      branches:
        - **

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') }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it still needed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

head at least is needed post 3.0.0's release, and the jruby one is needed until its fixed

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
File renamed without changes.
10 changes: 1 addition & 9 deletions travis/.travis.yml → ci/.travis.yml
Expand Up @@ -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
Expand All @@ -49,3 +40,4 @@ branches:
only:
- main
- /^\d+-\d+-maintenance$/
- /^\d+-\d+-dev$/
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion travis/script/functions.sh → 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.
Expand Down
File renamed without changes.
File renamed without changes.