Skip to content

Commit 1a6590f

Browse files
committed
Merge remote-tracking branch 'origin/master' into ha-updates
2 parents 6c874e3 + 2bf29e2 commit 1a6590f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+732
-134
lines changed

.travis.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
language: ruby
22

33
import:
4-
- travis-ci/build-configs:db-setup.yml
4+
- travis-ci/build-configs:db-setup.yml@bionic
55

66
rvm: 2.6.5
77

88
script: "bundle exec rake knapsack:rspec"
99

10+
addons:
11+
- snaps:
12+
- name: docker
13+
channel: latest/beta
14+
1015
env:
1116
global:
17+
- PATH=/snap/bin:$PATH
1218
- RUBY_GC_MALLOC_LIMIT=90000000
1319
- RUBY_GC_HEAP_FREE_SLOTS=200000
1420
- CI_NODE_TOTAL=3
@@ -32,4 +38,4 @@ jobs:
3238
install: echo skip
3339
before_script: echo skip
3440
script: make ship
35-
if: type = cron OR commit_message =~ /ship:docker/ OR env(SHIP_DOCKER) = true
41+
if: commit_message =~ /ship:docker/ OR env(SHIP_DOCKER) = true or branch = master

Gemfile.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ GIT
6161

6262
GIT
6363
remote: https://github.com/travis-ci/travis-github_apps
64-
revision: fb865ee510534006f15553f4ef3746c2610a4668
64+
revision: c96dc9330849ff3e2ccd7c9d00005a1a96c1a4b6
6565
specs:
66-
travis-github_apps (0.2.0)
66+
travis-github_apps (0.2.1)
6767
activesupport (>= 3.2)
6868
faraday
6969
faraday_middleware
@@ -399,7 +399,7 @@ GEM
399399
timecop (0.9.1)
400400
tool (0.2.3)
401401
travis-rollout (0.0.2)
402-
tzinfo (1.2.6)
402+
tzinfo (1.2.7)
403403
thread_safe (~> 0.1)
404404
uber (0.0.15)
405405
unf (0.1.4)

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ docker-push-branch:
4848
.PHONY: ship
4949
ship: docker-build docker-login
5050

51-
ifeq ($(BRANCH),master)
51+
ifeq ($(TRAVIS_BRANCH),master)
5252
ifeq ($(TRAVIS_PULL_REQUEST),false)
5353
ship: docker-push-latest-master
5454
endif

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,3 +149,4 @@ Start with the find/get spec (for example: spec/v3/services/caches/find_spec.rb)
149149
Re-run the test at this point. Depending on what objects you are returning you may also need to add:
150150
- Add a model (either pulls from the DB or a wrapper for the class of the objects returned from another source (s3 for example), or that structures the result you will be passing back to the client)
151151
- Add a renderer (if needed to display your new model/object/collection).
152+

lib/travis/api/app/endpoint/authorization.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ class Authorization < Endpoint
104104
#
105105
# * **redirect_uri**: URI to redirect to after handshake.
106106
get '/handshake/?:provider?' do
107-
method = Travis::Features.enabled_for_all?(:vcs_login) ? :vcs_handshake : :handshake
107+
method = org? ? :handshake : :vcs_handshake
108108
params[:provider] ||= 'github'
109109

110110
send(method) do |user, token, redirect_uri|

lib/travis/api/app/middleware/user_agent_tracker.rb

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,33 @@ class UserAgentTracker < Middleware
1111
"Opera", "Mozilla"
1212
]
1313

14+
PATHS_IGNORED = [
15+
'/uptime'
16+
]
17+
18+
attr_reader :metrik_prefix
19+
20+
before do
21+
@metrik_prefix = if version = request.env['HTTP_TRAVIS_API_VERSION'].to_s.match(/^\d+(\.\d+)*/)
22+
"api.v#{version}"
23+
else
24+
"api.v2"
25+
end
26+
end
27+
1428
before(agent: /^$/) do
15-
::Metriks.meter("api.v2.user_agent.missing").mark
29+
return if PATHS_IGNORED.include?(request.path)
30+
::Metriks.meter("#{metrik_prefix}.user_agent.missing").mark
1631
halt(400, "error" => "missing User-Agent header") if Travis::Features.feature_active?(:require_user_agent)
1732
end
1833

