diff --git a/CHANGELOG.md b/CHANGELOG.md index fa1f164..561f979 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,14 +1,52 @@ -# Changelog for DS API rubygem +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## 1.6.1 - 2025-11 + +### Security + +- Updated dependency versions to address security vulnerabilities: + - Faraday HTTP client updated to 2.14.0 with related middleware + - WebMock, Mocha, and Excon libraries updated to latest secure versions + - Development and linting tools updated to compatible versions + + [#27](https://github.com/epimorphics/data_services_api/issues/27) + +### Added + +- New Make targets for linting, cleaning, asset management, and variable inspection +- Comprehensive help documentation in Makefile + +### Changed + +- Improved gemspec with enhanced metadata and dependency constraints +- Overhauled Makefile with comprehensive build automation +- Upgraded Bundler version for improved dependency management +- Refined file packaging configuration for better gem distribution + +### Fixed + +- Corrected middleware stack ordering in HTTP client to ensure proper error handling +- Updated gem homepage URL and project references for accuracy ## 1.6.0 - 2025-07 -- Update TargetRubyVersion to 3.4 for compatibility -- Refresh dependencies for better stability -- Refactor logging and error handling for clarity -- Enhance JSON parsing reliability -- Revise VCR setups with new HTTP client -- Expand .gitignore to cover more files -- Include Gemfile.lock for consistent dependencies +### Changed + +- Updated TargetRubyVersion to 3.4 for compatibility +- Refreshed dependencies for better stability +- Refactored logging and error handling for clarity +- Enhanced JSON parsing reliability +- Revised VCR setups with new HTTP client +- Expanded .gitignore to cover more files +- Included Gemfile.lock for consistent dependencies + +--- + ## 1.5.4 - 2025-04 diff --git a/Gemfile b/Gemfile index 62884e6..50f09e0 100644 --- a/Gemfile +++ b/Gemfile @@ -2,7 +2,7 @@ source 'https://rubygems.org' -# Specify your gem's dependencies in data-api.gemspec +# Specify the gem's runtime dependencies in data_services_api.gemspec gemspec gem 'byebug', group: %i[development test], require: false diff --git a/Gemfile.lock b/Gemfile.lock index 16abc1c..cb399c1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -2,10 +2,10 @@ PATH remote: . specs: data_services_api (1.6.0) - faraday (~> 2.13) - faraday-encoding (~> 0.0.6) - faraday-follow_redirects (~> 0.3.0) - faraday-retry (~> 2.0) + faraday (~> 2.13, >= 2.13.0) + faraday-encoding (~> 0.0, >= 0.0.6) + faraday-follow_redirects (~> 0.3, >= 0.3.0) + faraday-retry (~> 2.0, >= 2.0) json (~> 2.0) yajl-ruby (~> 1.4) @@ -16,59 +16,59 @@ GEM public_suffix (>= 2.0.2, < 7.0) ast (2.4.3) base64 (0.3.0) - bigdecimal (3.2.2) + bigdecimal (3.3.1) byebug (12.0.0) - crack (1.0.0) + crack (1.0.1) bigdecimal rexml docile (1.4.1) - excon (1.2.8) + excon (1.3.1) logger - faraday (2.13.4) + faraday (2.14.0) faraday-net_http (>= 2.0, < 3.5) json logger faraday-encoding (0.0.6) faraday - faraday-follow_redirects (0.3.0) + faraday-follow_redirects (0.4.0) faraday (>= 1, < 3) - faraday-net_http (3.4.1) - net-http (>= 0.5.0) + faraday-net_http (3.4.2) + net-http (~> 0.5) faraday-retry (2.3.2) faraday (~> 2.0) - hashdiff (1.2.0) - json (2.13.2) + hashdiff (1.2.1) + json (2.16.0) json_expressions (0.9.0) language_server-protocol (3.17.0.5) lint_roller (1.1.0) logger (1.7.0) minispec-metadata (2.0.0) minitest - minitest (5.25.5) + minitest (5.26.1) minitest-rg (5.3.0) minitest (~> 5.0) minitest-vcr (1.4.0) minispec-metadata (~> 2.0) minitest (>= 4.7.5) vcr (>= 2.9) - mocha (2.7.1) + mocha (2.8.0) ruby2_keywords (>= 0.0.5) mutex_m (0.3.0) - net-http (0.6.0) + net-http (0.7.0) uri ostruct (0.6.3) parallel (1.27.0) - parser (3.3.9.0) + parser (3.3.10.0) ast (~> 2.4.1) racc - prism (1.4.0) + prism (1.6.0) public_suffix (6.0.2) racc (1.8.1) rainbow (3.1.1) - rake (13.3.0) - regexp_parser (2.10.0) - rexml (3.4.1) - rubocop (1.79.0) + rake (13.3.1) + regexp_parser (2.11.3) + rexml (3.4.4) + rubocop (1.81.7) json (~> 2.3) language_server-protocol (~> 3.17.0.2) lint_roller (~> 1.1.0) @@ -76,11 +76,10 @@ GEM parser (>= 3.3.0.2) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 2.9.3, < 3.0) - rubocop-ast (>= 1.46.0, < 2.0) + rubocop-ast (>= 1.47.1, < 2.0) ruby-progressbar (~> 1.7) - tsort (>= 0.2.0) unicode-display_width (>= 2.4.0, < 4.0) - rubocop-ast (1.46.0) + rubocop-ast (1.48.0) parser (>= 3.3.7.2) prism (~> 1.4) ruby-progressbar (1.13.0) @@ -91,14 +90,13 @@ GEM simplecov_json_formatter (~> 0.1) simplecov-html (0.13.2) simplecov_json_formatter (0.1.4) - tsort (0.2.0) - unicode-display_width (3.1.4) - unicode-emoji (~> 4.0, >= 4.0.4) - unicode-emoji (4.0.4) - uri (1.0.3) + unicode-display_width (3.2.0) + unicode-emoji (~> 4.1) + unicode-emoji (4.1.0) + uri (1.1.1) vcr (6.3.1) base64 - webmock (3.25.1) + webmock (3.26.1) addressable (>= 2.8.0) crack (>= 0.3.2) hashdiff (>= 0.4.0, < 2.0.0) @@ -126,4 +124,4 @@ DEPENDENCIES webmock BUNDLED WITH - 2.7.0 + 2.7.2 diff --git a/Makefile b/Makefile index 399592c..ea1ad5d 100644 --- a/Makefile +++ b/Makefile @@ -10,8 +10,6 @@ GEM=${NAME}-${VERSION}.gem GPR=https://rubygems.pkg.github.com/${OWNER} SPEC=${NAME}.gemspec -all: publish - ${AUTH}: @mkdir -p ${HOME}/.gem @echo '---' > ${AUTH} @@ -21,25 +19,64 @@ ${AUTH}: ${GEM}: ${SPEC} ./lib/${NAME}/version.rb gem build ${SPEC} +all: publish + +assets: + @echo "Installing assets for ${NAME} gem..." + @bundle install + @echo "Assets for ${NAME} gem are up to date." + auth: ${AUTH} -build: gem +build: clean gem + +checks: lint test + +clean: + @echo "Cleaning up ${NAME} gem..." + @bundle exec rake clean clobber + @rm -rf ${GEM} gem: ${GEM} @echo ${GEM} -test: gem - @bundle install - @bundle exec rake test +help: + @echo "Make targets:" + @echo " all - build the Docker image (default)" + @echo " assets - install gems and yarn packages, compile assets" + @echo " auth - compile the required package registry authorisations" + @echo " build - build the gem package" + @echo " checks - run all linting and tests as a single task" + @echo " clean - remove temporary files" + @echo " gem - show the gem file name" + @echo " help - show this help message" + @echo " lint - run linters" + @echo " publish - release the image to the Docker registry" + @echo " realclean - remove all authentication tokens" + @echo " tags - show the current name, owner and version tags" + @echo " test - runs the test suite, be it units or integration" + @echo " vars - show the current variable settings" + @echo " version - show the current version" + @echo "" + @echo "Environment variables (optional: all variables have defaults):" + @echo " GEM - package name of the gem file (default: ${NAME}-${VERSION}.gem)" + @echo " GPR - GitHub package registry for gem (default: from git config)" + @echo " NAME - name of the Gem (default: from deployment.yaml)" + @echo " PAT - GitHub personal access token (default: prompt)" + @echo " SPEC - gemspec file to use (default: ${NAME}.gemspec)" + @echo " VERSION - version of the application (default: from VERSION file)" + +lint: + @echo "Running code linting for ${NAME} ..." +# Auto-correct offenses safely where possible with the `-a` flag + @bundle exec rubocop -a + @echo "Linting checks completed." publish: ${AUTH} ${GEM} @echo Publishing package ${NAME}:${VERSION} to ${OWNER} ... @gem push --key github --host ${GPR} ${GEM} @echo Done. -clean: - @rm -rf ${GEM} - realclean: clean @rm -rf ${AUTH} @@ -47,3 +84,18 @@ tags: @echo name=${NAME} @echo owner=${OWNER} @echo version=${VERSION} + +test: assets gem + @bundle exec rake test + @echo "Tests completed successfully." + +vars: + @echo "GEM=${GEM}" + @echo "GPR=${GPR}" + @echo "NAME=${NAME}" + @echo "OWNER=${OWNER}" + @echo "SPEC=${SPEC}" + @echo "VERSION=${VERSION}" + +version: + @echo ${VERSION} diff --git a/data_services_api.gemspec b/data_services_api.gemspec index 87c74de..deaa05a 100644 --- a/data_services_api.gemspec +++ b/data_services_api.gemspec @@ -1,9 +1,6 @@ # frozen_string_literal: true -lib = File.expand_path('lib', __dir__) -$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) - -require 'data_services_api/version' +require_relative 'lib/data_services_api/version' Gem::Specification.new do |spec| spec.name = 'data_services_api' @@ -12,20 +9,27 @@ Gem::Specification.new do |spec| spec.email = ['info@epimorphics.com'] spec.summary = 'Data Services API' spec.description = 'Ruby wrapper for Epimorphics Data Services API' - spec.homepage = 'https://github.com/epimorphics/data-API-ruby' + spec.homepage = 'https://github.com/epimorphics/data_services_api' spec.license = 'MIT' spec.required_ruby_version = '>= 3.4' - spec.files = `git ls-files -z`.split("\x0") + spec.files = Dir.glob('lib/**/*', File::FNM_DOTMATCH) + ['LICENSE.txt', 'README.md'] spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } + spec.extra_rdoc_files = Dir['README.md', 'CHANGELOG.md', 'LICENSE.txt'] spec.require_paths = ['lib'] - spec.metadata['rubygems_mfa_required'] = 'true' + spec.metadata = { + 'bug_tracker_uri' => 'https://github.com/epimorphics/data_services_api/issues', + 'changelog_uri' => 'https://github.com/epimorphics/data_services_api/blob/main/CHANGELOG.md', + 'documentation_uri' => 'https://www.rubydoc.info/gems/data_services_api', + 'homepage_uri' => spec.homepage, + 'rubygems_mfa_required' => 'true' + } - spec.add_dependency 'faraday', '~> 2.13' - spec.add_dependency 'faraday-encoding', '~> 0.0.6' - spec.add_dependency 'faraday-follow_redirects', '~> 0.3.0' - spec.add_dependency 'faraday-retry', '~> 2.0' + spec.add_dependency 'faraday', '~> 2.13', '>= 2.13.0' + spec.add_dependency 'faraday-encoding', '~> 0.0', '>= 0.0.6' + spec.add_dependency 'faraday-follow_redirects', '~> 0.3', '>= 0.3.0' + spec.add_dependency 'faraday-retry', '~> 2.0', '>= 2.0' spec.add_dependency 'json', '~> 2.0' spec.add_dependency 'yajl-ruby', '~> 1.4' end diff --git a/lib/data_services_api/service.rb b/lib/data_services_api/service.rb index 96226db..492acbe 100644 --- a/lib/data_services_api/service.rb +++ b/lib/data_services_api/service.rb @@ -169,10 +169,12 @@ def create_http_connection(http_url, auth = false) # rubocop:disable Metrics/Met # instrument the request to log the time it takes to complete but only if we're in a Rails environment config.request :instrumentation, name: 'requests.api' if in_rails? config.request :retry, retry_options - with_logger_in_rails(config) config.response :json + # ! Since responses are processed by the middleware stack in reverse order config.response :raise_error + # ! Passing the logger in last ensures that errors are logged before the exception is raised. + with_logger_in_rails(config) end end diff --git a/lib/data_services_api/version.rb b/lib/data_services_api/version.rb index 35ddafa..c2dfeaa 100644 --- a/lib/data_services_api/version.rb +++ b/lib/data_services_api/version.rb @@ -4,7 +4,7 @@ module DataServicesApi MAJOR = 1 MINOR = 6 - PATCH = 0 + PATCH = 1 SUFFIX = nil VERSION = "#{MAJOR}.#{MINOR}.#{PATCH}#{SUFFIX && ".#{SUFFIX}"}".freeze end