add rails version to Gemfile.lock
refs DE-523 Previously, the current version would be represented by Gemfile.lock and the next version by Gemfile.lock.next. Replace both with a common format of Gemfile.rails<version>.lock to be able to iterate over the files in a cleaner way. Change-Id: I35aef3a14e726eb35db8aebc808af4a925552c01 Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/288563 Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com> Reviewed-by: Jacob Burroughs <jburroughs@instructure.com> QA-Review: Aaron Ogata <aogata@instructure.com> Product-Review: Aaron Ogata <aogata@instructure.com>
This commit is contained in:
parent
c72cacb87b
commit
a5cb130154
|
@ -29,8 +29,7 @@
|
|||
/db/*sql
|
||||
docker-compose.override.yml
|
||||
/exports/
|
||||
Gemfile.lock
|
||||
Gemfile.lock.next
|
||||
Gemfile.*.lock
|
||||
/log/*
|
||||
!/log/.keep
|
||||
!/log/parallel-runtime-rspec.log
|
||||
|
|
|
@ -12,18 +12,15 @@ RUN --mount=target=/tmp/src \
|
|||
/tmp/dst && \
|
||||
find gems \( \
|
||||
-name "Gemfile" -o \
|
||||
-name "Gemfile.d" -o \
|
||||
-name "Gemfile.lock" -o \
|
||||
-name "Gemfile.lock.next" -o \
|
||||
-name "*.gemspec" -o \
|
||||
-name "gem_version.rb" -o \
|
||||
-name "version.rb" \
|
||||
\) -exec cp --parents -rf {} /tmp/dst \; && \
|
||||
find gems/plugins \( \
|
||||
-name "Gemfile.d" \
|
||||
\) -exec cp --parents -rf {} /tmp/dst \; && \
|
||||
find engines \( \
|
||||
-name "Gemfile" -o \
|
||||
-name "Gemfile.d" -o \
|
||||
-name "Gemfile.lock" -o \
|
||||
-name "Gemfile.lock.next" -o \
|
||||
-name "*.gemspec" -o \
|
||||
-name "gem_version.rb" -o \
|
||||
-name "version.rb" \
|
||||
|
|
|
@ -32,22 +32,19 @@ elsif RUBY_VERSION >= "3.0.0" && RUBY_VERSION < "3.1"
|
|||
end
|
||||
ruby ">= 2.7.0", "< 3.1"
|
||||
|
||||
# force a different lockfile for next rails
|
||||
if CANVAS_RAILS >= "6.1"
|
||||
Bundler::SharedHelpers.class_eval do
|
||||
# Add the version number to the Gemfile.lock as Gemfile.<version>.lock
|
||||
Bundler::SharedHelpers.class_eval do
|
||||
class << self
|
||||
def default_lockfile
|
||||
lockfile = +"#{Bundler.default_gemfile}.lock"
|
||||
lockfile << ".next"
|
||||
lockfile = "#{Bundler.default_gemfile}.rails#{CANVAS_RAILS.delete(".")}.lock"
|
||||
Pathname.new(lockfile)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Bundler::Dsl.class_eval do
|
||||
Bundler::Dsl.class_eval do
|
||||
def to_definition(_lockfile, unlock)
|
||||
@sources << @rubygems_source if @sources.respond_to?(:include?) && !@sources.include?(@rubygems_source)
|
||||
Definition.new(Bundler.default_lockfile, @dependencies, @sources, unlock, @ruby_version)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -8,10 +8,8 @@ unless defined?(Spring)
|
|||
require 'rubygems'
|
||||
require 'bundler'
|
||||
|
||||
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
|
||||
default_lockfile = Bundler.default_lockfile
|
||||
next_lockfile = default_lockfile.dirname + "Gemfile.lock.next"
|
||||
lockfile_name = [next_lockfile, default_lockfile].find(&:exist?)
|
||||
rails_version = ENV["CANVAS_RAILS"] || "6.0"
|
||||
lockfile_name = Bundler.default_lockfile.dirname + "Gemfile.rails#{rails_version.delete(".")}.lock"
|
||||
lockfile = Bundler::LockfileParser.new(lockfile_name.read)
|
||||
spring = lockfile.specs.detect { |spec| spec.name == 'spring' }
|
||||
if spring
|
||||
|
|
|
@ -2,19 +2,15 @@
|
|||
|
||||
set -ex
|
||||
|
||||
TEST_FILE=""
|
||||
for TEST_FILE in Gemfile.*.lock; do
|
||||
echo "checking $TEST_FILE with snyk"
|
||||
|
||||
if test -f "Gemfile.lock"; then
|
||||
TEST_FILE="Gemfile.lock"
|
||||
elif test -f "Gemfile.lock.next"; then
|
||||
TEST_FILE="Gemfile.lock.next"
|
||||
else
|
||||
npx snyk auth $SNYK_TOKEN
|
||||
npx snyk test --severity-threshold=low --file=$TEST_FILE --org=instructure --project-name=canvas-lms:ruby --packageManager=rubygems || true
|
||||
npx snyk monitor --severity-threshold=low --file=$TEST_FILE --org=instructure --project-name=canvas-lms:ruby --packageManager=rubygems
|
||||
done
|
||||
|
||||
if [[ -z "$TEST_FILE" ]]; then
|
||||
echo "could not find any supported file to check"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "checking $TEST_FILE with snyk"
|
||||
|
||||
npx snyk auth $SNYK_TOKEN
|
||||
npx snyk test --severity-threshold=low --file=$TEST_FILE --org=instructure --project-name=canvas-lms:ruby --packageManager=rubygems || true
|
||||
npx snyk monitor --severity-threshold=low --file=$TEST_FILE --org=instructure --project-name=canvas-lms:ruby --packageManager=rubygems
|
||||
|
|
Loading…
Reference in New Issue