From 03461151d610b044ba5619761cb2e13182de95ae Mon Sep 17 00:00:00 2001 From: Robert Waffen Date: Fri, 25 Nov 2022 13:46:23 +0100 Subject: [PATCH 01/18] we dont do travis --- .travis.yml | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 35ca81b3..00000000 --- a/.travis.yml +++ /dev/null @@ -1,14 +0,0 @@ -language: ruby -dist: focal -rvm: 2.5.8 - -cache: - bundler: true - -before_install: - - yes | gem update --system --force - - gem install bundler - -install: - - bundle install - - cp config/hdm.yml.template config/hdm.yml From 650935442a5c2d237425ad12ec3ee094d2c6522a Mon Sep 17 00:00:00 2001 From: Robert Waffen Date: Fri, 25 Nov 2022 13:47:02 +0100 Subject: [PATCH 02/18] update gems and cleanup comments --- Gemfile | 18 +--- Gemfile.lock | 254 ++++++++++++++++++++++++--------------------------- 2 files changed, 122 insertions(+), 150 deletions(-) diff --git a/Gemfile b/Gemfile index 5f13cedc..58f1ea9a 100644 --- a/Gemfile +++ b/Gemfile @@ -6,9 +6,9 @@ ruby '3.1.2' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '~> 7.0.0' # Use sqlite3 as the database for Active Record -gem 'sqlite3', '~> 1.4' +gem 'sqlite3', '~> 1.5' # Use Puma as the app server -gem 'puma', '~> 5.6' +gem 'puma', '~> 6.0' # Asset handling gem 'sprockets-rails' @@ -20,23 +20,17 @@ gem 'bootstrap', '~> 4.6.0' gem 'bootstrap-icons-helper' gem 'jquery-rails' -# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder -# gem 'jbuilder', '~> 2.7' # Use Redis adapter to run Action Cable in production -gem 'redis', '~> 4.0' +gem 'redis', '~> 5.0' # Use Active Model has_secure_password -gem 'bcrypt', '~> 3.1.7' +gem 'bcrypt', '~> 3.1' gem 'faker' -gem 'friendly_id', '~> 5.4.0' +gem 'friendly_id', '~> 5.5' gem 'puppet' gem 'puppetdb-ruby', require: 'puppetdb' gem 'hiera-eyaml' gem 'net-ldap', require: "net/ldap" - -# Use Active Storage variant -# gem 'image_processing', '~> 1.2' - gem 'breadcrumbs_on_rails' gem 'cancancan' @@ -70,10 +64,8 @@ end # Windows does not include zoneinfo files, so bundle the tzinfo-data gem gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] -# Professional version only gems gem 'git' gem 'gitable', require: "gitable/uri" # dependencies & sec fixes -# gem "nokogiri", ">= 1.13.2" # needs ruby >= 2.6.0 gem 'mini_racer' # minimal Google V8 JS engine for execjs diff --git a/Gemfile.lock b/Gemfile.lock index c6316000..057560b7 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -2,81 +2,81 @@ GEM remote: https://rubygems.org/ specs: CFPropertyList (2.3.6) - actioncable (7.0.3.1) - actionpack (= 7.0.3.1) - activesupport (= 7.0.3.1) + actioncable (7.0.4) + actionpack (= 7.0.4) + activesupport (= 7.0.4) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (7.0.3.1) - actionpack (= 7.0.3.1) - activejob (= 7.0.3.1) - activerecord (= 7.0.3.1) - activestorage (= 7.0.3.1) - activesupport (= 7.0.3.1) + actionmailbox (7.0.4) + actionpack (= 7.0.4) + activejob (= 7.0.4) + activerecord (= 7.0.4) + activestorage (= 7.0.4) + activesupport (= 7.0.4) mail (>= 2.7.1) net-imap net-pop net-smtp - actionmailer (7.0.3.1) - actionpack (= 7.0.3.1) - actionview (= 7.0.3.1) - activejob (= 7.0.3.1) - activesupport (= 7.0.3.1) + actionmailer (7.0.4) + actionpack (= 7.0.4) + actionview (= 7.0.4) + activejob (= 7.0.4) + activesupport (= 7.0.4) mail (~> 2.5, >= 2.5.4) net-imap net-pop net-smtp rails-dom-testing (~> 2.0) - actionpack (7.0.3.1) - actionview (= 7.0.3.1) - activesupport (= 7.0.3.1) + actionpack (7.0.4) + actionview (= 7.0.4) + activesupport (= 7.0.4) rack (~> 2.0, >= 2.2.0) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (7.0.3.1) - actionpack (= 7.0.3.1) - activerecord (= 7.0.3.1) - activestorage (= 7.0.3.1) - activesupport (= 7.0.3.1) + actiontext (7.0.4) + actionpack (= 7.0.4) + activerecord (= 7.0.4) + activestorage (= 7.0.4) + activesupport (= 7.0.4) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.0.3.1) - activesupport (= 7.0.3.1) + actionview (7.0.4) + activesupport (= 7.0.4) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.1, >= 1.2.0) - activejob (7.0.3.1) - activesupport (= 7.0.3.1) + activejob (7.0.4) + activesupport (= 7.0.4) globalid (>= 0.3.6) - activemodel (7.0.3.1) - activesupport (= 7.0.3.1) - activerecord (7.0.3.1) - activemodel (= 7.0.3.1) - activesupport (= 7.0.3.1) - activestorage (7.0.3.1) - actionpack (= 7.0.3.1) - activejob (= 7.0.3.1) - activerecord (= 7.0.3.1) - activesupport (= 7.0.3.1) + activemodel (7.0.4) + activesupport (= 7.0.4) + activerecord (7.0.4) + activemodel (= 7.0.4) + activesupport (= 7.0.4) + activestorage (7.0.4) + actionpack (= 7.0.4) + activejob (= 7.0.4) + activerecord (= 7.0.4) + activesupport (= 7.0.4) marcel (~> 1.0) mini_mime (>= 1.1.0) - activesupport (7.0.3.1) + activesupport (7.0.4) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) tzinfo (~> 2.0) - addressable (2.8.0) - public_suffix (>= 2.0.2, < 5.0) + addressable (2.8.1) + public_suffix (>= 2.0.2, < 6.0) ast (2.4.2) - autoprefixer-rails (10.4.2.0) + autoprefixer-rails (10.4.7.0) execjs (~> 2) - bcrypt (3.1.17) + bcrypt (3.1.18) bindex (0.8.1) - bootstrap (4.6.1) + bootstrap (4.6.2) autoprefixer-rails (>= 9.1.0) - popper_js (>= 1.14.3, < 2) + popper_js (>= 1.16.1, < 2) sassc-rails (>= 2.0.0) bootstrap-icons (1.0.12) nokogiri (~> 1) @@ -87,8 +87,8 @@ GEM railties (>= 5.0) builder (3.2.4) byebug (11.1.3) - cancancan (3.3.0) - capybara (3.36.0) + cancancan (3.4.0) + capybara (3.38.0) addressable matrix mini_mime (>= 0.1.3) @@ -99,15 +99,15 @@ GEM xpath (~> 3.2) childprocess (4.1.0) concurrent-ruby (1.1.10) + connection_pool (2.3.0) crass (1.0.6) - dartsass-rails (0.3.0) + dartsass-rails (0.4.0) railties (>= 6.0.0) deep_merge (1.2.2) - digest (3.1.0) docile (1.4.0) erubi (1.11.0) execjs (2.8.1) - facter (4.2.9) + facter (4.2.13) hocon (~> 1.3) thor (>= 1.0.1, < 2.0) factory_bot (6.2.1) @@ -115,20 +115,21 @@ GEM factory_bot_rails (6.2.0) factory_bot (~> 6.2.0) railties (>= 5.0.0) - faker (2.20.0) + faker (3.0.0) i18n (>= 1.8.11, < 2) fast_gettext (2.2.0) ffi (1.15.5) - friendly_id (5.4.2) + friendly_id (5.5.0) activerecord (>= 4.0.0) - git (1.11.0) + git (1.12.0) + addressable (~> 2.8) rchardet (~> 1.8) gitable (0.4.0) addressable (~> 2.2, >= 2.2.7) globalid (1.0.0) activesupport (>= 5.0) - hiera (3.9.0) - hiera-eyaml (3.2.2) + hiera (3.10.0) + hiera-eyaml (3.3.0) highline optimist highline (2.0.3) @@ -138,21 +139,20 @@ GEM multi_xml (>= 0.5.2) i18n (1.12.0) concurrent-ruby (~> 1.0) - importmap-rails (1.0.3) + importmap-rails (1.1.5) actionpack (>= 6.0.0) railties (>= 6.0.0) - jquery-rails (4.4.0) + jquery-rails (4.5.1) rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) - libv8-node (16.10.0.0) + json (2.6.2) libv8-node (16.10.0.0-x86_64-darwin) - libv8-node (16.10.0.0-x86_64-linux) listen (3.7.1) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) locale (2.1.3) - loofah (2.18.0) + loofah (2.19.0) crass (~> 1.0.2) nokogiri (>= 1.5.9) mail (2.7.1) @@ -164,55 +164,32 @@ GEM mime-types-data (~> 3.2015) mime-types-data (3.2022.0105) mini_mime (1.1.2) - mini_portile2 (2.8.0) - mini_racer (0.6.2) + mini_racer (0.6.3) libv8-node (~> 16.10.0.0) minitest (5.16.3) multi_json (1.15.0) multi_xml (0.6.0) - net-imap (0.2.3) - digest + net-imap (0.3.1) net-protocol - strscan - net-ldap (0.17.0) - net-pop (0.1.1) - digest + net-ldap (0.17.1) + net-pop (0.1.2) net-protocol - timeout net-protocol (0.1.3) timeout - net-smtp (0.3.1) - digest + net-smtp (0.3.3) net-protocol - timeout nio4r (2.5.8) - nokogiri (1.13.9) - mini_portile2 (~> 2.8.0) - racc (~> 1.4) nokogiri (1.13.9-x86_64-darwin) racc (~> 1.4) - nokogiri (1.13.9-x86_64-linux) - racc (~> 1.4) optimist (3.0.1) parallel (1.22.1) - parser (3.1.2.0) + parser (3.1.2.1) ast (~> 2.4.1) - popper_js (1.16.0) - public_suffix (4.0.7) - puma (5.6.4) + popper_js (1.16.1) + public_suffix (5.0.0) + puma (6.0.0) nio4r (~> 2.0) - puppet (7.16.0) - concurrent-ruby (~> 1.0) - deep_merge (~> 1.0) - facter (> 2.0.1, < 5) - fast_gettext (>= 1.1, < 3) - hiera (>= 3.2.1, < 4) - locale (~> 2.1) - multi_json (~> 1.10) - puppet-resource_api (~> 1.5) - scanf (~> 1.0) - semantic_puppet (~> 1.0) - puppet (7.16.0-universal-darwin) + puppet (7.20.0-universal-darwin) CFPropertyList (~> 2.2) concurrent-ruby (~> 1.0) deep_merge (~> 1.0) @@ -232,56 +209,60 @@ GEM rack (2.2.4) rack-test (2.0.2) rack (>= 1.3) - rails (7.0.3.1) - actioncable (= 7.0.3.1) - actionmailbox (= 7.0.3.1) - actionmailer (= 7.0.3.1) - actionpack (= 7.0.3.1) - actiontext (= 7.0.3.1) - actionview (= 7.0.3.1) - activejob (= 7.0.3.1) - activemodel (= 7.0.3.1) - activerecord (= 7.0.3.1) - activestorage (= 7.0.3.1) - activesupport (= 7.0.3.1) + rails (7.0.4) + actioncable (= 7.0.4) + actionmailbox (= 7.0.4) + actionmailer (= 7.0.4) + actionpack (= 7.0.4) + actiontext (= 7.0.4) + actionview (= 7.0.4) + activejob (= 7.0.4) + activemodel (= 7.0.4) + activerecord (= 7.0.4) + activestorage (= 7.0.4) + activesupport (= 7.0.4) bundler (>= 1.15.0) - railties (= 7.0.3.1) + railties (= 7.0.4) rails-dom-testing (2.0.3) activesupport (>= 4.2.0) nokogiri (>= 1.6) rails-html-sanitizer (1.4.3) loofah (~> 2.3) - railties (7.0.3.1) - actionpack (= 7.0.3.1) - activesupport (= 7.0.3.1) + railties (7.0.4) + actionpack (= 7.0.4) + activesupport (= 7.0.4) method_source rake (>= 12.2) thor (~> 1.0) zeitwerk (~> 2.5) rainbow (3.1.1) rake (13.0.6) - rb-fsevent (0.11.1) + rb-fsevent (0.11.2) rb-inotify (0.10.1) ffi (~> 1.0) rchardet (1.8.0) - redis (4.6.0) - regexp_parser (2.3.1) + redis (5.0.5) + redis-client (>= 0.9.0) + redis-client (0.11.2) + connection_pool + regexp_parser (2.6.1) rexml (3.2.5) - rubocop (1.28.2) + rubocop (1.39.0) + json (~> 2.3) parallel (~> 1.10) - parser (>= 3.1.0.0) + parser (>= 3.1.2.1) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) - rexml - rubocop-ast (>= 1.17.0, < 2.0) + rexml (>= 3.2.5, < 4.0) + rubocop-ast (>= 1.23.0, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 1.4.0, < 3.0) - rubocop-ast (1.17.0) + rubocop-ast (1.23.0) parser (>= 3.1.1.0) - rubocop-rails (2.14.2) + rubocop-rails (2.17.3) activesupport (>= 4.2.0) rack (>= 1.1) - rubocop (>= 1.7.0, < 2.0) + rubocop (>= 1.33.0, < 2.0) rubocop-rake (0.6.0) rubocop (~> 1.0) ruby-progressbar (1.11.0) @@ -295,10 +276,11 @@ GEM sprockets-rails tilt scanf (1.0.0) - selenium-webdriver (4.1.0) + selenium-webdriver (4.6.1) childprocess (>= 0.5, < 5.0) rexml (~> 3.2, >= 3.2.5) - rubyzip (>= 1.2.2) + rubyzip (>= 1.2.2, < 3.0) + websocket (~> 1.0) semantic_puppet (1.0.4) simplecov (0.21.2) docile (~> 1.1) @@ -306,49 +288,48 @@ GEM simplecov_json_formatter (~> 0.1) simplecov-html (0.12.3) simplecov_json_formatter (0.1.4) - sprockets (4.0.3) + sprockets (4.1.1) concurrent-ruby (~> 1.0) rack (> 1, < 3) sprockets-rails (3.4.2) actionpack (>= 5.2) activesupport (>= 5.2) sprockets (>= 3.0.0) - sqlite3 (1.4.2) - stimulus-rails (1.0.4) + sqlite3 (1.5.4-x86_64-darwin) + stimulus-rails (1.1.1) railties (>= 6.0.0) - strscan (3.0.4) thor (1.2.1) - tilt (2.0.10) + tilt (2.0.11) timeout (0.3.0) - turbo-rails (1.0.1) + turbo-rails (1.3.2) actionpack (>= 6.0.0) + activejob (>= 6.0.0) railties (>= 6.0.0) tzinfo (2.0.5) concurrent-ruby (~> 1.0) - unicode-display_width (2.1.0) + unicode-display_width (2.3.0) web-console (4.2.0) actionview (>= 6.0.0) activemodel (>= 6.0.0) bindex (>= 0.4.0) railties (>= 6.0.0) - webdrivers (5.0.0) + webdrivers (5.2.0) nokogiri (~> 1.6) rubyzip (>= 1.3.0) selenium-webdriver (~> 4.0) + websocket (1.2.9) websocket-driver (0.7.5) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) xpath (3.2.0) nokogiri (~> 1.8) - zeitwerk (2.6.0) + zeitwerk (2.6.6) PLATFORMS - ruby x86_64-darwin-21 - x86_64-linux DEPENDENCIES - bcrypt (~> 3.1.7) + bcrypt (~> 3.1) bootstrap (~> 4.6.0) bootstrap-icons-helper breadcrumbs_on_rails @@ -358,7 +339,7 @@ DEPENDENCIES dartsass-rails factory_bot_rails faker - friendly_id (~> 5.4.0) + friendly_id (~> 5.5) git gitable hiera-eyaml @@ -367,21 +348,20 @@ DEPENDENCIES listen (~> 3.2) mini_racer net-ldap - puma (~> 5.6) + puma (~> 6.0) puppet puppetdb-ruby rails (~> 7.0.0) - redis (~> 4.0) + redis (~> 5.0) rubocop rubocop-rails rubocop-rake selenium-webdriver simplecov sprockets-rails - sqlite3 (~> 1.4) + sqlite3 (~> 1.5) stimulus-rails turbo-rails - tzinfo-data web-console (>= 3.3.0) webdrivers @@ -389,4 +369,4 @@ RUBY VERSION ruby 3.1.2p20 BUNDLED WITH - 2.3.11 + 2.3.7 From 0b95516b711a6171a55269c020532a9350fef269 Mon Sep 17 00:00:00 2001 From: Robert Waffen Date: Fri, 25 Nov 2022 13:48:28 +0100 Subject: [PATCH 03/18] update docker build - switch to rails production --- Dockerfile | 11 ++++++++--- bin/entry.sh | 3 --- config/application.rb | 2 ++ docker-compose.yaml | 2 +- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index e082d192..33aebd77 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,15 +18,20 @@ RUN apk add --update --no-cache \ git \ tzdata -# RUN gem install bundler -v 2.3.11 - ENV APP_HOME /hdm +ENV RAILS_ENV production +ENV RAILS_SERVE_STATIC_FILES true +ENV RAILS_LOG_TO_STDOUT true + WORKDIR $APP_HOME COPY . $APP_HOME COPY config/hdm.yml.template $APP_HOME/config/hdm.yml -RUN bundle check || (bundle config set --local without 'test' && bundle install) +RUN bundle check || (bundle config set --local without 'development test linter' && bundle install) +# RUN bundle exec rake assets:precompile # does not work on alpine +RUN bundle exec rake db:create +RUN bundle exec rake db:migrate EXPOSE 3000 diff --git a/bin/entry.sh b/bin/entry.sh index 17267961..b7fc03ff 100755 --- a/bin/entry.sh +++ b/bin/entry.sh @@ -1,8 +1,5 @@ #!/usr/bin/env sh -bundle exec rails db:create -bundle exec rails db:migrate - if [ "${DEVELOP}" -eq 1 ]; then bundle exec rails db:seed ./bin/fake_puppet_db & diff --git a/config/application.rb b/config/application.rb index c4062d29..424bfed4 100644 --- a/config/application.rb +++ b/config/application.rb @@ -22,6 +22,8 @@ class Application < Rails::Application config.generators.assets = nil config.generators.helper = nil + config.active_record.sqlite3_production_warning=false + config.hdm = config_for(:hdm) end end diff --git a/docker-compose.yaml b/docker-compose.yaml index d40277b3..dc915d11 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -2,7 +2,7 @@ version: "3.5" services: hdm: - image: ghcr.io/betadots/hdm:main + image: ghcr.io/betadots/hdm:latest container_name: hdm environment: - TZ=Europe/Berlin From fbf1574572eaa73f4b88eff10108a90ebc48bd36 Mon Sep 17 00:00:00 2001 From: Robert Waffen Date: Fri, 25 Nov 2022 14:15:40 +0100 Subject: [PATCH 04/18] change back to create/migrate db on every container start - makes it update compatible - makes sure it runs if someone mounts a volume over the pre-created db --- Dockerfile | 2 -- bin/entry.sh | 3 +++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 33aebd77..b2d849b5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -30,8 +30,6 @@ COPY config/hdm.yml.template $APP_HOME/config/hdm.yml RUN bundle check || (bundle config set --local without 'development test linter' && bundle install) # RUN bundle exec rake assets:precompile # does not work on alpine -RUN bundle exec rake db:create -RUN bundle exec rake db:migrate EXPOSE 3000 diff --git a/bin/entry.sh b/bin/entry.sh index b7fc03ff..b03dd51b 100755 --- a/bin/entry.sh +++ b/bin/entry.sh @@ -1,5 +1,8 @@ #!/usr/bin/env sh +bundle exec rake db:create +bundle exec rake db:migrate + if [ "${DEVELOP}" -eq 1 ]; then bundle exec rails db:seed ./bin/fake_puppet_db & From c4e9ece0fa2d0f33cb0802e5ad9410a7f6029dc4 Mon Sep 17 00:00:00 2001 From: Robert Waffen Date: Fri, 25 Nov 2022 14:19:30 +0100 Subject: [PATCH 05/18] add linux to bundle lock --- Gemfile.lock | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Gemfile.lock b/Gemfile.lock index 057560b7..4d41974b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -148,6 +148,7 @@ GEM thor (>= 0.14, < 2.0) json (2.6.2) libv8-node (16.10.0.0-x86_64-darwin) + libv8-node (16.10.0.0-x86_64-linux) listen (3.7.1) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) @@ -181,6 +182,8 @@ GEM nio4r (2.5.8) nokogiri (1.13.9-x86_64-darwin) racc (~> 1.4) + nokogiri (1.13.9-x86_64-linux) + racc (~> 1.4) optimist (3.0.1) parallel (1.22.1) parser (3.1.2.1) @@ -189,6 +192,17 @@ GEM public_suffix (5.0.0) puma (6.0.0) nio4r (~> 2.0) + puppet (7.20.0) + concurrent-ruby (~> 1.0) + deep_merge (~> 1.0) + facter (> 2.0.1, < 5) + fast_gettext (>= 1.1, < 3) + hiera (>= 3.2.1, < 4) + locale (~> 2.1) + multi_json (~> 1.10) + puppet-resource_api (~> 1.5) + scanf (~> 1.0) + semantic_puppet (~> 1.0) puppet (7.20.0-universal-darwin) CFPropertyList (~> 2.2) concurrent-ruby (~> 1.0) @@ -296,6 +310,7 @@ GEM activesupport (>= 5.2) sprockets (>= 3.0.0) sqlite3 (1.5.4-x86_64-darwin) + sqlite3 (1.5.4-x86_64-linux) stimulus-rails (1.1.1) railties (>= 6.0.0) thor (1.2.1) @@ -327,6 +342,7 @@ GEM PLATFORMS x86_64-darwin-21 + x86_64-linux DEPENDENCIES bcrypt (~> 3.1) @@ -362,6 +378,7 @@ DEPENDENCIES sqlite3 (~> 1.5) stimulus-rails turbo-rails + tzinfo-data web-console (>= 3.3.0) webdrivers From 915f51dbf77bf6bd5ed5e105d27c97d4a903dc35 Mon Sep 17 00:00:00 2001 From: Robert Waffen Date: Fri, 25 Nov 2022 14:25:09 +0100 Subject: [PATCH 06/18] add plattform ruby again to Gemfile.lock --- Gemfile.lock | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Gemfile.lock b/Gemfile.lock index 4d41974b..4be03240 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -147,6 +147,7 @@ GEM railties (>= 4.2.0) thor (>= 0.14, < 2.0) json (2.6.2) + libv8-node (16.10.0.0) libv8-node (16.10.0.0-x86_64-darwin) libv8-node (16.10.0.0-x86_64-linux) listen (3.7.1) @@ -165,6 +166,7 @@ GEM mime-types-data (~> 3.2015) mime-types-data (3.2022.0105) mini_mime (1.1.2) + mini_portile2 (2.8.0) mini_racer (0.6.3) libv8-node (~> 16.10.0.0) minitest (5.16.3) @@ -180,6 +182,9 @@ GEM net-smtp (0.3.3) net-protocol nio4r (2.5.8) + nokogiri (1.13.9) + mini_portile2 (~> 2.8.0) + racc (~> 1.4) nokogiri (1.13.9-x86_64-darwin) racc (~> 1.4) nokogiri (1.13.9-x86_64-linux) @@ -309,6 +314,8 @@ GEM actionpack (>= 5.2) activesupport (>= 5.2) sprockets (>= 3.0.0) + sqlite3 (1.5.4) + mini_portile2 (~> 2.8.0) sqlite3 (1.5.4-x86_64-darwin) sqlite3 (1.5.4-x86_64-linux) stimulus-rails (1.1.1) @@ -341,6 +348,7 @@ GEM zeitwerk (2.6.6) PLATFORMS + ruby x86_64-darwin-21 x86_64-linux From 79a04914b88a0575915cb008aef00c2acc699b88 Mon Sep 17 00:00:00 2001 From: Robert Waffen Date: Fri, 25 Nov 2022 14:30:43 +0100 Subject: [PATCH 07/18] rubcop demands change from map to pluck - @oneiros can you say if this is the same? --- app/services/puppet_db_client.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/services/puppet_db_client.rb b/app/services/puppet_db_client.rb index fb73ee9a..bb45a350 100644 --- a/app/services/puppet_db_client.rb +++ b/app/services/puppet_db_client.rb @@ -32,7 +32,8 @@ def environments nil, {} ) - response.data.map { |x| x["name"] } + # response.data.map { |x| x["name"] } + response.data.pluck('name') rescue => e raise Hdm::Error, e end From 0e8a8a6d183a6fdeca888c3bf3b742505dace918 Mon Sep 17 00:00:00 2001 From: Robert Waffen Date: Fri, 25 Nov 2022 14:31:33 +0100 Subject: [PATCH 08/18] use FileUtils - rubocops demands this - it is easier to use --- app/models/hiera_data/git_repo.rb | 2 +- test/test_helper.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/hiera_data/git_repo.rb b/app/models/hiera_data/git_repo.rb index 29114a96..056c2c38 100644 --- a/app/models/hiera_data/git_repo.rb +++ b/app/models/hiera_data/git_repo.rb @@ -24,7 +24,7 @@ def local_path private def setup_repo - Dir.mkdir(BASE_PATH) unless File.exist?(BASE_PATH) + FileUtils.mkdir_p(BASE_PATH) if File.exist?(local_path) Git.open(local_path) else diff --git a/test/test_helper.rb b/test/test_helper.rb index 76ff700d..eb7547ec 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -27,10 +27,10 @@ class ActiveSupport::TestCase # Add more helper methods to be used by all tests here... def with_temp_file(path, &block) begin - File.unlink(path) if File.exist?(path) + FileUtils.rm_f(path) yield ensure - File.unlink(path) if File.exist?(path) + FileUtils.rm_f(path) end end From 564fc845566a471a3fe99392f72098345809369c Mon Sep 17 00:00:00 2001 From: Robert Waffen Date: Mon, 12 Dec 2022 09:47:28 +0100 Subject: [PATCH 09/18] update with recommendations --- Gemfile | 4 ++-- app/services/puppet_db_client.rb | 1 - bin/entry.sh | 3 +-- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/Gemfile b/Gemfile index 58f1ea9a..d6fde8bc 100644 --- a/Gemfile +++ b/Gemfile @@ -23,10 +23,10 @@ gem 'jquery-rails' # Use Redis adapter to run Action Cable in production gem 'redis', '~> 5.0' # Use Active Model has_secure_password -gem 'bcrypt', '~> 3.1' +gem 'bcrypt', '~> 3.1.7' gem 'faker' -gem 'friendly_id', '~> 5.5' +gem 'friendly_id', '~> 5.5.0' gem 'puppet' gem 'puppetdb-ruby', require: 'puppetdb' gem 'hiera-eyaml' diff --git a/app/services/puppet_db_client.rb b/app/services/puppet_db_client.rb index bb45a350..711499ac 100644 --- a/app/services/puppet_db_client.rb +++ b/app/services/puppet_db_client.rb @@ -32,7 +32,6 @@ def environments nil, {} ) - # response.data.map { |x| x["name"] } response.data.pluck('name') rescue => e raise Hdm::Error, e diff --git a/bin/entry.sh b/bin/entry.sh index b03dd51b..58577288 100755 --- a/bin/entry.sh +++ b/bin/entry.sh @@ -1,7 +1,6 @@ #!/usr/bin/env sh -bundle exec rake db:create -bundle exec rake db:migrate +bundle exec rake db:setup if [ "${DEVELOP}" -eq 1 ]; then bundle exec rails db:seed From d198de782ad01054f039ca02fa71dbde67806b4d Mon Sep 17 00:00:00 2001 From: Robert Waffen Date: Tue, 13 Dec 2022 10:57:31 +0100 Subject: [PATCH 10/18] update Gemfile.lock according to Gemfile --- Gemfile.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index ffae87c3..49eec500 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -353,7 +353,7 @@ PLATFORMS x86_64-linux DEPENDENCIES - bcrypt (~> 3.1) + bcrypt (~> 3.1.7) bootstrap (~> 4.6.0) bootstrap-icons-helper breadcrumbs_on_rails @@ -363,7 +363,7 @@ DEPENDENCIES dartsass-rails factory_bot_rails faker - friendly_id (~> 5.5) + friendly_id (~> 5.5.0) git gitable hiera-eyaml From d7504949f013143bce482f5db56525da5bc364a3 Mon Sep 17 00:00:00 2001 From: Robert Waffen Date: Tue, 13 Dec 2022 11:14:15 +0100 Subject: [PATCH 11/18] adjust to strange rubocop recommendations. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - didnt touch the files in the first place - they are not offended in main branch - rubocop only complains in my branch - ¯\_(ツ)_/¯ --- app/controllers/application_controller.rb | 2 +- app/controllers/groups_controller.rb | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index e3942624..2d01b2db 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -46,6 +46,6 @@ def display_error_page(error) end def access_denied - render file: Rails.root.join("public/403.html"), status: :forbidden, layout: false + render file: Rails.public_path.join('403.html'), status: :forbidden, layout: false end end diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb index 1ea837a9..4aa44057 100644 --- a/app/controllers/groups_controller.rb +++ b/app/controllers/groups_controller.rb @@ -18,6 +18,12 @@ def new @group = Group.new end + def edit + add_breadcrumb "Groups", :groups_path + add_breadcrumb @group.name, group_path(@group) + add_breadcrumb "Edit", edit_group_path(@group) + end + def create @group = Group.new(group_params) @@ -28,12 +34,6 @@ def create end end - def edit - add_breadcrumb "Groups", :groups_path - add_breadcrumb @group.name, group_path(@group) - add_breadcrumb "Edit", edit_group_path(@group) - end - def update if @group.update(group_params) redirect_to @group, notice: "Group was updated successfully." From 26205ba4760c86378339d0fe5e3bfe5016d4d672 Mon Sep 17 00:00:00 2001 From: Robert Waffen Date: Tue, 13 Dec 2022 16:02:41 +0100 Subject: [PATCH 12/18] switch to ruby:3.1.3-slim --- Dockerfile | 21 ++++++++++----------- Gemfile | 5 +++-- Gemfile.lock | 2 +- bin/entry.sh | 4 ++-- config/hdm.yml.template | 19 ++++++------------- 5 files changed, 22 insertions(+), 29 deletions(-) diff --git a/Dockerfile b/Dockerfile index b2d849b5..297bb43d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,22 +1,21 @@ -FROM ruby:3.1.2-alpine +FROM ruby:3.1.3-slim-bullseye -RUN apk add --update --no-cache \ - binutils-gold \ - build-base \ +RUN apt update && apt install -y \ g++ \ gcc \ - libstdc++ \ + make \ + libstdc++-10-dev \ libffi-dev \ libc-dev \ libxml2-dev \ libxslt-dev \ libgcrypt-dev \ - make \ - sqlite \ - sqlite-dev \ + libsqlite3-dev \ + sqlite3 \ # not needed for gems, but for runtime git \ - tzdata + tzdata \ + && rm -rf /var/lib/apt/lists/* ENV APP_HOME /hdm ENV RAILS_ENV production @@ -28,8 +27,8 @@ WORKDIR $APP_HOME COPY . $APP_HOME COPY config/hdm.yml.template $APP_HOME/config/hdm.yml -RUN bundle check || (bundle config set --local without 'development test linter' && bundle install) -# RUN bundle exec rake assets:precompile # does not work on alpine +RUN bundle check || (bundle config set --local without 'development test' && bundle install) +RUN bundle exec rake assets:clean && bundle exec rake assets:clobber && bundle exec rake assets:precompile EXPOSE 3000 diff --git a/Gemfile b/Gemfile index d6fde8bc..db55d510 100644 --- a/Gemfile +++ b/Gemfile @@ -1,7 +1,7 @@ source 'https://rubygems.org' git_source(:github) { |repo| "https://github.com/#{repo}.git" } -ruby '3.1.2' +ruby '3.1.3' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '~> 7.0.0' @@ -44,9 +44,10 @@ end group :development do # Access an interactive console on exception pages or by calling 'console' anywhere in the code. gem 'web-console', '>= 3.3.0' - gem 'listen', '~> 3.2' end +gem 'listen', '~> 3.2' # need for rake to precompile assets + group :test do # Adds support for Capybara system testing and selenium driver gem 'capybara', '>= 2.15' diff --git a/Gemfile.lock b/Gemfile.lock index 49eec500..30f63ed6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -391,7 +391,7 @@ DEPENDENCIES webdrivers RUBY VERSION - ruby 3.1.2p20 + ruby 3.1.3p185 BUNDLED WITH 2.3.7 diff --git a/bin/entry.sh b/bin/entry.sh index 58577288..81b161d7 100755 --- a/bin/entry.sh +++ b/bin/entry.sh @@ -1,8 +1,8 @@ -#!/usr/bin/env sh +#!/usr/bin/env bash bundle exec rake db:setup -if [ "${DEVELOP}" -eq 1 ]; then +if [[ "${DEVELOP}" -eq 1 ]]; then bundle exec rails db:seed ./bin/fake_puppet_db & fi diff --git a/config/hdm.yml.template b/config/hdm.yml.template index 9681e7d6..b4e1e370 100644 --- a/config/hdm.yml.template +++ b/config/hdm.yml.template @@ -18,18 +18,11 @@ test: port: 389 production: - read_only: false - allow_encryption: true + read_only: true + allow_encryption: false puppet_db: - # When using https make sure the server name matches - # the one in the certificate - server: "https://localhost:8081" - pem: - key: "/path/to/keyfile" - cert: "/path/to/certfile" - ca_file: "/path/to/cafile" - config_dir: "/etc/puppetlabs/code" - #hiera_config_file: "hiera_hdm.yaml" + server: "http://localhost:8083" + config_dir: <%= Rails.root.join('test','fixtures','files','puppet') %> # Example for PE token authentication # production: @@ -53,11 +46,11 @@ production: # allow_encryption: true # puppet_db: # server: "http://localhost:8081" -# config_dir: "/etc/puppetlabs/code" +# config_dir: "/etc/puppetlabs/code" # git_data: # - datadir: /etc/puppetlabs/code/myenv/data # git_url: git@githost.example.com:puppet/hiera_data.git -# path_in_repo: environments/myenv/data +# path_in_repo: environments/myenv/data # Example for ldap authentication # production: From f921da1e015b4530eb189da7b8d8cc68b8bb7488 Mon Sep 17 00:00:00 2001 From: Robert Waffen Date: Tue, 13 Dec 2022 16:17:58 +0100 Subject: [PATCH 13/18] set ruby version to 3.1.3 --- .ruby-version | 2 +- .tool-versions | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.ruby-version b/.ruby-version index 7bde84d0..c877459a 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -ruby-3.1.2 +ruby-3.1.3 diff --git a/.tool-versions b/.tool-versions index 7e402d08..520a1687 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1 +1 @@ -ruby 2.5.3 +ruby 3.1.3 From 81826a6ef5c8160006349fb64ab9aef5e288c35b Mon Sep 17 00:00:00 2001 From: Robert Waffen Date: Wed, 14 Dec 2022 10:59:06 +0100 Subject: [PATCH 14/18] assets: combine rake tasks into one custom task --- Dockerfile | 2 +- lib/tasks/hdm.rake | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 297bb43d..5d9e4531 100644 --- a/Dockerfile +++ b/Dockerfile @@ -28,7 +28,7 @@ COPY . $APP_HOME COPY config/hdm.yml.template $APP_HOME/config/hdm.yml RUN bundle check || (bundle config set --local without 'development test' && bundle install) -RUN bundle exec rake assets:clean && bundle exec rake assets:clobber && bundle exec rake assets:precompile +RUN bundle exec rake hdm:assets EXPOSE 3000 diff --git a/lib/tasks/hdm.rake b/lib/tasks/hdm.rake index a6d49173..0d0b06ef 100644 --- a/lib/tasks/hdm.rake +++ b/lib/tasks/hdm.rake @@ -21,4 +21,11 @@ namespace :hdm do puts "The new password is:" puts new_password end + + desc "A task to clean and compile all assets" + task :assets do + Rake::Task['assets:clean'].invoke + Rake::Task['assets:clobber'].invoke + Rake::Task['assets:precompile'].invoke + end end From 1bc6c1f6773fe868b172ce8cd757cb225d840075 Mon Sep 17 00:00:00 2001 From: David Roetzel Date: Wed, 14 Dec 2022 11:12:53 +0100 Subject: [PATCH 15/18] Fix js pinning in production env. --- config/importmap.rb | 4 ++-- config/initializers/assets.rb | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/config/importmap.rb b/config/importmap.rb index 35a1d015..4f73ca6d 100644 --- a/config/importmap.rb +++ b/config/importmap.rb @@ -4,7 +4,7 @@ pin "@hotwired/turbo-rails", to: "turbo.min.js", preload: true pin "@hotwired/stimulus", to: "stimulus.min.js", preload: true pin "@hotwired/stimulus-loading", to: "stimulus-loading.js", preload: true -pin "jquery", to: "jquery" -pin "bootstrap", to: "bootstrap" +pin "jquery", to: "jquery.js" +pin "bootstrap", to: "bootstrap.js" pin_all_from "app/javascript/controllers", under: "controllers" pin "slim-select" # @1.27.1 diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index 2eeef966..e688533a 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -10,3 +10,4 @@ # application.js, application.css, and all non-JS/CSS in the app/assets # folder are already added. # Rails.application.config.assets.precompile += %w( admin.js admin.css ) +Rails.application.config.assets.precompile += %w( jquery.js bootstrap.js ) From ba8692abfd163704426041551568c18b4c5fedad Mon Sep 17 00:00:00 2001 From: Robert Waffen Date: Wed, 14 Dec 2022 11:24:02 +0100 Subject: [PATCH 16/18] generate assets on start of container --- Dockerfile | 1 - bin/entry.sh | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 5d9e4531..6acc9d06 100644 --- a/Dockerfile +++ b/Dockerfile @@ -28,7 +28,6 @@ COPY . $APP_HOME COPY config/hdm.yml.template $APP_HOME/config/hdm.yml RUN bundle check || (bundle config set --local without 'development test' && bundle install) -RUN bundle exec rake hdm:assets EXPOSE 3000 diff --git a/bin/entry.sh b/bin/entry.sh index 81b161d7..8cfbb2b8 100755 --- a/bin/entry.sh +++ b/bin/entry.sh @@ -1,6 +1,7 @@ #!/usr/bin/env bash bundle exec rake db:setup +bundle exec rake hdm:assets if [[ "${DEVELOP}" -eq 1 ]]; then bundle exec rails db:seed From e8e813209279a7a61cc55cbf2bdcd08d1477f8eb Mon Sep 17 00:00:00 2001 From: Robert Waffen Date: Wed, 14 Dec 2022 11:32:50 +0100 Subject: [PATCH 17/18] fix rubocop --- config/initializers/assets.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index e688533a..21019fb6 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -10,4 +10,4 @@ # application.js, application.css, and all non-JS/CSS in the app/assets # folder are already added. # Rails.application.config.assets.precompile += %w( admin.js admin.css ) -Rails.application.config.assets.precompile += %w( jquery.js bootstrap.js ) +Rails.application.config.assets.precompile += %w[jquery.js bootstrap.js] From b64fce51cc955465295239f053fe38e2a0afb518 Mon Sep 17 00:00:00 2001 From: Robert Waffen Date: Mon, 30 Jan 2023 16:07:02 +0100 Subject: [PATCH 18/18] add changelog generator --- Gemfile | 4 ++++ Gemfile.lock | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++ Rakefile | 24 +++++++++++++++++++++++ 3 files changed, 83 insertions(+) diff --git a/Gemfile b/Gemfile index db55d510..b9566ec7 100644 --- a/Gemfile +++ b/Gemfile @@ -62,6 +62,10 @@ group :linter do gem 'rubocop-rake' end +group :release do + gem 'github_changelog_generator', '>= 1.16.1', :require => false +end + # Windows does not include zoneinfo files, so bundle the tzinfo-data gem gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] diff --git a/Gemfile.lock b/Gemfile.lock index 8b78e4d3..a3fd12ab 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -70,6 +70,25 @@ GEM addressable (2.8.1) public_suffix (>= 2.0.2, < 6.0) ast (2.4.2) + async (2.3.1) + console (~> 1.10) + io-event (~> 1.1) + timers (~> 4.1) + async-http (0.59.5) + async (>= 1.25) + async-io (>= 1.28) + async-pool (>= 0.2) + protocol-http (~> 0.23) + protocol-http1 (~> 0.14.0) + protocol-http2 (~> 0.14.0) + traces (>= 0.8.0) + async-http-faraday (0.11.0) + async-http (~> 0.42) + faraday + async-io (1.34.3) + async + async-pool (0.3.12) + async (>= 1.25) autoprefixer-rails (10.4.7.0) execjs (~> 2) bcrypt (3.1.18) @@ -100,6 +119,8 @@ GEM childprocess (4.1.0) concurrent-ruby (1.1.10) connection_pool (2.3.0) + console (1.16.2) + fiber-local crass (1.0.6) dartsass-rails (0.4.0) railties (>= 6.0.0) @@ -117,8 +138,15 @@ GEM railties (>= 5.0.0) faker (3.0.0) i18n (>= 1.8.11, < 2) + faraday (2.7.4) + faraday-net_http (>= 2.0, < 3.1) + ruby2_keywords (>= 0.0.4) + faraday-http-cache (2.4.1) + faraday (>= 0.8) + faraday-net_http (3.0.2) fast_gettext (2.2.0) ffi (1.15.5) + fiber-local (1.0.0) friendly_id (5.5.0) activerecord (>= 4.0.0) git (1.13.0) @@ -126,6 +154,15 @@ GEM rchardet (~> 1.8) gitable (0.4.0) addressable (~> 2.2, >= 2.2.7) + github_changelog_generator (1.16.4) + activesupport + async (>= 1.25.0) + async-http-faraday + faraday-http-cache + multi_json + octokit (~> 4.6) + rainbow (>= 2.2.1) + rake (>= 10.0) globalid (1.0.1) activesupport (>= 5.0) hiera (3.10.0) @@ -142,6 +179,7 @@ GEM importmap-rails (1.1.5) actionpack (>= 6.0.0) railties (>= 6.0.0) + io-event (1.1.6) jquery-rails (4.5.1) rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) @@ -186,11 +224,21 @@ GEM racc (~> 1.4) nokogiri (1.13.10-x86_64-linux) racc (~> 1.4) + octokit (4.25.1) + faraday (>= 1, < 3) + sawyer (~> 0.9) optimist (3.0.1) parallel (1.22.1) parser (3.1.2.1) ast (~> 2.4.1) popper_js (1.16.1) + protocol-hpack (1.4.2) + protocol-http (0.24.0) + protocol-http1 (0.14.6) + protocol-http (~> 0.22) + protocol-http2 (0.14.2) + protocol-hpack (~> 1.4) + protocol-http (~> 0.18) public_suffix (5.0.0) puma (6.0.0) nio4r (~> 2.0) @@ -282,6 +330,7 @@ GEM rubocop-rake (0.6.0) rubocop (~> 1.0) ruby-progressbar (1.11.0) + ruby2_keywords (0.0.5) rubyzip (2.3.2) sassc (2.4.0) ffi (~> 1.9) @@ -291,6 +340,9 @@ GEM sprockets (> 3.0) sprockets-rails tilt + sawyer (0.9.2) + addressable (>= 2.3.5) + faraday (>= 0.17.3, < 3) scanf (1.0.0) selenium-webdriver (4.6.1) childprocess (>= 0.5, < 5.0) @@ -320,6 +372,8 @@ GEM thor (1.2.1) tilt (2.0.11) timeout (0.3.0) + timers (4.3.5) + traces (0.8.0) turbo-rails (1.3.2) actionpack (>= 6.0.0) activejob (>= 6.0.0) @@ -363,6 +417,7 @@ DEPENDENCIES friendly_id (~> 5.5.0) git gitable + github_changelog_generator (>= 1.16.1) hiera-eyaml importmap-rails jquery-rails diff --git a/Rakefile b/Rakefile index 10249c3c..6a87560a 100644 --- a/Rakefile +++ b/Rakefile @@ -16,3 +16,27 @@ if File.file?('config/hdm.yml') else puts "Not loading Rails specific tasks because config/hdm.yml is missing!" end + +begin + require 'github_changelog_generator/task' + GitHubChangelogGenerator::RakeTask.new :changelog do |config| + config.header = "# Changelog\n\nAll notable changes to this project will be documented in this file.\nEach new release typically also includes the latest modulesync defaults.\nThese should not affect the functionality of the module." + config.exclude_labels = %w{duplicate question invalid wontfix wont-fix modulesync skip-changelog} + config.user = 'betadots' + config.project = 'hdm' + end + + # Workaround for https://github.com/github-changelog-generator/github-changelog-generator/issues/715 + require 'rbconfig' + if RbConfig::CONFIG['host_os'] =~ /linux/ + task :changelog do + puts 'Fixing line endings...' + changelog_file = File.join(__dir__, 'CHANGELOG.md') + changelog_txt = File.read(changelog_file) + new_contents = changelog_txt.gsub(%r{\r\n}, "\n") + File.open(changelog_file, "w") {|file| file.puts new_contents } + end + end + +rescue LoadError +end