From 190b9b6b78cf5c3dc33356ce56cc2daa06b586d2 Mon Sep 17 00:00:00 2001 From: Gabriel Arjones Date: Wed, 10 Jul 2024 13:53:25 -0300 Subject: [PATCH] chore: fix github workflows --- .github/workflows/lint.yml | 4 +++- .github/workflows/test.yml | 4 ++++ .rubocop.yml | 2 ++ .rubocop_todo.yml | 22 ++++++++++++++++++++++ Gemfile | 7 +++++-- autobuild.gemspec | 8 ++++++-- lib/autobuild/import/archive.rb | 2 +- lib/autobuild/import/git-lfs.rb | 2 +- lib/autobuild/importer.rb | 6 +++--- lib/autobuild/mail_reporter.rb | 6 +++--- lib/autobuild/packages/cmake.rb | 10 +++++----- 11 files changed, 55 insertions(+), 18 deletions(-) create mode 100644 .rubocop_todo.yml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 665569cf..099087a5 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -19,7 +19,9 @@ jobs: uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby-version }} + - name: Remove vscode gems + run: bundle config set --local without vscode - name: Install dependencies run: bundle install - name: Run rubocop - run: bundle exec rubocop \ No newline at end of file + run: bundle exec rubocop diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2e4e55c2..58f606d2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -19,8 +19,12 @@ jobs: uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby-version }} + - name: Remove vscode gems + run: bundle config set --local without vscode - name: Install dependencies run: bundle install + - name: Enable file transport in git + run: git config --global protocol.file.allow always - name: Run tests run: bundle exec rake test env: diff --git a/.rubocop.yml b/.rubocop.yml index 7ce07215..4d88c290 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,3 +1,5 @@ +inherit_from: .rubocop_todo.yml + inherit_gem: rubocop-rock: defaults.yml diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml new file mode 100644 index 00000000..66052c0a --- /dev/null +++ b/.rubocop_todo.yml @@ -0,0 +1,22 @@ +# This configuration was generated by +# `rubocop --auto-gen-config` +# on 2024-07-10 17:48:07 UTC using RuboCop version 1.65.0. +# The point is for the user to remove these configuration records +# one by one as the offenses are removed from the code base. +# Note that changes in the inspected code, or installation of new +# versions of RuboCop, may require this file to be generated again. + +# Offense count: 2 +# Configuration parameters: Severity, Include. +# Include: **/*.gemspec +Gemspec/RubyVersionGlobalsUsage: + Exclude: + - 'autobuild.gemspec' + +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: AllowedReceivers. +# AllowedReceivers: Thread.current +Style/HashEachMethods: + Exclude: + - 'lib/autobuild/reporting.rb' diff --git a/Gemfile b/Gemfile index 18112f58..9b7341d0 100644 --- a/Gemfile +++ b/Gemfile @@ -2,12 +2,15 @@ source 'https://rubygems.org' gemspec +group :lint do + gem 'rubocop', '~> 1.65.0' + gem 'rubocop-rock' +end + group :vscode do gem 'debase', '>= 0.2.2.beta10' gem 'pry' gem 'pry-byebug' - gem 'rubocop', '>= 0.6.0' - gem 'rubocop-rock' gem 'ruby-debug-ide', '>= 0.6.0' gem 'solargraph' end diff --git a/autobuild.gemspec b/autobuild.gemspec index 546fdcdc..ef1cdf9b 100644 --- a/autobuild.gemspec +++ b/autobuild.gemspec @@ -24,7 +24,9 @@ Gem::Specification.new do |s| .reject { |f| f.match(%r{^(test|spec|features)/}) } s.add_runtime_dependency "concurrent-ruby", "~> 1.1" - s.add_runtime_dependency "net-smtp" if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.1.0") + if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.1.0") + s.add_runtime_dependency "net-smtp" + end s.add_runtime_dependency "pastel", "~> 0.7.0" s.add_runtime_dependency "rake", "~> 13.0" s.add_runtime_dependency 'tty-cursor', '~> 0.7.0' @@ -36,5 +38,7 @@ Gem::Specification.new do |s| s.add_development_dependency "minitest", "~> 5.0", ">= 5.0" s.add_development_dependency "simplecov" s.add_development_dependency "timecop" - s.add_development_dependency "webrick" if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.0.0") + if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.0.0") + s.add_development_dependency "webrick" + end end diff --git a/lib/autobuild/import/archive.rb b/lib/autobuild/import/archive.rb index c7f842c4..97fb8525 100644 --- a/lib/autobuild/import/archive.rb +++ b/lib/autobuild/import/archive.rb @@ -537,7 +537,7 @@ def checkout(package, options = Hash.new) # :nodoc: cmd = ['-o', cachefile, '-d', main_dir] package.run(:import, Autobuild.tool('unzip'), *cmd) - archive_dir = (self.archive_dir || File.basename(package.name)) + archive_dir = self.archive_dir || File.basename(package.name) if archive_dir != File.basename(package.srcdir) FileUtils.rm_rf File.join(package.srcdir) FileUtils.mv File.join(base_dir, archive_dir), package.srcdir diff --git a/lib/autobuild/import/git-lfs.rb b/lib/autobuild/import/git-lfs.rb index 4f544027..68e72a33 100644 --- a/lib/autobuild/import/git-lfs.rb +++ b/lib/autobuild/import/git-lfs.rb @@ -38,7 +38,7 @@ def self.lfs_setup(importer, package) end Git.add_post_hook(always: true) do |importer, package| - wants_lfs = (importer.options[:lfs] != false && importer.uses_lfs?(package)) + wants_lfs = importer.options[:lfs] != false && importer.uses_lfs?(package) if wants_lfs && !Git.lfs_installed? Autobuild.warn "#{package.name} uses git LFS but it is not installed, "\ "files may be missing from checkout" diff --git a/lib/autobuild/importer.rb b/lib/autobuild/importer.rb index b45fd390..aea85867 100644 --- a/lib/autobuild/importer.rb +++ b/lib/autobuild/importer.rb @@ -245,9 +245,9 @@ def patches [[@options[:patches], 0]] end - single_patch = (patches.size == 2 && - patches[0].respond_to?(:to_str) && - patches[1].respond_to?(:to_int)) + single_patch = patches.size == 2 && + patches[0].respond_to?(:to_str) && + patches[1].respond_to?(:to_int) patches = [patches] if single_patch patches.map do |obj| diff --git a/lib/autobuild/mail_reporter.rb b/lib/autobuild/mail_reporter.rb index 4d29985a..14baac4f 100644 --- a/lib/autobuild/mail_reporter.rb +++ b/lib/autobuild/mail_reporter.rb @@ -27,13 +27,13 @@ def default_mail def initialize(config) super() - @from_email = (config[:from] || default_mail) - @to_email = (config[:to] || default_mail) + @from_email = config[:from] || default_mail + @to_email = config[:to] || default_mail @subject = config[:subject] || "Build %result% on #{Socket.gethostname} at %time%" @only_errors = config[:only_errors] - @smtp_hostname = (config[:smtp] || "localhost") + @smtp_hostname = config[:smtp] || "localhost" @smtp_port = Integer(config[:port] || Socket.getservbyname('smtp')) end diff --git a/lib/autobuild/packages/cmake.rb b/lib/autobuild/packages/cmake.rb index 82b8e04c..1434e574 100644 --- a/lib/autobuild/packages/cmake.rb +++ b/lib/autobuild/packages/cmake.rb @@ -165,11 +165,11 @@ def define(name, value) end DOXYGEN_ACCEPTED_VARIABLES = { - '@CMAKE_SOURCE_DIR@' => ->(pkg) { pkg.srcdir }, - '@PROJECT_SOURCE_DIR@' => ->(pkg) { pkg.srcdir }, - '@CMAKE_BINARY_DIR@' => ->(pkg) { pkg.builddir }, - '@PROJECT_BINARY_DIR@' => ->(pkg) { pkg.builddir }, - '@PROJECT_NAME@' => ->(pkg) { pkg.name } + '@CMAKE_SOURCE_DIR@' => lambda(&:srcdir), + '@PROJECT_SOURCE_DIR@' => lambda(&:srcdir), + '@CMAKE_BINARY_DIR@' => lambda(&:builddir), + '@PROJECT_BINARY_DIR@' => lambda(&:builddir), + '@PROJECT_NAME@' => lambda(&:name) }.freeze class << self