Skip to content

Commit

Permalink
Merge pull request #2134 from travis-ci/release_20240724
Browse files Browse the repository at this point in the history
Release 2024 07 24
  • Loading branch information
DominikAlberski authored Jul 24, 2024
2 parents 0a9dd66 + 8c09d23 commit a002bad
Show file tree
Hide file tree
Showing 15 changed files with 103 additions and 19 deletions.
4 changes: 3 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ gem 'connection_pool'
gem 'ed25519'
gem 'faraday'
gem 'faraday_middleware'
gem 'jemalloc', github: 'travis-ci/jemalloc-rb'
gem 'jwt', '~> 1.5'
gem 'metriks', '0.9.9.6'
gem 'metriks-librato_metrics', github: 'eric/metriks-librato_metrics'
Expand All @@ -25,6 +26,7 @@ gem 'puma'
gem 'rack', '>= 2.2.4'
gem 'rack-ssl', '~> 1.4'
gem 'rack-test', '>= 2.1.0'
gem 'redis', '~> 4'
gem 'rake'
gem 'rbtrace'
gem 'rerun', require: false, group: :development
Expand All @@ -36,7 +38,7 @@ gem 'sinatra', '>= 3.0.6'
gem 'ssh_data'
gem 'travis'
gem 'travis-config', github: 'travis-ci/travis-config'
gem 'travis-github_apps', github: 'travis-ci/travis-github_apps'
gem 'travis-github_apps', git: 'https://github.com/travis-ci/travis-github_apps', branch: 'ga-ext_access'
gem 'travis-rollout', github: 'travis-ci/travis-rollout'
gem 'travis-support', github: 'travis-ci/travis-support'

Expand Down
17 changes: 13 additions & 4 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ GIT
sinatra (= 3.0.6)
tilt (~> 2.0)

GIT
remote: https://github.com/travis-ci/jemalloc-rb.git
revision: e9528e26aff663efa2c124cdeca47700e389097d
specs:
jemalloc (1.0.2)

GIT
remote: https://github.com/travis-ci/travis-config.git
revision: 601e9a6dcb799dc14944c40153c60aaf935629ee
Expand All @@ -26,8 +32,9 @@ GIT
hashr (~> 2.0)

GIT
remote: https://github.com/travis-ci/travis-github_apps.git
revision: c96dc9330849ff3e2ccd7c9d00005a1a96c1a4b6
remote: https://github.com/travis-ci/travis-github_apps
revision: 929dadf0b4f60ca4240d52a11fc032917ff3f83a
branch: ga-ext_access
specs:
travis-github_apps (0.2.1)
activesupport (>= 3.2)
Expand Down Expand Up @@ -67,7 +74,7 @@ GEM
coder (0.4.0)
coderay (1.1.3)
concurrent-ruby (1.2.2)
connection_pool (2.2.2)
connection_pool (2.4.1)
crack (0.4.5)
rexml
diff-lcs (1.3)
Expand Down Expand Up @@ -159,7 +166,7 @@ GEM
ffi (>= 1.0.6)
msgpack (>= 0.4.3)
optimist (>= 3.0.0)
redis (4.1.4)
redis (4.8.1)
rerun (0.14.0)
listen (~> 3.0)
rest-client (2.1.0)
Expand Down Expand Up @@ -242,6 +249,7 @@ DEPENDENCIES
ed25519
faraday
faraday_middleware
jemalloc!
jwt (~> 1.5)
metriks (= 0.9.9.6)
metriks-librato_metrics!
Expand All @@ -256,6 +264,7 @@ DEPENDENCIES
rack-test (>= 2.1.0)
rake
rbtrace
redis (~> 4)
rerun
rest-client
rspec (~> 3.0)
Expand Down
2 changes: 1 addition & 1 deletion lib/travis/build/addons.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'active_support/core_ext/string/inflections'
require 'active_support/core_ext/string/inflections.rb'
require 'travis/build/addons/apt'
require 'travis/build/addons/apt_packages'
require 'travis/build/addons/apt_retries'
Expand Down
2 changes: 1 addition & 1 deletion lib/travis/build/appliances/agent.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def start
end

def store_key
redis.set(key, 1, ex: TTL)
redis.setex(key, TTL, 1)
end

def agent
Expand Down
13 changes: 12 additions & 1 deletion lib/travis/build/appliances/services.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ class Services < Base
'memcache' => 'memcached',
'neo4j-server' => 'neo4j',
'rabbitmq' => 'rabbitmq-server',
'redis' => 'redis-server'
'redis' => 'redis-server',
'cri-dockerd' => 'cri_dockerd'
}

