Skip to content

Commit

Permalink
[TBT-84] Enterprise merge (#270)
Browse files Browse the repository at this point in the history
* Update OS for enterprise ship:docker

* Update travis yml ship:docker

* email handler - ignore case

* Ext gem update (#250)

* security updates

* revert activerecord from 5 to 4

* bundler version

* rack,sinatra,activerecord update (#252)

* docker fix+trivy

* trivy fix

* gh update

* update to use latest docker

* Upgrade gems (#255)

* proper logging for sidekiq

* minimum for Ruby 2.5.9 + safe sidekiq

* bump webmock

* Trying with ruby-2.7.5

* force bundler to 2.3.7

* bundler in dockerfile

* jemallock fix

* Jemmaloc 1.1.3

* new sidekiq does not have  -i/--index option

* sidekiq pro 5.1.1

* join if respond_to

* Ruby 2.5.9

* changes in API for Redis

Co-authored-by: Maciej Kempin <[email protected]>

* gem updates (#258)

* removed trivy'

* rack update -> 2.2.3.1

* global webhook urls from installation config (#259)

* activerecord bump

* image size reduction [ship:docker] (#260)

* merge from master (#261)

* merge from master

* ship:docker

* sinatra update to 2.2.3 (#262)

* jemalloc/gh rev fix ship:docker

* Update Gemfile

* Hub merge. Enterprise to master.

* Hub merge. Enterprise to master.

* Hub merge. Enterprise to master.

* Hub merge. Enterprise to master.

* Delete Gemfile.lock.origin

* Hub merge. Enterprise to master.

* dist up to focal, ship:docker

* removed duplicate method

* spec- removed duplicated

* Update build db

---------

Co-authored-by: Damian Szymanski <[email protected]>
Co-authored-by: gabriel-arc <[email protected]>
Co-authored-by: gabriel-arc <[email protected]>
Co-authored-by: Maciej Kempin <[email protected]>
Co-authored-by: Maciej Kempin <[email protected]>
Co-authored-by: GbArc <[email protected]>
Co-authored-by: Sebastian Karpeta <[email protected]>
Co-authored-by: SebastianKarpetaDev <[email protected]>
  • Loading branch information
9 people authored Jul 23, 2024
1 parent 71842b2 commit d4415ad
Show file tree
Hide file tree
Showing 13 changed files with 88 additions and 39 deletions.
11 changes: 5 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
language: ruby
group: edge

import:
- travis-ci/build-configs:db-setup.yml@postgres-9.6
- travis-ci/build-configs:db-setup.yml

rvm: 3.2.2

Expand All @@ -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

Expand All @@ -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
Expand Down
38 changes: 38 additions & 0 deletions Dockerfile.tcie
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
FROM ruby:3.2.2-slim

LABEL maintainer Travis CI GmbH <[email protected]>

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
4 changes: 3 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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'
Expand Down
50 changes: 28 additions & 22 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -180,24 +181,24 @@ 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)
llhttp-ffi (0.5.0)
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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -252,33 +254,34 @@ 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)
parser (>= 3.3.0.2)
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)
rubocop (~> 1.41)
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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -358,6 +363,7 @@ DEPENDENCIES
rubocop-performance
rubocop-rspec
sentry-ruby
sidekiq (~> 7.2.0)
sidekiq-pro!
simple_states!
simplecov
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 0 additions & 1 deletion bin/sidekiq
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/bin/bash

index=$(echo ${DYNO:-1} | sed 's/.*\.//')
threads=$1
shift
queues=$@
Expand Down
2 changes: 1 addition & 1 deletion lib/travis/addons/handlers/billing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def handle?
end

def handle
publish
publish unless Travis::Hub.context.config.enterprise?
end

private
Expand Down
6 changes: 4 additions & 2 deletions lib/travis/addons/handlers/email.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion lib/travis/addons/handlers/webhook.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion lib/travis/hub/api/jwt.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/travis/hub/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
1 change: 1 addition & 0 deletions lib/travis/hub/support/sidekiq.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions spec/travis/addons/handlers/email_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d4415ad

Please sign in to comment.