-
Notifications
You must be signed in to change notification settings - Fork 375
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
204 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
name: Lock Dependency | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
branch: | ||
description: 'Branch to be lock dependency' | ||
required: true | ||
# Testing purpose, to be removed before merge. | ||
push: | ||
branches: | ||
- tonycthsu/automate-update-gemfiles | ||
|
||
# Ensure obsolete job is cancelled if another commit is pushed to the same branch. | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
# TODO: In order to fully automate this workflow for each PR, | ||
# have a reliable way to precheck job to understand whether it need to be updated | ||
lock: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
engine: | ||
# ADD NEW RUBIES HERE | ||
- name: ruby | ||
version: '3.4' | ||
- name: ruby | ||
version: '3.3' | ||
- name: ruby | ||
version: '3.2' | ||
- name: ruby | ||
version: '3.1' | ||
- name: ruby | ||
version: '3.0' | ||
- name: ruby | ||
version: '2.7' | ||
- name: ruby | ||
version: '2.6' | ||
- name: ruby | ||
version: '2.5' | ||
- name: jruby | ||
version: '9.4' | ||
- name: jruby | ||
version: '9.3' | ||
- name: jruby | ||
version: '9.2' | ||
container: | ||
image: ghcr.io/datadog/images-rb/engines/${{ matrix.engine.name }}:${{ matrix.engine.version }} | ||
env: | ||
BUNDLE_WITHOUT: check | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- run: ls -al | ||
- run: | | ||
ruby -v | ||
gem -v | ||
bundler -v | ||
- run: bundle install | ||
|
||
# TODO: Migrate away from `appraisal` | ||
- run: bundle exec appraisal generate | ||
- run: bundle exec rake dependency:lock | ||
|
||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: lock-dependency-${{ github.run_id }}-${{ matrix.engine.name }}-${{ matrix.engine.version }} | ||
path: gemfiles/${{ matrix.engine.name }}_${{ matrix.engine.version }}* | ||
|
||
commit: | ||
needs: lock | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- uses: actions/download-artifact@v4 | ||
with: | ||
path: gemfiles | ||
pattern: lock-dependency-${{ github.run_id }}-* | ||
merge-multiple: true | ||
|
||
- run: git diff --color | ||
|
||
- uses: stefanzweifel/git-auto-commit-action@v5 | ||
with: | ||
file_pattern: 'gemfiles/*' | ||
commit_message: "[🤖] Lock Dependency: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
require 'pathname' | ||
|
||
# This module translates our custom mapping between appraisal and bundler. | ||
# | ||
# It cannot be included into `Appraisal` file, because it was invoked via `instance_eval`. | ||
module AppraisalConversion | ||
module_function | ||
|
||
@gemfile_dir = 'gemfiles' | ||
@definition_dir = 'appraisal' | ||
|
||
def to_bundle_gemfile(group) | ||
gemfile = "#{runtime_identifier}_#{group}.gemfile".tr('-', '_') | ||
path = root_path.join(gemfile_dir, gemfile) | ||
|
||
if path.exist? | ||
path.to_s | ||
else | ||
raise "Gemfile not found at #{path}" | ||
end | ||
end | ||
|
||
def definition | ||
path = root_path.join(@definition_dir, "#{runtime_identifier}.rb") | ||
|
||
if path.exist? | ||
path.to_s | ||
else | ||
raise "Definition not found at #{path}" | ||
end | ||
end | ||
|
||
def runtime_identifier | ||
major, minor, = Gem::Version.new(RUBY_ENGINE_VERSION).segments | ||
"#{RUBY_ENGINE}-#{major}.#{minor}" | ||
end | ||
|
||
def gemfile_pattern | ||
root_path + gemfile_dir + "#{runtime_identifier.tr('-', '_')}_*.gemfile" | ||
end | ||
|
||
def gemfile_dir | ||
@gemfile_dir | ||
end | ||
|
||
def root_path | ||
Pathname.pwd | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
require 'open3' | ||
|
||
require_relative 'appraisal_conversion' | ||
|
||
task :dep => :dependency | ||
task :dependency => %w[dependency:lock] | ||
namespace :dependency do | ||
# rubocop:disable Style/MultilineBlockChain | ||
Dir.glob(AppraisalConversion.gemfile_pattern).each do |gemfile| | ||
# desc "Lock the dependencies for #{gemfile}" | ||
task gemfile do | ||
Bundler.with_unbundled_env do | ||
command = +'bundle lock' | ||
command << ' --add-platform x86_64-linux aarch64-linux' unless RUBY_PLATFORM == 'java' | ||
output, = Open3.capture2e({ 'BUNDLE_GEMFILE' => gemfile.to_s }, command) | ||
|
||
puts output | ||
end | ||
end | ||
end.tap do |gemfiles| | ||
desc "Lock the dependencies for #{AppraisalConversion.runtime_identifier}" | ||
# WHY can't we use `multitask :lock => gemfiles` here? | ||
# | ||
# Running bundler in parallel has various race conditions | ||
# | ||
# Race condition with the file system, particularly worse with JRuby. | ||
# For instance, `Errno::ENOENT: No such file or directory - bundle` is raised with JRuby 9.2 | ||
|
||
# Even with CRuby, `simplcov` declaration with `github` in Gemfile causes | ||
# race condition for the local gem cache with the following error: | ||
|
||
# ``` | ||
# [/usr/local/bundle/bundler/gems/simplecov-3bb6b7ee58bf/simplecov.gemspec] isn't a Gem::Specification (NilClass instead). | ||
# ``` | ||
|
||
# and | ||
|
||
# ``` | ||
# fatal: Unable to create '/usr/local/bundle/bundler/gems/simplecov-3bb6b7ee58bf/.git/index.lock': File exists. | ||
# Another git process seems to be running in this repository, e.g. | ||
# an editor opened by 'git commit'. Please make sure all processes | ||
# are terminated then try again. If it still fails, a git process | ||
# may have crashed in this repository earlier: | ||
# remove the file manually to continue. | ||
# ``` | ||
task :lock => gemfiles | ||
end | ||
# rubocop:enable Style/MultilineBlockChain | ||
end |
Oops, something went wrong.