diff options
10 files changed, 45 insertions, 48 deletions
diff --git a/doc/integration/sourcegraph.md b/doc/integration/sourcegraph.md index fc45b270d80..5e7cbdfbac3 100644 --- a/doc/integration/sourcegraph.md +++ b/doc/integration/sourcegraph.md @@ -4,7 +4,7 @@ type: reference, how-to # Sourcegraph integration -> [Introduced](https://gitlab.com/gitlab-org/gitlab/merge_requests/16556) in GitLab 12.5. Please note that this integration is [behind a feature flag](#enable-the-sourcegraph-feature-flag). +> [Introduced](https://gitlab.com/gitlab-org/gitlab/merge_requests/16556) in GitLab 12.5. Please note that this integration is in BETA and [behind a feature flag](#enable-the-sourcegraph-feature-flag). [Sourcegraph](https://sourcegraph.com) provides code intelligence features, natively integrated into the GitLab UI. @@ -12,6 +12,9 @@ For GitLab.com users, see [Sourcegraph for GitLab.com](#sourcegraph-for-gitlabco ![Sourcegraph demo](img/sourcegraph_demo_v12_5.png) +<i class="fa fa-youtube-play youtube" aria-hidden="true"></i> +For an overview, watch the video [Sourcegraph's new GitLab native integration](https://www.youtube.com/watch?v=LjVxkt4_sEA). + NOTE: **Note:** This feature requires user opt-in. After Sourcegraph has been enabled for your GitLab instance, you can choose to enable Sourcegraph [through your user preferences](#enable-sourcegraph-in-user-preferences). @@ -103,12 +106,18 @@ When visiting one of these views, you can now hover over a code reference to see ## Sourcegraph for GitLab.com -Sourcegraph powered code intelligence will be incrementally rolled out on GitLab.com. It will eventually be -available for all public projects, but for now, it is only available for some specific [`gitlab-org` projects](https://gitlab.com/gitlab-org/). +Sourcegraph powered code intelligence will be incrementally rolled out on GitLab.com. +It will eventually become available for all public projects, but for now, it is only +available for some specific [`gitlab-org` projects](https://gitlab.com/gitlab-org/). +This means that you can see it working and use it to dig into the code of these projects, +but you cannot use it on your own project on GitLab.com yet. -If you have a private or internal project and would like integrated code intelligence, please consider +If you would like to use it in your own projects as of GitLab 12.5, you can do so by setting up a self-managed GitLab instance. +Follow the epic [&2201](https://gitlab.com/groups/gitlab-org/-/epics/2201) for +updates. + ## Sourcegraph and Privacy From Sourcegraph's [extension documentation](https://docs.sourcegraph.com/integration/browser_extension#privacy) which is the diff --git a/qa/qa/flow/login.rb b/qa/qa/flow/login.rb index 9a28ad57e0c..d84dfaa9377 100644 --- a/qa/qa/flow/login.rb +++ b/qa/qa/flow/login.rb @@ -29,6 +29,10 @@ module QA def sign_in_as_admin sign_in(as: Runtime::User.admin) end + + def sign_in_unless_signed_in(as: nil) + sign_in(as: as) unless Page::Main::Menu.perform(&:signed_in?) + end end end end diff --git a/qa/qa/resource/group.rb b/qa/qa/resource/group.rb index e11bd5728fb..7511396251d 100644 --- a/qa/qa/resource/group.rb +++ b/qa/qa/resource/group.rb @@ -8,7 +8,10 @@ module QA attr_accessor :path, :description attribute :sandbox do - Sandbox.fabricate! + Sandbox.fabricate_via_api! do |sandbox| + sandbox.user = user + sandbox.api_client = api_client + end end attribute :id diff --git a/qa/qa/resource/merge_request.rb b/qa/qa/resource/merge_request.rb index fe7eeeed37a..1a6de8de456 100644 --- a/qa/qa/resource/merge_request.rb +++ b/qa/qa/resource/merge_request.rb @@ -26,8 +26,6 @@ module QA end attribute :target do - project.visit! - Repository::ProjectPush.fabricate! do |resource| resource.project = project resource.branch_name = 'master' diff --git a/qa/qa/runtime/api/client.rb b/qa/qa/runtime/api/client.rb index 1b0adbc9053..83fbb8f15d2 100644 --- a/qa/qa/runtime/api/client.rb +++ b/qa/qa/runtime/api/client.rb @@ -46,19 +46,24 @@ module QA end def create_personal_access_token - Page::Main::Menu.perform(&:sign_out) if @is_new_session && Page::Main::Menu.perform { |p| p.has_personal_area?(wait: 0) } + signed_in_initially = Page::Main::Menu.perform(&:signed_in?) - unless Page::Main::Menu.perform { |p| p.has_personal_area?(wait: 0) } - Runtime::Browser.visit(@address, Page::Main::Login) - Page::Main::Login.perform { |login| login.sign_in_using_credentials(user: @user) } - end + Page::Main::Menu.perform(&:sign_out) if @is_new_session && signed_in_initially + + Flow::Login.sign_in_unless_signed_in(as: @user) token = Resource::PersonalAccessToken.fabricate!.access_token # If this is a new session, that tests that follow could fail if they - # try to sign in without starting a new session + # try to sign in without starting a new session. + # Also, if the browser wasn't already signed in, leaving it + # signed in could cause tests to fail when they try to sign + # in again. For example, that would happen if a test has a + # before(:context) block that fabricates via the API, and + # it's the first test to run so it creates an access token + # # Sign out so the tests can successfully sign in - Page::Main::Menu.perform(&:sign_out) if @is_new_session + Page::Main::Menu.perform(&:sign_out) if @is_new_session || !signed_in_initially token end diff --git a/qa/qa/specs/features/browser_ui/3_create/merge_request/view_merge_request_diff_patch_spec.rb b/qa/qa/specs/features/browser_ui/3_create/merge_request/view_merge_request_diff_patch_spec.rb index 891cef6c420..0eaec61b2fa 100644 --- a/qa/qa/specs/features/browser_ui/3_create/merge_request/view_merge_request_diff_patch_spec.rb +++ b/qa/qa/specs/features/browser_ui/3_create/merge_request/view_merge_request_diff_patch_spec.rb @@ -4,9 +4,6 @@ module QA context 'Create' do describe 'Download merge request patch and diff' do before(:context) do - Runtime::Browser.visit(:gitlab, Page::Main::Login) - Page::Main::Login.perform(&:sign_in_using_credentials) - project = Resource::Project.fabricate_via_api! do |project| project.name = 'project' end @@ -19,6 +16,8 @@ module QA end it 'views the merge request email patches' do + Flow::Login.sign_in + @merge_request.visit! Page::MergeRequest::Show.perform(&:view_email_patches) @@ -28,6 +27,8 @@ module QA end it 'views the merge request plain diff' do + Flow::Login.sign_in + @merge_request.visit! Page::MergeRequest::Show.perform(&:view_plain_diff) diff --git a/qa/qa/specs/features/browser_ui/3_create/repository/add_file_template_spec.rb b/qa/qa/specs/features/browser_ui/3_create/repository/add_file_template_spec.rb index a0fe957f97e..d2fd1d743fb 100644 --- a/qa/qa/specs/features/browser_ui/3_create/repository/add_file_template_spec.rb +++ b/qa/qa/specs/features/browser_ui/3_create/repository/add_file_template_spec.rb @@ -6,23 +6,12 @@ module QA describe 'File templates' do include Runtime::Fixtures - def login - unless Page::Main::Menu.perform(&:signed_in?) - Runtime::Browser.visit(:gitlab, Page::Main::Login) - Page::Main::Login.perform(&:sign_in_using_credentials) - end - end - before(:all) do - login - - @project = Resource::Project.fabricate! do |project| + @project = Resource::Project.fabricate_via_api! do |project| project.name = 'file-template-project' project.description = 'Add file templates via the Files view' project.initialize_with_readme = true end - - Page::Main::Menu.perform(&:sign_out) end templates = [ @@ -56,7 +45,8 @@ module QA it "user adds #{template[:file_name]} via file template #{template[:name]}" do content = fetch_template_from_api(template[:api_path], template[:api_key]) - login + Flow::Login.sign_in + @project.visit! Page::Project::Show.perform(&:create_new_file!) diff --git a/qa/qa/specs/features/browser_ui/3_create/repository/clone_spec.rb b/qa/qa/specs/features/browser_ui/3_create/repository/clone_spec.rb index f2584f55a60..0650c8395c7 100644 --- a/qa/qa/specs/features/browser_ui/3_create/repository/clone_spec.rb +++ b/qa/qa/specs/features/browser_ui/3_create/repository/clone_spec.rb @@ -4,14 +4,10 @@ module QA context 'Create' do describe 'Git clone over HTTP', :ldap_no_tls do before(:all) do - Runtime::Browser.visit(:gitlab, Page::Main::Login) - Page::Main::Login.perform(&:sign_in_using_credentials) - - @project = Resource::Project.fabricate! do |scenario| + @project = Resource::Project.fabricate_via_api! do |scenario| scenario.name = 'project-with-code' scenario.description = 'project for git clone tests' end - @project.visit! Git::Repository.perform do |repository| repository.uri = @project.repository_http_location.uri diff --git a/qa/qa/specs/features/browser_ui/3_create/repository/user_views_commit_diff_patch_spec.rb b/qa/qa/specs/features/browser_ui/3_create/repository/user_views_commit_diff_patch_spec.rb index 5459104ec84..aee62bacfa8 100644 --- a/qa/qa/specs/features/browser_ui/3_create/repository/user_views_commit_diff_patch_spec.rb +++ b/qa/qa/specs/features/browser_ui/3_create/repository/user_views_commit_diff_patch_spec.rb @@ -31,8 +31,7 @@ module QA end def view_commit - Runtime::Browser.visit(:gitlab, Page::Main::Login) - Page::Main::Login.perform(&:sign_in_using_credentials) + Flow::Login.sign_in @project.visit! Page::Project::Show.perform do |show| diff --git a/qa/qa/specs/features/browser_ui/3_create/web_ide/add_file_template_spec.rb b/qa/qa/specs/features/browser_ui/3_create/web_ide/add_file_template_spec.rb index 957674353d6..318adc3c272 100644 --- a/qa/qa/specs/features/browser_ui/3_create/web_ide/add_file_template_spec.rb +++ b/qa/qa/specs/features/browser_ui/3_create/web_ide/add_file_template_spec.rb @@ -6,21 +6,12 @@ module QA describe 'Web IDE file templates' do include Runtime::Fixtures - def login - Runtime::Browser.visit(:gitlab, Page::Main::Login) - Page::Main::Login.perform(&:sign_in_using_credentials) - end - before(:all) do - login - - @project = Resource::Project.fabricate! do |project| + @project = Resource::Project.fabricate_via_api! do |project| project.name = 'file-template-project' project.description = 'Add file templates via the Web IDE' project.initialize_with_readme = true end - - Page::Main::Menu.perform(&:sign_out) end templates = [ @@ -54,7 +45,8 @@ module QA it "user adds #{template[:file_name]} via file template #{template[:name]}" do content = fetch_template_from_api(template[:api_path], template[:api_key]) - login + Flow::Login.sign_in + @project.visit! Page::Project::Show.perform(&:open_web_ide!) |