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

Enterprise to master. #1316

Open
wants to merge 49 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
11175e2
Update OS for enterprise ship:docker
DamianSzymanski Mar 18, 2021
c73e9ee
gem updates (#1192)
GbArc Apr 21, 2021
4a759ca
trivy scan added, docker fix (#1196)
GbArc Jul 6, 2021
5ee50d2
trivy fix
GbArc Jul 7, 2021
ba2c4dc
security updates [ship:docker] (#1200)
gbarc80 Aug 2, 2021
26be255
gh update
GbArc Aug 2, 2021
a89750c
update to use latest docker
GbArc Oct 21, 2021
82d5198
added region to s3 query
GbArc Nov 23, 2021
52adedb
gh update - gh token fix (#1223)
GbArc Feb 8, 2022
b968fac
share envs to forks (#1232)
GbArc Mar 16, 2022
40153e7
extended default timeouts for db, temp workaround for tcie
GbArc May 4, 2022
95b0da0
timeout spec fix
GbArc May 4, 2022
2bce53f
Upgrade gems (#1233)
makemp May 17, 2022
41af887
removed trivy
GbArc May 17, 2022
6e817cc
gem updates (#1237)
GbArc May 17, 2022
d8b682f
w/a: removed set_tags call for raven, todo - migrate to new api'
GbArc Jun 1, 2022
eaefc8a
rack update -> 2.2.3.1
GbArc Jun 8, 2022
c12eb15
job query optimization ship:docker (#1240)
GbArc Jun 14, 2022
8d8d693
console fix after pry update
GbArc Jun 29, 2022
978635f
gem updates + extended access rights for tokens (#1246)
GbArc Aug 26, 2022
e036f1b
restarted_by feature - merge from master (#1248)
GbArc Sep 7, 2022
0bd5566
putting api on a diet (ship:docker) (#1250)
GbArc Oct 5, 2022
ef4b8f8
bump google-protobuf to 3.19.6
GbArc Oct 14, 2022
a6be270
merge from master (#1260)
GbArc Dec 14, 2022
cd697da
sinatra up to 2.2.3 (#1264)
GbArc Dec 28, 2022
415f12c
bump travis-lock, travis-settings
GbArc Jan 11, 2023
fe48847
simplecov moved to test group
GbArc Jan 11, 2023
edfd3a7
sinatra bump to 2.2.4, hostname added for cache queries
GbArc Jan 30, 2023
22f7893
activesupport up to 6.1.7.2
GbArc Feb 2, 2023
fedd96c
managing email subscriptions for whole org
gbarc-dt May 26, 2023
9deeb71
Update gem database_cleaner
Jun 26, 2023
09ac6dd
Fix for SUPP-725 ship:docker (#1295)
piccadilly-circus Aug 28, 2023
ab08a8c
[BSFY-277] Add tag_name to build request (#1305)
AndriiMysko Feb 21, 2024
c567088
API merge. Enterprise to master.
Mar 19, 2024
b3b45c1
API merge. Enterprise to master.
Mar 20, 2024
83d6944
TravisCI API merge. Enterprise to master.
Mar 21, 2024
27fec3b
TravisCI API. Review fixes.
Apr 2, 2024
063ffb3
repo spec
gbarc-dt Apr 2, 2024
e830a80
specs, ship:docker
gbarc-dt Apr 2, 2024
ad89c7b
TravisCI API. Adding libcurl library.
Apr 3, 2024
74fb28d
Merge branch 'dt-e3-0-update' of https://github.com/travis-ci/travis-…
Apr 3, 2024
e4d67d7
libcurl4 ship:docker
gbarc-dt Apr 4, 2024
ec37998
allowance for tcie ship:docker
gbarc-dt Apr 9, 2024
68eef36
allowance ship:docker
gbarc-dt Apr 9, 2024
43ef552
Dockerfile revert ship:docker
gbarc-dt Apr 12, 2024
45efe5c
endpoint updates ship:docker
gbarc-dt Apr 16, 2024
f435814
Implement legacy roles option
AndriiMysko Apr 17, 2024
b192120
test
gbarc-dt Apr 17, 2024
5721958
Merge remote-tracking branch 'origin/dt-e3-0-legacy-roles' into dt-e3…
gbarc-dt Apr 18, 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
4 changes: 2 additions & 2 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:db-setup.yml
Expand All @@ -19,12 +20,11 @@ env:
- CI_NODE_INDEX=1
- CI_NODE_INDEX=2

cache: bundler

services:
- redis-server

before_install:
- 'gem install rubygems-update -v 3.4.22'
- 'gem update --system'

jobs:
Expand Down
8 changes: 6 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@ FROM ruby:3.2.2-slim

LABEL maintainer Travis CI GmbH <[email protected]>

# packages required for bundle install
RUN ( \
mkdir -p /app/vendor /app/cache; \
groupadd -r travis -g 1000 && \
useradd -u 1000 -r -g travis -s /bin/sh -c "travis user" -d "/app" travis;\
chown -R travis:travis /app; \
apt-get update ; \
apt-get install -y --no-install-recommends git make gcc g++ libpq-dev libjemalloc-dev libcurl4\
&& rm -rf /var/lib/apt/lists/* \
)

USER travis
ENV LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so.2

# throw errors if Gemfile has been modified since Gemfile.lock
Expand All @@ -28,4 +32,4 @@ RUN gem install --user-install executable-hooks

COPY . /app

CMD ./script/server-buildpacks
CMD ["./script/server-buildpacks"]
44 changes: 44 additions & 0 deletions Dockerfile.tcie
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
FROM ruby:3.2.2-slim

LABEL maintainer Travis CI GmbH <[email protected]>

RUN ( \
mkdir -p /app/vendor /app/cache; \
groupadd -r travis -g 1000 && \
useradd -u 1000 -r -g travis -s /bin/sh -c "travis user" -d "/app" travis;\
chown -R travis:travis /app; \
apt-get update ; \
apt-get upgrade -y ; \
apt-get install -y --no-install-recommends git make gcc g++ libpq-dev libjemalloc-dev xz-utils \
&& rm -rf /var/lib/apt/lists/*; \
gem update --system; \
bundle config set app_config /app; \
bundle config set cache_path /app; \
bundle config --global frozen 1; \
bundle config set deployment 'true'; \
chown -R travis:travis /usr/local/bundle; \
)



WORKDIR /app

USER travis
COPY Gemfile* /app/
RUN ( \
bundle config set without 'development test'; \
bundler install --verbose --retry=3; \
bundle config set frozen true; \
)
USER root
RUN ( apt-get remove -y gcc g++ make git perl xz-utils && apt-get -y autoremove; \
bundle clean && rm -rf /app/vendor/bundle/ruby/2.7.0/cache/*; \
for i in `find /app/vendor/ -name \*.o -o -name \*.c -o -name \*.h`; do rm -f $i; done; \
)

USER travis
ENV LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so.2

COPY . /app

CMD ["./script/server-buildpacks"]
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ DOCKER ?= docker

.PHONY: docker-build
docker-build:
$(DOCKER) build -t $(DOCKER_DEST) .
$(DOCKER) build --no-cache --pull -t $(DOCKER_DEST) . -f Dockerfile.tcie

.PHONY: docker-login
docker-login:
Expand Down
2 changes: 1 addition & 1 deletion lib/travis.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'pusher'
require 'travis/support'
require 'travis/support/database'
#require 'travis/support/database'
require 'travis/errors'

module Travis
Expand Down
5 changes: 1 addition & 4 deletions lib/travis/api/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,6 @@ def self.setup(options = {})
FileUtils.touch('/tmp/app-initialized') if ENV['DYNO'] # Heroku
end

def self.new(options = {})
setup(options)
super()
end

def self.deploy_sha
@deploy_sha ||= ENV['HEROKU_SLUG_COMMIT'] || SecureRandom.hex(5)
Expand Down Expand Up @@ -186,6 +182,7 @@ def initialize(options = {})

# Rack protocol
def call(env)
#app.after { ActiveRecord::Base.clear_active_connections! }
app.call(env)
rescue
if Endpoint.production?
Expand Down
3 changes: 3 additions & 0 deletions lib/travis/api/enqueue/services/restart_model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ def billing?
# there is no billing for .org
return true if Travis.config.org?

# there is no billing for .enterprise
return true if !!Travis.config.enterprise

@_billing_ok ||= begin
jobs = target.is_a?(Job) ? [target] : target.matrix

Expand Down
6 changes: 0 additions & 6 deletions lib/travis/api/v3/billing_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,6 @@ def get_invoices_for_subscription(id)
end
end

def get_invoices_for_v2_subscription(id)
Copy link
Contributor

Choose a reason for hiding this comment

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

don't remove

Copy link
Author

Choose a reason for hiding this comment

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

Done.

body(connection.get("/v2/subscriptions/#{id}/invoices")).map do |invoice_data|
Travis::API::V3::Models::Invoice.new(invoice_data)
end
end

def trials
body(connection.get('/trials')).map do | trial_data |
Travis::API::V3::Models::Trial.new(trial_data)
Expand Down
2 changes: 2 additions & 0 deletions lib/travis/api/v3/extensions/preferences.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require 'active_support/all'

module Travis::API::V3
module Extensions
module Preferences
Expand Down
2 changes: 2 additions & 0 deletions lib/travis/api/v3/models/fingerprint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ def calculate(source)
rsa_key = OpenSSL::PKey::RSA.new(source)
public_ssh_rsa = "\x00\x00\x00\x07ssh-rsa" + rsa_key.e.to_s(0) + rsa_key.n.to_s(0)
OpenSSL::Digest::MD5.new(public_ssh_rsa).hexdigest.scan(/../).join(':')
rescue OpenSSL::PKey::RSAError
nil
end

module_function :calculate
Expand Down
2 changes: 2 additions & 0 deletions lib/travis/api/v3/models/key_pair.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ def fingerprint_source
def public_key
return unless value.decrypt
OpenSSL::PKey::RSA.new(value.decrypt).public_key.to_s
rescue OpenSSL::PKey::RSAError
nil
end

def to_h
Expand Down
13 changes: 0 additions & 13 deletions lib/travis/api/v3/models/leads.rb

This file was deleted.

2 changes: 2 additions & 0 deletions lib/travis/api/v3/models/user_settings.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require 'json'

module Travis::API::V3
class Models::UserSettings < Models::JsonSlice
child Models::UserSetting
Expand Down
5 changes: 4 additions & 1 deletion lib/travis/api/v3/queries/env_vars.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ def create(repository, from_admin = false)
env_vars.user = repository.user_settings.user
env_vars.change_source = 'travis-api' unless from_admin
env_var = env_vars.create(env_var_params)

unless env_var.valid?
repository.env_vars.destroy(env_var.id)
handle_errors(env_var)
Expand All @@ -34,5 +33,9 @@ def handle_errors(env_var)

raise ServerError
end

def errors_(env_var, what)
env_var.errors.errors.any? { |e| e.type.to_s == what}
end
end
end
9 changes: 8 additions & 1 deletion lib/travis/api/v3/queries/jobs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,14 @@ def for_owner(relation)

def for_user(user)
set_custom_timeout(host_timeout)
jobs = V3::Models::Job.where("jobs.id in (select id from most_recent_job_ids_for_user_repositories_by_states(#{user.id}, ?))", states)
if ENV['TCIE_BETA_MOST_RECENT_JOBS_LW'] == 'true'
puts "USING LW JOBS!!\n\n"
jobs = V3::Models::Job.where("jobs.id in (select id from most_recent_job_ids_for_user_repositories_by_states_lw(#{user.id}, ?))", states)
else
puts "USING REGULAR JOBS!!!\n\n"
Copy link
Contributor

Choose a reason for hiding this comment

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

pls remove these three puts - this was tcie debug

Copy link
Author

Choose a reason for hiding this comment

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

Done.

jobs = V3::Models::Job.where("jobs.id in (select id from most_recent_job_ids_for_user_repositories_by_states(#{user.id}, ?))", states)
end
puts jobs.inspect

sort filter(jobs)
end
Expand Down
3 changes: 2 additions & 1 deletion lib/travis/api/v3/queries/request.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Travis::API::V3
class Queries::Request < Query
params :id, :message, :branch, :sha, :merge_mode, :config, :configs, :token, prefix: :request
params :id, :message, :branch, :sha, :tag_name, :merge_mode, :config, :configs, :token, prefix: :request

def find
raise WrongParams, 'missing request.id'.freeze unless id
Expand Down Expand Up @@ -36,6 +36,7 @@ def schedule(repository, user)
id: request.id,
message: message,
branch: branch || repository.default_branch.name,
tag_name: tag_name,
sha: sha,
configs: request_configs,
# BC, remove once everyone is on yml/configs, coordinate with Gatekeeper
Expand Down
5 changes: 0 additions & 5 deletions lib/travis/api/v3/renderer/leads.rb

This file was deleted.

2 changes: 2 additions & 0 deletions lib/travis/api/v3/renderer/user_settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ def render
end

def allow?(setting)
return unless setting

case setting[:name]
when :allow_config_imports then repo.private?
else true
Expand Down
4 changes: 0 additions & 4 deletions lib/travis/api/v3/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -470,9 +470,5 @@ module Routes
get :stats, '/stats'
end

hidden_resource :leads do
route '/leads'
post :create
end
end
end
1 change: 0 additions & 1 deletion lib/travis/api/v3/services.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ module Services
Job = Module.new { extend Services }
Jobs = Module.new { extend Services }
KeyPair = Module.new { extend Services }
Leads = Module.new { extend Services }
Lint = Module.new { extend Services }
Log = Module.new { extend Services }
ScanResult = Module.new { extend Services }
Expand Down
66 changes: 0 additions & 66 deletions lib/travis/api/v3/services/leads/create.rb

This file was deleted.

6 changes: 3 additions & 3 deletions lib/travis/api/v3/services/user_setting/update.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ class Services::UserSetting::Update < Service
def run!
repository = check_login_and_find(:repository)
return repo_migrated if migrated?(repository)

user_setting = query.find(repository)
access_control.permissions(user_setting).write!
access_control.permissions(user_setting).write! if user_setting
app_id = Travis::Api::App::AccessToken.find_by_token(access_control.token).app_id

user_setting = query.update(repository, access_control.user, app_id == 2)
result user_setting
end
Expand Down
1 change: 0 additions & 1 deletion lib/travis/api/v3/services/v2_subscriptions/create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ class Services::V2Subscriptions::Create < Service

def run!
raise LoginRequired unless access_control.full_access_or_logged_in?

result query(:v2_subscriptions).create(access_control.user.id), status: 201
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/travis/config/defaults.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ def fallback_logs_api_auth_token
amqp: { username: 'guest', password: 'guest', host: 'localhost', prefetch: 1 },
closeio: { key: 'key' },
gdpr: {},
database: { adapter: 'postgresql', database: "travis_#{Travis.env}", encoding: 'unicode', min_messages: 'warning', variables: { statement_timeout: 10_000 } },
db: { max_statement_timeout_in_seconds: 15, slow_host_max_statement_timeout_in_seconds: 60},
database: { adapter: 'postgresql', database: "travis_#{Travis.env}", encoding: 'unicode', min_messages: 'warning', variables: { statement_timeout: ENV['TRAVIS_DB_STATEMENT_TIMEOUT'] || 10000 } },
db: { max_statement_timeout_in_seconds: 15, slow_host_max_statement_timeout_in_seconds: ENV['TRAVIS_MAX_DB_STATEMENT_TIMEOUT'] || 15},
Copy link
Contributor

Choose a reason for hiding this comment

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

change default to 60 like it was before

Copy link
Author

Choose a reason for hiding this comment

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

Done.

log_options: { s3: { access_key_id: '', secret_access_key: ''}},
s3: { access_key_id: '', secret_access_key: ''},
pusher: { app_id: 'app-id', key: 'key', secret: 'secret' },
Expand Down
1 change: 1 addition & 0 deletions lib/travis/event/handler/metrics.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require 'metriks'
require 'travis/support'

module Travis
module Event
Expand Down
4 changes: 4 additions & 0 deletions lib/travis/model/build.rb
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@ def per_page
end
end

def state
(super || :created).to_sym
end

def matrix_ids
matrix.map(&:id)
end
Expand Down
Loading