Skip to content

Commit 73cd6f3

Browse files
authored
Merge pull request #254 from rspec/update-ci
Start switching to Github Actions for CI
2 parents e06d126 + e32ccec commit 73cd6f3

File tree

11 files changed

+63
-24
lines changed

11 files changed

+63
-24
lines changed

Rakefile

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ def run_command(command, opts={})
2727
begin
2828
Bundler.unbundled_system(command)
2929
rescue Exception => e
30+
puts e
3031
puts e.backtrace
3132
end
3233
puts
@@ -240,14 +241,15 @@ def create_pull_request(project_name, branch, custom_pr_comment, base=BASE_BRANC
240241
)
241242
end
242243

243-
namespace :travis do
244+
namespace :ci do
244245
ReadFile = Struct.new(:file_name, :contents, :mode)
245246

246-
def update_travis_files_in_repos(opts={})
247-
update_files_in_repos('travis build scripts', '', opts) do |name|
248-
around_update_travis_build do
249-
travis_files_with_comments.each do |file|
247+
def update_ci_files_in_repos(opts={})
248+
update_files_in_repos('ci build scripts', '', opts) do |name|
249+
around_update_ci_build do
250+
ci_files_with_comments.each do |file|
250251
full_file_name = ReposPath.join(name, file.file_name)
252+
ensure_directory_exists(File.dirname(full_file_name))
251253
full_file_name.write(file.contents)
252254
full_file_name.chmod(file.mode) # ensure executables are set
253255
end
@@ -257,9 +259,12 @@ namespace :travis do
257259
end
258260
end
259261

260-
def travis_files_with_comments
261-
travis_root = BaseRspecPath.join('travis')
262-
file_names = Pathname.glob(travis_root.join('**', '{*,.*}')).select do |f|
262+
def ci_files_with_comments
263+
ci_root = BaseRspecPath.join('ci')
264+
file_names = Pathname.glob(ci_root.join('**', '{*,.*}')).select do |f|
265+
f.file?
266+
end
267+
file_names += Pathname.glob(ci_root.join('.github', '**', '{*,.*}')).select do |f|
263268
f.file?
264269
end
265270

@@ -278,13 +283,18 @@ namespace :travis do
278283
end
279284

280285
ReadFile.new(
281-
file.relative_path_from(travis_root),
286+
file.relative_path_from(ci_root),
282287
lines.join,
283288
file.stat.mode
284289
)
285290
end
286291
end
287292

293+
def ensure_directory_exists(dirname)
294+
return if Dir.exist?(dirname)
295+
Dir.mkdir(dirname)
296+
end
297+
288298
def update_maintenance_branch
289299
File.write("./maintenance-branch", BASE_BRANCH) unless File.exist?('./maintenance-branch')
290300
end
@@ -293,22 +303,24 @@ namespace :travis do
293303
sh script_file if File.exist?(script_file)
294304
end
295305

296-
def around_update_travis_build
306+
def around_update_ci_build
297307
run_if_exists './script/before_update_travis_build.sh'
308+
run_if_exists './script/before_update_build.sh'
298309
yield if block_given?
299310
ensure
311+
run_if_exists './script/after_update_build.sh'
300312
run_if_exists './script/after_update_travis_build.sh'
301313
end
302314

303-
desc "Update travis build files"
315+
desc "Update build files"
304316
task :update_files do
305-
update_travis_files_in_repos
317+
update_ci_files_in_repos
306318
end
307319

308-
desc "Updates the travis files and creates a PR"
320+
desc "Updates the CI files and creates a PR"
309321
task :create_pr_with_updates, :custom_pr_comment do |t, args|
310322
opts = { except: %w[ rspec-rails ] }
311-
force_update(update_travis_files_in_repos(opts), args[:custom_pr_comment], opts)
323+
force_update(update_ci_files_in_repos(opts), args[:custom_pr_comment], opts)
312324
end
313325
end
314326

ci/.github/workflows/ci.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: RSpec CI
2+
on: [pull_request, push]
3+
jobs:
4+
test:
5+
name: Ruby ${{ matrix.ruby }}
6+
runs-on: ubuntu-20.04
7+
strategy:
8+
matrix:
9+
ruby:
10+
- 3.0.0-preview1
11+
- 2.7
12+
- 2.6
13+
- 2.5
14+
- 2.4
15+
- 2.3
16+
- 2.2
17+
- 2.1.9
18+
- ruby-head
19+
fail-fast: false
20+
continue-on-error: ${{ matrix.ruby == 'jruby-9.2.13.0' || endsWith(matrix.ruby, 'head') }}
21+
steps:
22+
- uses: actions/checkout@v2
23+
- uses: ruby/setup-ruby@v1
24+
with:
25+
bundler: ${{ (matrix.ruby == 'jruby-9.1.17.0' && 1) || 2 }}
26+
ruby-version: ${{ matrix.ruby }}
27+
bundler-cache: true
28+
- uses: actions/cache@v2
29+
with:
30+
path: ../bundle
31+
key: ${{ runner.os }}-${{ matrix.ruby }}
32+
- run: script/update_rubygems_and_install_bundler
33+
- run: script/clone_all_rspec_repos
34+
- run: bundle install --binstubs --standalone
35+
- run: script/run_build
File renamed without changes.

travis/.travis.yml renamed to ci/.travis.yml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,6 @@ rvm:
1616
- 1.9.2
1717
- 1.9.3
1818
- 2.0.0
19-
- 2.1
20-
- 2.2.10
21-
- 2.3.8
22-
- 2.4.10
23-
- 2.5.8
24-
- 2.6.6
25-
- 2.7.1
26-
- ruby-3.0.0-preview1
27-
- ruby-head
2819
- ree
2920
- rbx-3
3021
- jruby-9.1.7.0 # pin JRuby to this until travis/rvm can install later versions
@@ -49,3 +40,4 @@ branches:
4940
only:
5041
- main
5142
- /^\d+-\d+-maintenance$/
43+
- /^\d+-\d+-dev$/
File renamed without changes.
File renamed without changes.
File renamed without changes.

travis/script/functions.sh renamed to ci/script/functions.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
2-
source $SCRIPT_DIR/travis_functions.sh
2+
source $SCRIPT_DIR/ci_functions.sh
33
source $SCRIPT_DIR/predicate_functions.sh
44

55
# If JRUBY_OPTS isn't set, use these.
File renamed without changes.

0 commit comments

Comments
 (0)