def apply
Expand Down Expand Up @@ -56,6 +57,16 @@ def apply_mongodb
end
end

def apply_cri_dockerd
sh.if '"$TRAVIS_OS_NAME" != linux' do
sh.echo "Addon cri-dockerd is not supported on #{data[:config][:os]}", ansi: :red
end
sh.else do
sh.raw bash('travis_setup_cri-dockerd'), echo: false, timing: false
sh.cmd "travis_setup_cri-dockerd", echo: true, timing: true
end
end

def apply_mysql
sh.raw <<~BASH
travis_mysql_ping() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module Appliances
class SetDockerMtuAndRegistryMirrors < Base

REGISTRY_URL = Travis::Build.config.registry_url.output_safe.freeze
MTU = Travis::Build.config.docker.mtu.to_i.freeze

def apply?
linux?
Expand All @@ -16,11 +17,11 @@ def apply
sh.raw <<-EOF
sudo test -f /etc/docker/daemon.json
if [[ $? = 0 ]]; then
echo '[{"op":"add","path":"/mtu","value":1460}]' > mtu.jsonpatch
echo '[{"op":"add","path":"/mtu","value":#{MTU}}]' > mtu.jsonpatch
sudo jsonpatch /etc/docker/daemon.json mtu.jsonpatch > daemon.json
sudo mv daemon.json /etc/docker/daemon.json
else
echo '{"mtu":1460}' | sudo tee /etc/docker/daemon.json > /dev/null
echo '{"mtu":#{MTU}}' | sudo tee /etc/docker/daemon.json > /dev/null
fi
if curl --connect-timeout 1 -fsSL -o /dev/null \
Expand Down
26 changes: 26 additions & 0 deletions lib/travis/build/bash/travis_setup_cri-dockerd.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
travis_setup_cri-dockerd() {
local cri_containerd_cni_version='1.6.14'
local crictl_version='v1.24.2'
echo -e "${ANSI_YELLOW}cri-dockerd setup ${ANSI_CLEAR}"
sudo bash -c "
groupadd docker || true;
apt-get update && apt-get install socat eptables;
apt-get install conntrack containerd;
wget https://github.com/containerd/containerd/releases/download/v${cri_containerd_cni_version}/cri-containerd-cni-${cri_containerd_cni_version}-linux-amd64.tar.gz;
tar zxvf cri-containerd-cni-${cri_containerd_cni_version}-linux-amd64.tar.gz -C /;
rm -rf cri-containerd-cni-1.6.14-linux-amd64.tar.gz;
wget https://github.com/Mirantis/cri-dockerd/releases/download/v0.3.0/cri-dockerd_0.3.0.3-0.ubuntu-bionic_amd64.deb;
dpkg -i cri-dockerd_0.3.0.3-0.ubuntu-bionic_amd64.deb;
wget https://raw.githubusercontent.com/Mirantis/cri-dockerd/v0.3.0/packaging/systemd/cri-docker.service
wget https://raw.githubusercontent.com/Mirantis/cri-dockerd/v0.3.0/packaging/systemd/cri-docker.socket;
mv cri-docker.socket cri-docker.service /etc/systemd/system/;
systemctl daemon-reload;
systemctl enable cri-docker.service;
systemctl enable --now cri-docker.socket;
wget https://github.com/kubernetes-sigs/cri-tools/releases/download/${crictl_version}/crictl-${crictl_version}-linux-amd64.tar.gz
tar zxvf crictl-${crictl_version}-linux-amd64.tar.gz -C /usr/bin;
rm -f crictl-${crictl_version}-linux-amd64.tar.gz;
echo runtime-endpoint: unix:///run/containerd/containerd.sock > /etc/crictl.yaml;
echo image-endpoint: unix:///run/containerd/containerd.sock >> /etc/crictl.yaml;
"
}
3 changes: 3 additions & 0 deletions lib/travis/build/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ def sc_data
},
maven_central_mirror: ENV.fetch('TRAVIS_MAVEN_CENTRAL_MIRROR', ''),
registry_url: ENV.fetch('TRAVIS_BUILD_REGISTRY_URL', 'https://registry.travis-ci.com'),
docker: {
mtu: ENV.fetch('TRAVIS_BUILD_DOCKER_MTU', 1350)
},
network: {
wait_retries: Integer(ENV.fetch(
'TRAVIS_BUILD_NETWORK_WAIT_RETRIES',
Expand Down
8 changes: 6 additions & 2 deletions lib/travis/build/data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def ssh_key?
def ssh_key
@ssh_key ||= if ssh_key = data[:ssh_key]
SshKey.new(ssh_key[:value], ssh_key[:source], ssh_key[:encoded], ssh_key[:public_key])
elsif source_key = data[:config][:source_key]
elsif data[:config] && source_key = data[:config][:source_key]
SshKey.new(source_key, nil, true, nil)
end
end
Expand Down Expand Up @@ -152,13 +152,17 @@ def source_https?
def source_ssh?
return false if prefer_https?
((repo_private? || force_private?) && !installation?) ||
(repo_private? && custom_ssh_key?)
((repo_private? || enterprise?) && custom_ssh_key?)
end

def force_private?
github? && !source_host&.include?('github.com')
end

def enterprise?
ENV['TRAVIS_ENTERPRISE'] == 'true' || nil
end

def github?
repository[:vcs_type] == 'GithubRepository'
end
Expand Down
1 change: 1 addition & 0 deletions lib/travis/build/script.rb
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,7 @@ def error_message_ary(exception, event)
end

def show_compile_error_msg(exception, event)
puts "Exception Occurred when trying to compile #{exception.class}. Message: #{exception.message}. Backtrace: \n #{exception.backtrace.join("\n")}"
@sh = Shell::Builder.new
error_message_ary(exception, event).each { |line| sh.raw "echo -e \"\033[31;1m#{line}\033[0m\"" }
sh.raw "exit 2"
Expand Down
1 change: 0 additions & 1 deletion lib/travis/build/script/node_js.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ def setup
sh.newline

npm_disable_prefix
npm_disable_spinner
npm_disable_progress
npm_disable_strict_ssl unless npm_strict_ssl?
install_yarn_when_locked
Expand Down
2 changes: 1 addition & 1 deletion lib/travis/services/vault/keys/kv2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module Travis
module Vault
class Keys
class KV2
def self.resolve(namespace, mount ,path, vault)
def self.resolve(namespace, mount, path, vault)
response = RestClient.get("#{vault[:api_url]}/v1/#{mount}/data/#{path}", 'X-Vault-Token': vault[:token], 'X-Vault-Namespace': namespace ? namespace : "")
JSON.parse(response.body).dig('data', 'data') if response.code == 200
rescue RestClient::ExceptionWithResponse, SocketError
Expand Down
32 changes: 32 additions & 0 deletions spec/build/data_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -141,5 +141,37 @@
it { expect(data.source_ssh?).to be nil }
it { expect(data.token).to eq 'access_token' }
end

describe 'source_ssh is true for public enterprise repository' do
let(:config) { {oauth_token: 'access_token', prefer_https: false, repository: { installation_id: 1, private: false, vcs_id: 123} } }
let(:data) { Travis::Build::Data.new(config) }

before {
Travis::GithubApps.any_instance.stubs(:access_token).returns 'access_token'
ENV['TRAVIS_ENTERPRISE'] = 'true'
}
after {
ENV['TRAVIS_ENTERPRISE'] = nil
}
it { expect(data.installation?).to be true }
it { expect(data.source_ssh?).to be false }
it { expect(data.token).to eq 'access_token' }
end

describe 'source_ssh is true for public enterprise repository if custom key is present' do
let(:config) { {oauth_token: 'access_token', prefer_https: false, repository: { installation_id: 1, private: false, vcs_id: 123}, ssh_key: { value: TEST_PRIVATE_KEY, source: 'repository_settings' } } }
let(:data) { Travis::Build::Data.new(config) }

before {
Travis::GithubApps.any_instance.stubs(:access_token).returns 'access_token'
ENV['TRAVIS_ENTERPRISE'] = 'true'
}
after {
ENV['TRAVIS_ENTERPRISE'] = nil
}
it { expect(data.installation?).to be true }
it { expect(data.source_ssh?).to be true }
it { expect(data.token).to eq 'access_token' }
end
end
end
4 changes: 0 additions & 4 deletions spec/build/script/node_js_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,6 @@
should include_sexp [:cmd, 'npm --version', echo: true]
end

it 'disables the npm spinner' do
should include_sexp [:cmd, 'npm config set spin false --silent || true', assert: true]
end

describe 'if package.json exists' do
let(:sexp) { sexp_find(subject, [:if, '-f package.json'], [:then]) }

Expand Down
2 changes: 1 addition & 1 deletion spec/build/services/vault/keys/kv2_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

describe Travis::Vault::Keys::KV2 do
describe '.resolve' do
subject { described_class.resolve('','secret', path, vault) }
subject { described_class.resolve('', 'secret', path, vault) }

let(:vault) do
{
Expand Down

0 comments on commit a002bad

Please sign in to comment.