1934
before(agent: /^.+$/) do
35+
return if PATHS_IGNORED.include?(request.path)
2036
agent = UserAgent.parse(request.user_agent)
2137
case agent.browser
22-
when *WEB_BROWSERS then mark_browser
38+
when *WEB_BROWSERS
39+
# if X-User-Agent header is set, honor that instead
40+
mark :browser, UserAgent.parse(env['HTTP_X_USER_AGENT'] || request.user_agent).browser
2341
when "curl", "Wget" then mark(:console, agent.browser)
2442
when "travis-api-wrapper" then mark(:script, :node_js, agent.browser)
2543
when "TravisPy" then mark(:script, :python, agent.browser)
@@ -30,12 +48,6 @@ class UserAgentTracker < Middleware
3048
end
3149
end
3250

33-
def mark_browser
34-
# allows a JavaScript Client to set X-User-Agent, for instance to "travis-web" in travis-web
35-
x_agent = UserAgent.parse(env['HTTP_X_USER_AGENT'] || 'unknown').browser
36-
mark(:browser, x_agent)
37-
end
38-
3951
def mark_travis(agent)
4052
command = agent.application.comment.detect { |c| c.start_with? "command " } if agent.application.comment
4153

@@ -54,7 +66,7 @@ def mark_unknown
5466
end
5567

5668
def mark(*keys)
57-
key = "api.v2.user_agent." << keys.map { |k| k.to_s.downcase.gsub(/[^a-z0-9\-\.]+/, '_') }.join('.')
69+
key = "#{metrik_prefix}.user_agent." << keys.map { |k| k.to_s.downcase.gsub(/[^a-z0-9\-\.]+/, '_') }.join('.')
5870
::Metriks.meter(key).mark
5971
end
6072
end

lib/travis/api/sidekiq.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ def gatekeeper_client
2727
def gatekeeper_pool
2828
::Sidekiq::RedisConnection.create(
2929
url: config.redis_gatekeeper.url,
30-
namespace: config.sidekiq.namespace
30+
namespace: config.sidekiq.namespace,
31+
id: nil
3132
)
3233
end
3334

lib/travis/api/v3/billing_client.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,11 @@ def get_coupon(code)
9090
handle_coupon_response(response)
9191
end
9292

93+
def update_organization_billing_permission(organization_id, billing_admin_only)
94+
response = connection.patch("/organization/permission_update/#{organization_id}", billing_admin_only)
95+
handle_subscription_response(response)
96+
end
97+
9398
private
9499

95100
def handle_subscription_response(response)

lib/travis/api/v3/github.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def deactivate_service_hook(repo)
8888
end
8989

9090
def service_hook(repo)
91-
hooks(repo).detect { |h| h['name'] == 'travis' && h.dig('config', 'domain') == service_hook_url.host }
91+
hooks(repo).detect { |h| h['name'] == 'travis' && h.dig('config', 'domain') == service_hook_url.to_s }
9292
end
9393

9494
def service_hook_url?(repo)

lib/travis/api/v3/models/build.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ class Models::BuildConfig < Model
33
end
44

55
class Models::Build < Model
6+
7+
HIGH_PRIORITY = 5
8+
69
belongs_to :commit
710
belongs_to :tag
811
belongs_to :pull_request
@@ -30,6 +33,8 @@ class Models::Build < Model
3033
primary_key: [:repository_id, :branch],
3134
class_name: 'Travis::API::V3::Models::Branch'.freeze
3235

36+
scope :running_builds, -> { where.not(state: ['passed', 'failed', 'errored', 'cancelled']) }
37+
3338
def created_by
3439
return unless sender
3540
sender.becomes(created_by_class)
@@ -88,5 +93,9 @@ def clear_debug_options!
8893
def log_complete
8994
jobs.all?(&:log_complete)
9095
end
96+
97+
def high_priority?
98+
jobs.where(priority: HIGH_PRIORITY).present?
99+
end
91100
end
92101
end

0 commit comments

Comments
 (0)