Add latest changes from gitlab-org/gitlab@master

This commit is contained in:
GitLab Bot 2023-04-17 18:14:29 +00:00
parent 2a6300a15a
commit 55bc011bc0
21 changed files with 200 additions and 372 deletions

1
.gitignore vendored
View File

@ -69,7 +69,6 @@ eslint-report.html
/rails_best_practices_output.html
/tags
/vendor/bundle/*
/vendor/gitaly-ruby
/vendor/package_metadata_db/
/builds*
/.gitlab_workhorse_secret

View File

@ -39,22 +39,12 @@
<<: *ruby-gems-cache
policy: push # We want to rebuild the cache from scratch to ensure stale dependencies are cleaned up.
.gitaly-ruby-gems-cache: &gitaly-ruby-gems-cache
key: "gitaly-ruby-gems-debian-${DEBIAN_VERSION}-ruby-${RUBY_VERSION}"
paths:
- vendor/gitaly-ruby/
policy: pull
.gitaly-ruby-gems-cache-push: &gitaly-ruby-gems-cache-push
<<: *gitaly-ruby-gems-cache
policy: push # We want to rebuild the cache from scratch to ensure stale dependencies are cleaned up.
.gitaly-binaries-cache: &gitaly-binaries-cache
key:
files:
- GITALY_SERVER_VERSION
- lib/gitlab/setup_helper.rb
prefix: "gitaly-binaries-debian-${DEBIAN_VERSION}-ruby-${RUBY_VERSION}"
prefix: "gitaly-binaries-debian-${DEBIAN_VERSION}"
paths:
- ${TMP_TEST_FOLDER}/gitaly/_build/bin/
- ${TMP_TEST_FOLDER}/gitaly/_build/deps/git/install/
@ -66,7 +56,6 @@
- ${TMP_TEST_FOLDER}/gitaly/Makefile
- ${TMP_TEST_FOLDER}/gitaly/praefect.config.toml
- ${TMP_TEST_FOLDER}/gitaly/praefect-db.config.toml
- ${TMP_TEST_FOLDER}/gitaly/ruby/
policy: pull
.go-pkg-cache: &go-pkg-cache
@ -140,14 +129,12 @@
.setup-test-env-cache:
cache:
- *ruby-gems-cache
- *gitaly-ruby-gems-cache
- *gitaly-binaries-cache
- *go-pkg-cache
.setup-test-env-cache-push:
cache:
- *ruby-gems-cache-push
- *gitaly-ruby-gems-cache-push
- *go-pkg-cache-push
.gitaly-binaries-cache-push:
@ -162,7 +149,6 @@
.rails-cache:
cache:
- *ruby-gems-cache
- *gitaly-ruby-gems-cache
.static-analysis-cache:
cache:

View File

@ -30,7 +30,6 @@ setup-test-env:
- ${TMP_TEST_FOLDER}/gitaly/Makefile
- ${TMP_TEST_FOLDER}/gitaly/praefect.config.toml
- ${TMP_TEST_FOLDER}/gitaly/praefect-db.config.toml
- ${TMP_TEST_FOLDER}/gitaly/ruby/
- ${TMP_TEST_FOLDER}/gitlab-elasticsearch-indexer/bin/gitlab-elasticsearch-indexer
- ${TMP_TEST_FOLDER}/gitlab-shell/
- ${TMP_TEST_FOLDER}/gitlab-test-fork/

View File

@ -428,6 +428,8 @@ module Ci
)
end
scope :order_id_desc, -> { order(id: :desc) }
# Returns the pipelines in descending order (= newest first), optionally
# limited to a number of references.
#

View File

@ -0,0 +1,18 @@
# frozen_string_literal: true
class AddIndexToSecurityScansOnScanType < Gitlab::Database::Migration[2.1]
disable_ddl_transaction!
TABLE_NAME = :security_scans
INDEX_NAME = 'index_for_security_scans_scan_type'
SUCCEEDED = 1
def up
add_concurrent_index TABLE_NAME, [:scan_type, :project_id, :pipeline_id], where: "status = #{SUCCEEDED}",
name: INDEX_NAME
end
def down
remove_concurrent_index_by_name TABLE_NAME, INDEX_NAME
end
end

View File

@ -0,0 +1 @@
0715accd97005c76bcb1e975bf00fd5fd4f34375a5d5a4131d107f13b1cd6be0

View File

@ -30616,6 +30616,8 @@ CREATE UNIQUE INDEX index_feature_gates_on_feature_key_and_key_and_value ON feat
CREATE UNIQUE INDEX index_features_on_key ON features USING btree (key);
CREATE INDEX index_for_security_scans_scan_type ON security_scans USING btree (scan_type, project_id, pipeline_id) WHERE (status = 1);
CREATE INDEX index_for_status_per_branch_per_project ON merge_trains USING btree (target_project_id, target_branch, status);
CREATE INDEX index_fork_network_members_on_fork_network_id ON fork_network_members USING btree (fork_network_id);

View File

@ -760,27 +760,6 @@ Configure Gitaly with TLS in one of two ways:
For information on observing the type of Gitaly connections being served, see the
[relevant documentation](monitoring.md#queries).
## `gitaly-ruby`
Gitaly was developed to replace the Ruby application code in GitLab.
To save time and avoid the risk of rewriting existing application logic, we chose to copy some
application code from GitLab into Gitaly.
To be able to run that code, `gitaly-ruby` was created, which is a "sidecar" process for the main
Gitaly Go process. Some examples of things that are implemented in `gitaly-ruby` are:
- RPCs that deal with wikis.
- RPCs that create commits on behalf of a user, such as merge commits.
Recommended settings:
- At least 300 MB memory per worker.
- No more than one worker per core.
NOTE:
[Epic 2862](https://gitlab.com/groups/gitlab-org/-/epics/2862) proposes to remove `gitaly-ruby`.
## Limit RPC concurrency
WARNING:

View File

@ -202,7 +202,6 @@ The following values configure logging in Gitaly under the `[logging]` section.
| `level` | string | no | Log level: `debug`, `info`, `warn`, `error`, `fatal`, or `panic`. Default: `info`. |
| `sentry_dsn` | string | no | Sentry DSN (Data Source Name) for exception monitoring. |
| `sentry_environment` | string | no | [Sentry Environment](https://docs.sentry.io/product/sentry-basics/environments/) for exception monitoring. |
| `ruby_sentry_dsn` | string | no | Sentry DSN (Data Source Name) for `gitaly-ruby` exception monitoring. |
While the main Gitaly application logs go to `stdout`, there are some extra log
files that go to a configured directory, like the GitLab Shell logs.

View File

@ -17,7 +17,7 @@ module Gitlab
#
# 1. Sidekiq: MergeService runs and updates the merge request in a locked state.
# 2. Gitaly: The UserMergeBranch RPC runs.
# 3. Gitaly (gitaly-ruby): This RPC calls the pre-receive hook.
# 3. Gitaly: The RPC calls the pre-receive hook.
# 4. Rails: This hook makes an API request to /api/v4/internal/allowed.
# 5. Rails: This API check does a SQL query for locked merge
# requests with a matching SHA.

View File

@ -54,8 +54,6 @@ module Gitlab
# state.
alias_method :object_pool_remote_name, :gl_repository
# This initializer method is only used on the client side (gitlab-ce).
# Gitaly-ruby uses a different initializer.
def initialize(storage, relative_path, gl_repository, gl_project_path, container: nil)
@storage = storage
@relative_path = relative_path

View File

@ -80,7 +80,7 @@ module Gitlab
# because it uses a Unix socket.
# For development and testing purposes, an extra storage is added to gitaly,
# which is not known to Rails, but must be explicitly stubbed.
def configuration_toml(gitaly_dir, storage_paths, options, gitaly_ruby: true)
def configuration_toml(gitaly_dir, storage_paths, options)
storages = []
address = nil
@ -128,7 +128,6 @@ module Gitlab
FileUtils.mkdir(runtime_dir) unless File.exist?(runtime_dir)
config[:runtime_dir] = runtime_dir
config[:'gitaly-ruby'] = { dir: File.join(gitaly_dir, 'ruby') } if gitaly_ruby
config[:'gitlab-shell'] = { dir: Gitlab.config.gitlab_shell.path }
config[:bin_dir] = File.expand_path(File.join(gitaly_dir, '_build', 'bin')) # binaries by default are in `_build/bin`
config[:gitlab] = { url: Gitlab.config.gitlab.url }

View File

@ -26,17 +26,8 @@ Usage: rake "gitlab:gitaly:install[/installation/dir,/storage/path]")
Gitlab::SetupHelper::Gitaly.create_configuration(args.dir, storage_paths)
Dir.chdir(args.dir) do
Bundler.with_original_env do
env = { "RUBYOPT" => nil, "BUNDLE_GEMFILE" => nil }
if Rails.env.test?
env["GEM_HOME"] = Bundler.bundle_path.to_s
env["BUNDLE_DEPLOYMENT"] = 'false'
end
output, status = Gitlab::Popen.popen([make_cmd, 'clean', 'all'], nil, env)
raise "Gitaly failed to compile: #{output}" unless status&.zero?
end
output, status = Gitlab::Popen.popen([make_cmd, 'clean', 'all'])
raise "Gitaly failed to compile: #{output}" unless status&.zero?
end
end

View File

@ -6,8 +6,8 @@ require 'fileutils'
require_relative '../spec/support/helpers/gitaly_setup'
# This script assumes tmp/tests/gitaly already contains the correct
# Gitaly version. We just have to compile it and run its 'bundle
# install'. We have this separate script for that to avoid bundle
# Gitaly version. We just have to compile it.
# We have this separate script for that to avoid bundle
# poisoning in CI. This script should only be run in CI.
class GitalyTestBuild
include GitalySetup
@ -16,14 +16,11 @@ class GitalyTestBuild
# If we have the binaries from the cache, we can skip building them again
if File.exist?(tmp_tests_gitaly_bin_dir)
GitalySetup::LOGGER.debug "Gitaly binary already built. Skip building...\n"
# We still need to install the gems in that case
install_gitaly_gems
else
abort 'gitaly build failed' unless build_gitaly
end
ensure_gitlab_shell_secret!
check_gitaly_config!
# Starting gitaly further validates its configuration
gitaly_pid = start_gitaly

View File

@ -9,8 +9,6 @@ class GitalyTestSpawn
include GitalySetup
def run
install_gitaly_gems
# Run Praefect migrations
setup_praefect

View File

@ -1,7 +1,10 @@
import Vue from 'vue';
import VueApollo from 'vue-apollo';
import { GlBadge, GlLink, GlIcon, GlIntersectionObserver } from '@gitlab/ui';
import { shallowMount, RouterLinkStub } from '@vue/test-utils';
import { nextTick } from 'vue';
import refQuery from '~/repository/queries/ref.query.graphql';
import { createMockDirective, getBinding } from 'helpers/vue_mock_directive';
import createMockApollo from 'helpers/mock_apollo_helper';
import TableRow from '~/repository/components/table/row.vue';
import FileIcon from '~/vue_shared/components/file_icon.vue';
import { FILE_SYMLINK_MODE } from '~/vue_shared/constants';
@ -9,23 +12,37 @@ import { ROW_APPEAR_DELAY } from '~/repository/constants';
const COMMIT_MOCK = { lockLabel: 'Locked by Root', committedDate: '2019-01-01' };
let vm;
let wrapper;
let $router;
function factory(propsData = {}) {
const createMockApolloProvider = (mockData) => {
Vue.use(VueApollo);
const apolloProver = createMockApollo([]);
apolloProver.clients.defaultClient.cache.writeQuery({ query: refQuery, data: { ...mockData } });
return apolloProver;
};
function factory({ mockData = { ref: 'main', escapedRef: 'main' }, propsData = {} } = {}) {
$router = {
push: jest.fn(),
};
vm = shallowMount(TableRow, {
wrapper = shallowMount(TableRow, {
apolloProvider: createMockApolloProvider(mockData),
propsData: {
id: '1',
sha: '0as4k',
commitInfo: COMMIT_MOCK,
...propsData,
name: propsData.path,
name: 'name',
currentPath: 'gitlab-org/gitlab-ce',
projectPath: 'gitlab-org/gitlab-ce',
url: `https://test.com`,
totalEntries: 10,
rowNumber: 123,
path: 'gitlab-org/gitlab-ce',
type: 'tree',
...propsData,
},
directives: {
GlHoverLoad: createMockDirective('gl-hover-load'),
@ -37,63 +54,67 @@ function factory(propsData = {}) {
RouterLink: RouterLinkStub,
},
});
// setData usage is discouraged. See https://gitlab.com/groups/gitlab-org/-/epics/7330 for details
// eslint-disable-next-line no-restricted-syntax
vm.setData({ escapedRef: 'main' });
}
describe('Repository table row component', () => {
const findRouterLink = () => vm.findComponent(RouterLinkStub);
const findIntersectionObserver = () => vm.findComponent(GlIntersectionObserver);
const findIcon = () => wrapper.findComponent(GlIcon);
const findFileIcon = () => wrapper.findComponent(FileIcon);
const findBadge = () => wrapper.findComponent(GlBadge);
const findRouterLink = () => wrapper.findComponent(RouterLinkStub);
const findIntersectionObserver = () => wrapper.findComponent(GlIntersectionObserver);
it('renders table row', async () => {
factory({
id: '1',
sha: '123',
path: 'test',
type: 'file',
currentPath: '/',
propsData: {
id: '1',
sha: '123',
path: 'test',
type: 'file',
currentPath: '/',
},
});
await nextTick();
expect(vm.element).toMatchSnapshot();
expect(wrapper.element).toMatchSnapshot();
});
it('renders a symlink table row', async () => {
factory({
id: '1',
sha: '123',
path: 'test',
type: 'blob',
currentPath: '/',
mode: FILE_SYMLINK_MODE,
propsData: {
id: '1',
sha: '123',
path: 'test',
type: 'blob',
currentPath: '/',
mode: FILE_SYMLINK_MODE,
},
});
await nextTick();
expect(vm.element).toMatchSnapshot();
expect(wrapper.element).toMatchSnapshot();
});
it('renders table row for path with special character', async () => {
factory({
id: '1',
sha: '123',
path: 'test$/test',
type: 'file',
currentPath: 'test$',
propsData: {
id: '1',
sha: '123',
path: 'test$/test',
type: 'file',
currentPath: 'test$',
},
});
await nextTick();
expect(vm.element).toMatchSnapshot();
expect(wrapper.element).toMatchSnapshot();
});
it('renders a gl-hover-load directive', () => {
factory({
id: '1',
sha: '123',
path: 'test',
type: 'blob',
currentPath: '/',
propsData: {
id: '1',
sha: '123',
path: 'test',
type: 'blob',
currentPath: '/',
},
});
const hoverLoadDirective = getBinding(findRouterLink().element, 'gl-hover-load');
@ -109,15 +130,16 @@ describe('Repository table row component', () => {
${'commit'} | ${'a'} | ${'hyperlink'}
`('renders a $componentName for type $type', async ({ type, component }) => {
factory({
id: '1',
sha: '123',
path: 'test',
type,
currentPath: '/',
propsData: {
id: '1',
sha: '123',
path: 'test',
type,
currentPath: '/',
},
});
await nextTick();
expect(vm.findComponent(component).exists()).toBe(true);
expect(wrapper.findComponent(component).exists()).toBe(true);
});
it.each`
@ -126,125 +148,136 @@ describe('Repository table row component', () => {
${'Änderungen'}
`('renders link for $path', async ({ path }) => {
factory({
id: '1',
sha: '123',
path,
type: 'tree',
currentPath: '/',
propsData: {
id: '1',
sha: '123',
path,
type: 'tree',
currentPath: '/',
},
});
await nextTick();
expect(vm.findComponent({ ref: 'link' }).props('to')).toEqual({
expect(wrapper.findComponent({ ref: 'link' }).props('to')).toEqual({
path: `/-/tree/main/${encodeURIComponent(path)}`,
});
});
it('renders link for directory with hash', async () => {
factory({
id: '1',
sha: '123',
path: 'test#',
type: 'tree',
currentPath: '/',
propsData: {
id: '1',
sha: '123',
path: 'test#',
type: 'tree',
currentPath: '/',
},
});
await nextTick();
expect(vm.find('.tree-item-link').props('to')).toEqual({ path: '/-/tree/main/test%23' });
expect(wrapper.find('.tree-item-link').props('to')).toEqual({ path: '/-/tree/main/test%23' });
});
it('renders commit ID for submodule', async () => {
factory({
id: '1',
sha: '123',
path: 'test',
type: 'commit',
currentPath: '/',
propsData: {
id: '1',
sha: '123',
path: 'test',
type: 'commit',
currentPath: '/',
},
});
await nextTick();
expect(vm.find('.commit-sha').text()).toContain('1');
expect(wrapper.find('.commit-sha').text()).toContain('1');
});
it('renders link with href', async () => {
factory({
id: '1',
sha: '123',
path: 'test',
type: 'blob',
url: 'https://test.com',
currentPath: '/',
propsData: {
id: '1',
sha: '123',
path: 'test',
type: 'blob',
url: 'https://test.com',
currentPath: '/',
},
});
await nextTick();
expect(vm.find('a').attributes('href')).toEqual('https://test.com');
expect(wrapper.find('a').attributes('href')).toEqual('https://test.com');
});
it('renders LFS badge', async () => {
factory({
id: '1',
sha: '123',
path: 'test',
type: 'commit',
currentPath: '/',
lfsOid: '1',
propsData: {
id: '1',
sha: '123',
path: 'test',
type: 'commit',
currentPath: '/',
lfsOid: '1',
},
});
await nextTick();
expect(vm.findComponent(GlBadge).exists()).toBe(true);
expect(findBadge().exists()).toBe(true);
});
it('renders commit and web links with href for submodule', async () => {
factory({
id: '1',
sha: '123',
path: 'test',
type: 'commit',
url: 'https://test.com',
submoduleTreeUrl: 'https://test.com/commit',
currentPath: '/',
propsData: {
id: '1',
sha: '123',
path: 'test',
type: 'commit',
url: 'https://test.com',
submoduleTreeUrl: 'https://test.com/commit',
currentPath: '/',
},
});
await nextTick();
expect(vm.find('a').attributes('href')).toEqual('https://test.com');
expect(vm.findComponent(GlLink).attributes('href')).toEqual('https://test.com/commit');
expect(wrapper.find('a').attributes('href')).toEqual('https://test.com');
expect(wrapper.findComponent(GlLink).attributes('href')).toEqual('https://test.com/commit');
});
it('renders lock icon', async () => {
factory({
id: '1',
sha: '123',
path: 'test',
type: 'tree',
currentPath: '/',
propsData: {
id: '1',
sha: '123',
path: 'test',
type: 'tree',
currentPath: '/',
},
});
await nextTick();
expect(vm.findComponent(GlIcon).exists()).toBe(true);
expect(vm.findComponent(GlIcon).props('name')).toBe('lock');
expect(findIcon().exists()).toBe(true);
expect(findIcon().props('name')).toBe('lock');
});
it('renders loading icon when path is loading', () => {
factory({
id: '1',
sha: '1',
path: 'test',
type: 'tree',
currentPath: '/',
loadingPath: 'test',
});
expect(vm.findComponent(FileIcon).props('loading')).toBe(true);
});
describe('row visibility', () => {
beforeEach(() => {
factory({
propsData: {
id: '1',
sha: '1',
path: 'test',
type: 'tree',
currentPath: '/',
commitInfo: null,
loadingPath: 'test',
},
});
expect(findFileIcon().props('loading')).toBe(true);
});
describe('row visibility', () => {
beforeEach(() => {
factory({
propsData: {
id: '1',
sha: '1',
path: 'test',
type: 'tree',
currentPath: '/',
commitInfo: null,
},
});
});
@ -258,7 +291,7 @@ describe('Repository table row component', () => {
expect(setTimeoutSpy).toHaveBeenCalledTimes(1);
expect(setTimeoutSpy).toHaveBeenLastCalledWith(expect.any(Function), ROW_APPEAR_DELAY);
expect(vm.emitted('row-appear')).toEqual([[123]]);
expect(wrapper.emitted('row-appear')).toEqual([[123]]);
});
});
});

View File

@ -2452,107 +2452,6 @@ RSpec.describe Gitlab::Git::Repository, feature_category: :source_code_managemen
end
end
describe '#squash' do
let(:branch_name) { 'fix' }
let(:start_sha) { TestEnv::BRANCH_SHA['master'] }
let(:end_sha) { '12d65c8dd2b2676fa3ac47d955accc085a37a9c1' }
subject do
opts = {
branch: branch_name,
start_sha: start_sha,
end_sha: end_sha,
author: user,
message: 'Squash commit message'
}
repository.squash(user, opts)
end
# Should be ported to gitaly-ruby rspec suite https://gitlab.com/gitlab-org/gitaly/issues/1234
skip 'sparse checkout' do
let(:expected_files) { %w(files files/js files/js/application.js) }
it 'checks out only the files in the diff' do
allow(repository).to receive(:with_worktree).and_wrap_original do |m, *args|
m.call(*args) do
worktree_path = args[0]
files_pattern = File.join(worktree_path, '**', '*')
expected = expected_files.map do |path|
File.expand_path(path, worktree_path)
end
expect(Dir[files_pattern]).to eq(expected)
end
end
subject
end
context 'when the diff contains a rename' do
let(:end_sha) do
repository.commit_files(
user,
branch_name: repository.root_ref,
message: 'Move CHANGELOG to encoding/',
actions: [{
action: :move,
previous_path: 'CHANGELOG',
file_path: 'encoding/CHANGELOG',
content: 'CHANGELOG'
}]
).newrev
end
after do
# Erase our commits so other tests get the original repo
repository.write_ref(repository.root_ref, TestEnv::BRANCH_SHA['master'])
end
it 'does not include the renamed file in the sparse checkout' do
allow(repository).to receive(:with_worktree).and_wrap_original do |m, *args|
m.call(*args) do
worktree_path = args[0]
files_pattern = File.join(worktree_path, '**', '*')
expect(Dir[files_pattern]).not_to include('CHANGELOG')
expect(Dir[files_pattern]).not_to include('encoding/CHANGELOG')
end
end
subject
end
end
end
# Should be ported to gitaly-ruby rspec suite https://gitlab.com/gitlab-org/gitaly/issues/1234
skip 'with an ASCII-8BIT diff' do
let(:diff) { "diff --git a/README.md b/README.md\nindex faaf198..43c5edf 100644\n--- a/README.md\n+++ b/README.md\n@@ -1,4 +1,4 @@\n-testme\n+✓ testme\n ======\n \n Sample repo for testing gitlab features\n" }
it 'applies a ASCII-8BIT diff' do
allow(repository).to receive(:run_git!).and_call_original
allow(repository).to receive(:run_git!).with(%W(diff --binary #{start_sha}...#{end_sha})).and_return(diff.force_encoding('ASCII-8BIT'))
expect(subject).to match(/\h{40}/)
end
end
# Should be ported to gitaly-ruby rspec suite https://gitlab.com/gitlab-org/gitaly/issues/1234
skip 'with trailing whitespace in an invalid patch' do
let(:diff) { "diff --git a/README.md b/README.md\nindex faaf198..43c5edf 100644\n--- a/README.md\n+++ b/README.md\n@@ -1,4 +1,4 @@\n-testme\n+ \n ====== \n \n Sample repo for testing gitlab features\n" }
it 'does not include whitespace warnings in the error' do
allow(repository).to receive(:run_git!).and_call_original
allow(repository).to receive(:run_git!).with(%W(diff --binary #{start_sha}...#{end_sha})).and_return(diff.force_encoding('ASCII-8BIT'))
expect { subject }.to raise_error do |error|
expect(error).to be_a(described_class::GitError)
expect(error.message).not_to include('trailing whitespace')
end
end
end
end
def create_remote_branch(remote_name, branch_name, source_branch_name)
source_branch = repository.find_branch(source_branch_name)
repository.write_ref("refs/remotes/#{remote_name}/#{branch_name}", source_branch.dereferenced_target.sha)

View File

@ -546,6 +546,17 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep, feature_category:
end
end
describe '.order_id_desc' do
subject(:pipelines_ordered_by_id) { described_class.order_id_desc }
let(:older_pipeline) { create(:ci_pipeline, id: 99, project: project) }
let(:newest_pipeline) { create(:ci_pipeline, id: 100, project: project) }
it 'only returns the pipelines ordered by id' do
expect(pipelines_ordered_by_id).to eq([newest_pipeline, older_pipeline])
end
end
describe '.jobs_count_in_alive_pipelines' do
before do
::Ci::HasStatus::ALIVE_STATUSES.each do |status|

View File

@ -60,11 +60,13 @@ RSpec.describe Git::WikiPushService::Change, feature_category: :source_code_mana
end
%i[added renamed modified].each do |op|
let(:operation) { op }
let(:slug) { new_path.chomp('.md') }
let(:revision) { change[:newrev] }
context "the operation is #{op}" do
let(:operation) { op }
let(:slug) { new_path.chomp('.md') }
let(:revision) { change[:newrev] }
it { is_expected.to have_attributes(page: wiki_page) }
it { is_expected.to have_attributes(page: wiki_page) }
end
end
end
end

View File

@ -10,7 +10,6 @@ require 'securerandom'
require 'socket'
require 'logger'
require 'fileutils'
require 'bundler'
require_relative '../../../lib/gitlab/utils'
@ -50,51 +49,18 @@ module GitalySetup
expand_path('.gitlab_shell_secret')
end
def gemfile
File.join(tmp_tests_gitaly_dir, 'ruby', 'Gemfile')
end
def gemfile_dir
File.dirname(gemfile)
end
def gitlab_shell_secret_file
File.join(tmp_tests_gitlab_shell_dir, '.gitlab_shell_secret')
end
def env
{
'GEM_PATH' => Gem.path.join(':'),
'BUNDLER_SETUP' => nil,
'BUNDLE_INSTALL_FLAGS' => nil,
'BUNDLE_IGNORE_CONFIG' => '1',
'BUNDLE_PATH' => bundle_path,
'BUNDLE_GEMFILE' => gemfile,
'BUNDLE_JOBS' => '4',
'BUNDLE_RETRY' => '3',
'RUBYOPT' => nil,
# Git hooks can't run during tests as the internal API is not running.
'GITALY_TESTING_NO_GIT_HOOKS' => "1",
'GITALY_TESTING_ENABLE_ALL_FEATURE_FLAGS' => "true"
}
end
def bundle_path
# Allow the user to override BUNDLE_PATH if they need to
return ENV['GITALY_TEST_BUNDLE_PATH'] if ENV['GITALY_TEST_BUNDLE_PATH']
if ENV['CI']
expand_path('vendor/gitaly-ruby')
else
explicit_path = Bundler.configured_bundle_path.explicit_path
return unless explicit_path
expand_path(explicit_path)
end
end
def config_path(service)
case service
when :gitaly
@ -125,10 +91,6 @@ module GitalySetup
system(env, *cmd, exception: true, chdir: tmp_tests_gitaly_dir)
end
def install_gitaly_gems
run_command(%W[make #{tmp_tests_gitaly_dir}/.ruby-bundle], env: env)
end
def build_gitaly
run_command(%w[make all WITH_BUNDLED_GIT=YesPlease], env: env.merge('GIT_VERSION' => nil))
end
@ -188,35 +150,6 @@ module GitalySetup
end
end
def check_gitaly_config!
LOGGER.debug "Checking gitaly-ruby Gemfile...\n"
unless File.exist?(gemfile)
message = "#{gemfile} does not exist."
message += "\n\nThis might have happened if the CI artifacts for this build were destroyed." if ENV['CI']
abort message
end
LOGGER.debug "Checking gitaly-ruby bundle...\n"
bundle_install unless bundle_check
abort 'bundle check failed' unless bundle_check
end
def bundle_check
bundle_cmd('check')
end
def bundle_install
bundle_cmd('install')
end
def bundle_cmd(cmd)
out = ENV['CI'] ? $stdout : '/dev/null'
system(env, 'bundle', cmd, out: out, chdir: gemfile_dir)
end
def connect_proc(toml)
# This code needs to work in an environment where we cannot use bundler,
# so we cannot easily use the toml-rb gem. This ad-hoc parser should be
@ -358,8 +291,6 @@ module GitalySetup
end
def spawn_gitaly(toml = nil)
check_gitaly_config!
pids = []
if toml

View File

@ -66,7 +66,7 @@ RSpec.describe 'gitlab:gitaly namespace rake task', :silence_stdout do
.with(%w[which gmake])
.and_return(['/usr/bin/gmake', 0])
expect(Gitlab::Popen).to receive(:popen)
.with(%w[gmake clean all], nil, { "BUNDLE_GEMFILE" => nil, "RUBYOPT" => nil })
.with(%w[gmake clean all])
.and_return(['ok', 0])
subject
@ -78,7 +78,7 @@ RSpec.describe 'gitlab:gitaly namespace rake task', :silence_stdout do
.with(%w[which gmake])
.and_return(['/usr/bin/gmake', 0])
expect(Gitlab::Popen).to receive(:popen)
.with(%w[gmake clean all], nil, { "BUNDLE_GEMFILE" => nil, "RUBYOPT" => nil })
.with(%w[gmake clean all])
.and_return(['output', 1])
expect { subject }.to raise_error /Gitaly failed to compile: output/
@ -95,27 +95,11 @@ RSpec.describe 'gitlab:gitaly namespace rake task', :silence_stdout do
it 'calls make in the gitaly directory' do
expect(Gitlab::Popen).to receive(:popen)
.with(%w[make clean all], nil, { "BUNDLE_GEMFILE" => nil, "RUBYOPT" => nil })
.with(%w[make clean all])
.and_return(['output', 0])
subject
end
context 'when Rails.env is test' do
let(:command) { %w[make clean all] }
before do
stub_rails_env('test')
end
it 'calls make in the gitaly directory with BUNDLE_DEPLOYMENT and GEM_HOME variables' do
expect(Gitlab::Popen).to receive(:popen)
.with(command, nil, { "BUNDLE_GEMFILE" => nil, "RUBYOPT" => nil, "BUNDLE_DEPLOYMENT" => 'false', "GEM_HOME" => Bundler.bundle_path.to_s })
.and_return(['/usr/bin/gmake', 0])
subject
end
end
end
end
end