Skip to content

Commit

Permalink
Test for possible version mismatches of base64 (stdlib) gem
Browse files Browse the repository at this point in the history
base64 is part of the ruby stdlib https://stdgems.org/base64/.
Rubocop adds it now as a gem dependency since it gets removed
from the stdlib with ruby 3.4 rubocop/rubocop#12094.
The introduced version of base64 matches the one of our
currently used ruby version (3.1.4). We have to make sure
that the version that now is included to our bundle does not
mismatch in the future due to possible introduced updates.
  • Loading branch information
krauselukas committed Aug 14, 2023
1 parent 92826a0 commit fb22db3
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 7 deletions.
12 changes: 6 additions & 6 deletions .circleci/conditional_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ parameters:
type: boolean
default: false

run-passenger-tests:
run-passenger-and-ruby-default-gem-tests:
type: boolean
default: false

Expand Down Expand Up @@ -309,7 +309,7 @@ jobs:
bundle exec rake db:seed
bundle exec rake data:migrate
passenger_tests:
passenger_and_ruby_default_gem_tests:
docker:
- <<: *frontend_base
steps:
Expand All @@ -320,6 +320,7 @@ jobs:
command: |
make -C src/api test_rake
make -C src/api test_rack
make -C src/api test_base64_gem
spider:
parallelism: 2
Expand Down Expand Up @@ -502,11 +503,11 @@ workflows:
requires:
- checkout_code

passenger_tests:
when: << pipeline.parameters.run-passenger-tests >>
passenger_and_ruby_default_gem_tests:
when: << pipeline.parameters.run-passenger-and-ruby-default-gem-tests >>
jobs:
- checkout_code
- passenger_tests:
- passenger_and_ruby_default_gem_tests:
requires:
- checkout_code

Expand Down Expand Up @@ -556,4 +557,3 @@ workflows:
- feature:
requires:
- linters

2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ workflows:
src/api/app/(views|components)/.* run-haml-linter true
src/api/vendor/cache/haml.* run-haml-linter true
src/api/db/.* run-migrations-tests true
src/api/Gemfile.lock run-passenger-tests true
src/api/Gemfile.lock run-passenger-and-ruby-default-gem-tests true
src/api/app/assets/javascripts/.* run-javascripts-linter true
src/api/public/apidocs-new/.* run-apidocs-linter true
base-revision: master
Expand Down
32 changes: 32 additions & 0 deletions .github/workflows/create_diffend_io_links.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/ruby
# frozen_string_literal: true

class CreateDiffendIoLinks
def initialize

end

def receive_file_diff_names
# EXAMPLE: "mini_mime-1.1.5\n"
@added_files = `git diff --name-only --diff-filter=A origin/${GITHUB_BASE_REF} $GITHUB_SHA`.split("\n")
@added_files = filter_gem_files_from_diff_names(filepaths: @added_files)
# EXAMPLE: "mini_mime-1.1.2\n"
@removed_files = `git diff --name-only --diff-filter=D origin/${GITHUB_BASE_REF} $GITHUB_SHA`.split("\n")
@removed_files = filter_gem_files_from_diff_names(filepaths: @removed_files)
# EXAMPLE: "src/api/vendor/cache/nokogiri-1.15.3.gem"
@changed_files = `git diff --name-only --diff-filter=C origin/${GITHUB_BASE_REF} $GITHUB_SHA`.split("\n")
@changed_files = filter_gem_files_from_diff_names(filepaths: @changed_files)
end

def filter_gem_files_from_diff_names(filepaths:)
filepaths.filter_map do |filepath|
File.basename(filepath) if File.extname(filepath) == '.gem'
end
end

def create_diffend_io_links

end
end

CreateDiffendIoLinks.new
5 changes: 5 additions & 0 deletions src/api/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ test_rack:
$(eval BUNDLE_RACK_VERSION:=$(shell basename `bundle show rack`))
@if [ "$(SYSTEM_RACK_VERSION)" != "$(BUNDLE_RACK_VERSION)" ]; then echo "rack version mismatch! System: $(SYSTEM_RACK_VERSION) / Bundle: $(BUNDLE_RACK_VERSION)"; exit 1; fi

test_base64_gem:
$(eval RUBY_DEFAULT_BASE64_VERSION:=$(shell gem list --local base64 | grep -Po 'default:\s\K[0-9]\.[0-9]\.[0-9]+'))
$(eval BUNDLE_BASE64_VERSION:=$(shell bundle show base64 | xargs basename | grep -Eo '[0-9]\.[0-9]\.[0-9]+'))
@if [ "$(RUBY_DEFAULT_BASE64_VERSION)" != "$(BUNDLE_BASE64_VERSION)" ]; then echo "base64 version mismatch! System Ruby Default: $(RUBY_DEFAULT_BASE64_VERSION) / Bundle: $(BUNDLE_BASE64_VERSION)"; exit 1; fi

clean:
rm -rf ../../docs/api/html

Expand Down

0 comments on commit fb22db3

Please sign in to comment.