diff --git a/.travis.yml b/.travis.yml index 30ab27b9..836739f9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,5 @@ language: ruby +group: edge import: - travis-ci/build-configs:db-setup.yml@postgres-9.6 @@ -23,6 +24,8 @@ services: - rabbitmq before_install: + - gem uninstall -v '>=2' -i $(rvm gemdir)@global -ax bundler || true + - gem install bundler -v '2.3.7' - bundle config https://gems.contribsys.com/ $BUNDLE_GEMS__CONTRIBSYS__COM - gem install bundler -v 2.4.14 @@ -31,13 +34,9 @@ jobs: - stage: "testing time" script: bundle exec rspec - stage: ":ship: it to quay.io" - dist: bionic + dist: focal ruby: services: - addons: - snaps: - - name: docker - channel: latest/beta before_install: echo "skipping" install: echo "skipping" before_sript: skip diff --git a/Dockerfile.tcie b/Dockerfile.tcie new file mode 100644 index 00000000..7fb2f066 --- /dev/null +++ b/Dockerfile.tcie @@ -0,0 +1,38 @@ +FROM ruby:3.2.2-slim + +LABEL maintainer Travis CI GmbH + +RUN ( \ + bundle config set no-cache 'true'; \ + bundle config --global frozen 1; \ + bundle config set deployment 'true'; \ + mkdir -p /app; \ +) + +WORKDIR /app + +COPY Gemfile /app +COPY Gemfile.lock /app +ARG bundle_gems__contribsys__com + +RUN ( \ + apt-get update ; \ + apt-get upgrade -y ; \ + apt-get install -y git make gcc g++ libpq-dev curl \ + && rm -rf /var/lib/apt/lists/*; \ + curl -sLO http://ppa.launchpad.net/rmescandon/yq/ubuntu/pool/main/y/yq/yq_3.1-2_amd64.deb && \ + dpkg -i yq_3.1-2_amd64.deb && \ + rm -f yq_3.1-2_amd64.deb; \ + gem install bundler -v '2.3.14'; \ + bundle config https://gems.contribsys.com/ $bundle_gems__contribsys__com \ + && bundle config set without 'development test' \ + && bundle install --deployment \ + && bundle config --delete https://gems.contribsys.com/; \ + apt-get remove -y gcc g++ make git perl && apt-get -y autoremove; \ + bundle clean && rm -rf /app/vendor/bundle/ruby/2.5.0/cache/*; \ + rm -rf /usr/local/bundle/cache/\*.gem; \ + find /usr/local/bundle/gems/ \( -name '*.c' -o -name '*.h' -o -name '*.cpp' -o -name '*.o' \) -delete; \ + find /app/vendor/ \( -name '*.c' -o -name '*.h' -o -name '*.cpp' -o -name '*.o' \) -delete; \ +) + +COPY . /app diff --git a/Gemfile b/Gemfile index b462352b..92904b9d 100644 --- a/Gemfile +++ b/Gemfile @@ -3,6 +3,7 @@ source 'https://rubygems.org' ruby '3.2.2' gem 'sidekiq-pro', source: 'https://gems.contribsys.com' +gem 'sidekiq', '~> 7.2.0' gem 'travis-exceptions', git: 'https://github.com/travis-ci/travis-exceptions' gem 'travis-logger', git: 'https://github.com/travis-ci/travis-logger' @@ -26,9 +27,10 @@ gem 'pg', '~> 1' gem 'rake' gem 'redis' gem 'rollout', git: 'https://github.com/travis-ci/rollout' +gem 'addressable', '~> 2.8.6' gem 'coder' -gem 'gh', git: 'https://github.com/travis-ci/gh' +gem 'gh', git: 'https://github.com/travis-ci/gh', branch: 'master' gem 'keen' gem 'multi_json' gem 'redlock' diff --git a/Gemfile.lock b/Gemfile.lock index f2799ee4..2686896d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,6 +1,7 @@ GIT remote: https://github.com/travis-ci/gh revision: e1fcd75786ffa75667e47d3d824b54d1bd0017fe + branch: master specs: gh (0.21.0) activesupport (~> 7.0.8) @@ -14,10 +15,10 @@ GIT GIT remote: https://github.com/travis-ci/marginalia - revision: d7c711abd60517b435e50b499fc8997ab67ababe + revision: 07f19a9ee5869a4557437a9f24608c7b1c4275bf specs: marginalia (1.6.0) - pg + pg (~> 1.3) GIT remote: https://github.com/travis-ci/metriks @@ -37,10 +38,10 @@ GIT GIT remote: https://github.com/travis-ci/rollout - revision: 4a7a0b96dc038f7ca057ca771693d8f5a7c90583 + revision: ec4db3ae6bbf8cf56ce4adce0814247c46195a0e specs: - rollout (2.5.0) - redis (~> 4.0) + rollout (3.0.0) + redis (~> 5.0) GIT remote: https://github.com/travis-ci/simple_states @@ -129,7 +130,7 @@ GEM avl_tree (1.2.1) atomic (~> 1.1) base64 (0.2.0) - bigdecimal (3.1.6) + bigdecimal (3.1.7) bunny (2.22.0) amq-protocol (~> 2.3, >= 2.3.1) sorted_set (~> 1, >= 1.0.2) @@ -152,7 +153,7 @@ GEM domain_name (0.6.20240107) ethon (0.16.0) ffi (>= 1.15.0) - excon (0.109.0) + excon (0.110.0) factory_bot (6.4.6) activesupport (>= 5.0.0) faraday (2.9.0) @@ -165,8 +166,8 @@ GEM faraday (~> 2.0) typhoeus (~> 1.4) ffi (1.16.3) - ffi-compiler (1.0.1) - ffi (>= 1.0.0) + ffi-compiler (1.3.2) + ffi (>= 1.15.5) rake hashdiff (1.1.0) hashr (2.0.1) @@ -180,16 +181,16 @@ GEM http-cookie (1.0.5) domain_name (~> 0.5) http-form_data (2.3.0) - i18n (1.14.1) + i18n (1.14.4) concurrent-ruby (~> 1.0) json (2.7.1) - jwt (2.8.0) + jwt (2.8.1) base64 keen (1.1.1) addressable (~> 2.5) multi_json (~> 1.12) language_server-protocol (3.17.0.3) - libhoney (2.2.0) + libhoney (2.3.0) addressable (~> 2.0) excon http (>= 2.0, < 6.0) @@ -197,7 +198,7 @@ GEM ffi-compiler (~> 1.0) rake (~> 13.0) method_source (1.0.0) - minitest (5.22.2) + minitest (5.22.3) mocha (2.1.0) ruby2_keywords (>= 0.0.5) multi_json (1.15.0) @@ -213,7 +214,7 @@ GEM parser (3.3.0.5) ast (~> 2.4.1) racc - pg (1.5.5) + pg (1.5.6) pry (0.14.2) coderay (~> 1.1) method_source (~> 1.0) @@ -232,8 +233,9 @@ GEM rainbow (3.1.1) rake (13.1.0) rbtree (0.4.6) - redis (4.8.1) - redis-client (0.20.0) + redis (5.1.0) + redis-client (>= 0.17.0) + redis-client (0.21.0) connection_pool redlock (2.0.6) redis-client (>= 0.14.1, < 1.0.0) @@ -252,7 +254,7 @@ GEM diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.13.0) rspec-support (3.13.1) - rubocop (1.60.2) + rubocop (1.62.1) json (~> 2.3) language_server-protocol (>= 3.17.0) parallel (~> 1.10) @@ -260,11 +262,11 @@ GEM rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) rexml (>= 3.2.5, < 4.0) - rubocop-ast (>= 1.30.0, < 2.0) + rubocop-ast (>= 1.31.1, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 2.4.0, < 3.0) - rubocop-ast (1.30.0) - parser (>= 3.2.1.0) + rubocop-ast (1.31.2) + parser (>= 3.3.0.4) rubocop-capybara (2.20.0) rubocop (~> 1.41) rubocop-factory_bot (2.25.1) @@ -272,13 +274,14 @@ GEM rubocop-performance (1.20.2) rubocop (>= 1.48.1, < 2.0) rubocop-ast (>= 1.30.0, < 2.0) - rubocop-rspec (2.26.1) + rubocop-rspec (2.27.1) rubocop (~> 1.40) rubocop-capybara (~> 2.17) rubocop-factory_bot (~> 2.22) ruby-progressbar (1.13.0) ruby2_keywords (0.0.5) - sentry-ruby (5.16.1) + sentry-ruby (5.17.1) + bigdecimal concurrent-ruby (~> 1.0, >= 1.0.2) set (1.1.0) sidekiq (7.2.2) @@ -325,10 +328,12 @@ GEM hashdiff (>= 0.4.0, < 2.0.0) PLATFORMS + arm64-darwin-23 x86_64-linux DEPENDENCIES activerecord (~> 7) + addressable (~> 2.8.6) bunny coder dalli @@ -358,6 +363,7 @@ DEPENDENCIES rubocop-performance rubocop-rspec sentry-ruby + sidekiq (~> 7.2.0) sidekiq-pro! simple_states! simplecov diff --git a/Makefile b/Makefile index 10a46d66..1bf2c569 100644 --- a/Makefile +++ b/Makefile @@ -31,7 +31,7 @@ DOCKER ?= docker .PHONY: docker-build docker-build: - $(DOCKER) build --build-arg bundle_gems__contribsys__com=$(BUNDLE_GEMS__CONTRIBSYS__COM) -t $(DOCKER_DEST) . + $(DOCKER) build --pull --no-cache --build-arg bundle_gems__contribsys__com=$(BUNDLE_GEMS__CONTRIBSYS__COM) -t $(DOCKER_DEST) . -f Dockerfile .PHONY: docker-login docker-login: diff --git a/bin/sidekiq b/bin/sidekiq index 4b790e40..3481f98e 100755 --- a/bin/sidekiq +++ b/bin/sidekiq @@ -1,6 +1,5 @@ #!/bin/bash -index=$(echo ${DYNO:-1} | sed 's/.*\.//') threads=$1 shift queues=$@ diff --git a/lib/travis/addons/handlers/billing.rb b/lib/travis/addons/handlers/billing.rb index ebe91345..0139504c 100644 --- a/lib/travis/addons/handlers/billing.rb +++ b/lib/travis/addons/handlers/billing.rb @@ -17,7 +17,7 @@ def handle? end def handle - publish + publish unless Travis::Hub.context.config.enterprise? end private diff --git a/lib/travis/addons/handlers/email.rb b/lib/travis/addons/handlers/email.rb index 6b2078df..6b93842c 100644 --- a/lib/travis/addons/handlers/email.rb +++ b/lib/travis/addons/handlers/email.rb @@ -44,9 +44,11 @@ def configured_emails end def default_emails - emails = [commit.author_email, commit.committer_email] + emails = [commit.author_email&.downcase, commit.committer_email&.downcase] user_ids = object.repository.permissions.pluck(:user_id) - ::Email.where(email: emails, user_id: user_ids).pluck(:email).uniq + ::Email.where(user_id: user_ids).pluck(:email).uniq.each do |email| + email if emails.include? email.downcase + end end def unsubscribed_emails diff --git a/lib/travis/addons/handlers/webhook.rb b/lib/travis/addons/handlers/webhook.rb index 190a6832..245f915f 100644 --- a/lib/travis/addons/handlers/webhook.rb +++ b/lib/travis/addons/handlers/webhook.rb @@ -18,7 +18,11 @@ def handle end def targets - @targets ||= config.values(:urls) + @targets ||= (config.values(:urls) || []) .push(*global_urls) + end + + def global_urls + @global_urls ||= ENV['TRAVIS_HUB_WEBHOOK_GLOBAL_URLS']&.split(';') || [] end class Instrument < Addons::Instrument diff --git a/lib/travis/hub/api/jwt.rb b/lib/travis/hub/api/jwt.rb index e42a987b..144bab5a 100644 --- a/lib/travis/hub/api/jwt.rb +++ b/lib/travis/hub/api/jwt.rb @@ -14,7 +14,6 @@ def run def valid? return false unless refresh_token.valid? return false unless redis.exists?(refresh_key) - redis.del(refresh_key) true end diff --git a/lib/travis/hub/config.rb b/lib/travis/hub/config.rb index e44d4226..02dc591b 100644 --- a/lib/travis/hub/config.rb +++ b/lib/travis/hub/config.rb @@ -42,7 +42,7 @@ def jwt_key(type) limit: { resets: { max: 50, after: 6 * 60 * 60 } }, notifications: ['billing'], auth: { jwt_private_key: jwt_key(:private), jwt_public_key: jwt_key(:public), http_basic_auth: }, - billing: { url: ENV['BILLING_URL'] || 'http://localhost:9292', auth_key: ENV['BILLING_AUTH_KEY'] || 't0Ps3Cr3t' } + billing: { url: ENV['BILLING_URL'] || 'http://localhost:9292', auth_key: ENV['BILLING_AUTH_KEY'] || 't0Ps3Cr3t' } def metrics # TODO: cleanup keychain? diff --git a/lib/travis/hub/support/sidekiq.rb b/lib/travis/hub/support/sidekiq.rb index 8bde56d9..cc7c672f 100644 --- a/lib/travis/hub/support/sidekiq.rb +++ b/lib/travis/hub/support/sidekiq.rb @@ -9,6 +9,7 @@ module Travis module Sidekiq def setup(config) ::Sidekiq.configure_server do |c| + c.logger.level = Logger::WARN c.redis = { url: config.redis.url, id: nil diff --git a/spec/travis/addons/handlers/email_spec.rb b/spec/travis/addons/handlers/email_spec.rb index 85b74e75..cea22764 100644 --- a/spec/travis/addons/handlers/email_spec.rb +++ b/spec/travis/addons/handlers/email_spec.rb @@ -198,9 +198,8 @@ before do Email.create(user:, email: address) - user.update!(preferences: JSON.dump(build_emails: false)) + user.update!(preferences: {:build_emails => false}) end - it { expect(handler.recipients).to be_empty } end end