Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hub update by merging enterprise. #268

Open
wants to merge 31 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
d751c76
Update OS for enterprise ship:docker
DamianSzymanski Mar 18, 2021
f32e097
Update travis yml ship:docker
DamianSzymanski Mar 24, 2021
dba772b
email handler - ignore case
GbArc Apr 12, 2021
4a45188
Merge pull request #249 from travis-ci/ga-email_case
GbArc Apr 15, 2021
459ff15
Ext gem update (#250)
GbArc Apr 21, 2021
52f92b6
rack,sinatra,activerecord update (#252)
GbArc Jun 2, 2021
e0713ce
docker fix+trivy
GbArc Jul 6, 2021
dd4c864
trivy fix
GbArc Jul 7, 2021
66306ac
gh update
GbArc Aug 2, 2021
bf05deb
update to use latest docker
GbArc Oct 21, 2021
64090a8
Upgrade gems (#255)
makemp May 17, 2022
dd28822
gem updates (#258)
GbArc May 19, 2022
ef8cd2d
removed trivy'
GbArc May 19, 2022
b766d14
rack update -> 2.2.3.1
GbArc Jun 8, 2022
51352c2
global webhook urls from installation config (#259)
GbArc Jun 29, 2022
5cc249d
activerecord bump
GbArc Jul 21, 2022
0046d20
image size reduction [ship:docker] (#260)
GbArc Oct 5, 2022
aacc142
merge from master (#261)
GbArc Dec 14, 2022
69c0f1d
sinatra update to 2.2.3 (#262)
GbArc Dec 28, 2022
58df241
jemalloc/gh rev fix ship:docker
gbarc-dt Oct 18, 2023
ba0d095
Hub merge. Enterprise to master.
Mar 15, 2024
30aab1c
Update Gemfile
SebastianKarpetaDev Mar 18, 2024
348d708
Hub merge. Enterprise to master.
Mar 18, 2024
f39447a
Hub merge. Enterprise to master.
Mar 18, 2024
24fd60e
Hub merge. Enterprise to master.
Mar 18, 2024
61e3ee9
Hub merge. Enterprise to master.
Mar 18, 2024
dd22381
Delete Gemfile.lock.origin
SebastianKarpetaDev Mar 18, 2024
44e837e
Hub merge. Enterprise to master.
Mar 18, 2024
4fc31b5
dist up to focal, ship:docker
gbarc-dt Apr 2, 2024
c88df50
removed duplicate method
GbArc Apr 16, 2024
9398f87
spec- removed duplicated
gbarc-dt Apr 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
language: ruby
group: edge

import:
- travis-ci/build-configs:[email protected]
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 @@ -34,10 +37,6 @@ jobs:
dist: bionic
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
10 changes: 6 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ source 'https://rubygems.org'

ruby '3.2.2'

gem 'sidekiq-pro', source: 'https://gems.contribsys.com'
gem 'sidekiq-pro', '~> 5.1.1', source: 'https://gems.contribsys.com'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

keep versions from master, there's sidekiq-pro / sidekiq 7.2.0,

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

gem 'sidekiq', '~> 6.4'

gem 'travis-exceptions', git: 'https://github.com/travis-ci/travis-exceptions'
gem 'travis-logger', git: 'https://github.com/travis-ci/travis-logger'
Expand All @@ -16,7 +17,7 @@ gem 'travis-support', git: 'https://github.com/travis-ci/travis-support'
gem 'metriks', git: 'https://github.com/travis-ci/metriks'
gem 'metriks-librato_metrics', git: 'https://github.com/travis-ci/metriks-librato_metrics'

gem 'marginalia', git: 'https://github.com/travis-ci/marginalia'
gem 'marginalia', git: 'https://github.com/travis-ci/marginalia', branch: '5.x'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

keep marginalia from master

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.


gem 'activerecord', '~> 7'
gem 'bunny'
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.0'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2.8.6 is on master

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.


gem 'coder'
gem 'gh', git: 'https://github.com/travis-ci/gh'
gem 'gh', git: 'https://github.com/travis-ci/gh', branch: 'tcie3-0_15_2'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here keep master, it's newer

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

gem 'keen'
gem 'multi_json'
gem 'redlock'
Expand All @@ -47,7 +49,7 @@ group :test do
gem 'mocha', '~> 2'
gem 'pry'
gem 'rack-test'
gem 'rspec', '~> 3.12'
gem 'rspec', '~> 3.12', '~> 2.3.2'
gem 'sinatra-contrib'
gem 'webmock'
end
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.tcie

.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
3 changes: 2 additions & 1 deletion lib/travis/hub/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ 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' },
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
8 changes: 8 additions & 0 deletions lib/travis/sidekiq.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ def billing(*args)
)
end

def billing(*args)
default_client.push(
'queue' => 'billing',
'class' => 'Travis::Billing::Worker',
'args' => [nil, "Travis::Billing::Services::UsageTracker", 'perform', *args]
)
end

private

def default_client
Expand Down
5 changes: 5 additions & 0 deletions spec/support/factories.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ def config=(config)
config { { arch: 'amd64', os: 'linux', virt: 'vm' } }
end

factory :job_config do
key 'key'
config { { arch: 'amd64', os: 'linux', virt: 'vm' } }
end

factory :user do
end

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