diff options
23 files changed, 131 insertions, 132 deletions
diff --git a/GITALY_SERVER_VERSION b/GITALY_SERVER_VERSION index 461daa216e2..7242eabf9b0 100644 --- a/GITALY_SERVER_VERSION +++ b/GITALY_SERVER_VERSION @@ -1 +1 @@ -ef91aecceeb69d7b7d7e7f8fb8b26e4dfcf1c266 +26780b6ce4906b1efd90020ab40560bff5cbec67 diff --git a/app/finders/users_finder.rb b/app/finders/users_finder.rb index 57dbeca5c51..13c4aae5b25 100644 --- a/app/finders/users_finder.rb +++ b/app/finders/users_finder.rb @@ -80,15 +80,11 @@ class UsersFinder def by_search(users) return users unless params[:search].present? - if Feature.enabled?(:autocomplete_users_use_search_service) - users.search( - params[:search], - with_private_emails: current_user&.can_admin_all_resources?, - use_minimum_char_limit: params[:use_minimum_char_limit] - ) - else - users.search(params[:search], with_private_emails: current_user&.can_admin_all_resources?) - end + users.search( + params[:search], + with_private_emails: current_user&.can_admin_all_resources?, + use_minimum_char_limit: params[:use_minimum_char_limit] + ) end def by_blocked(users) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 7f1c28de8a7..3aca413ed45 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -274,15 +274,7 @@ module ApplicationHelper end def stylesheet_link_tag_defer(path) - if startup_css_enabled? - stylesheet_link_tag(path, media: "print", crossorigin: ActionController::Base.asset_host ? 'anonymous' : nil) - else - stylesheet_link_tag(path, media: "all", crossorigin: ActionController::Base.asset_host ? 'anonymous' : nil) - end - end - - def startup_css_enabled? - !Feature.enabled?(:remove_startup_css) && !params.has_key?(:no_startup_css) + stylesheet_link_tag(path, media: "all", crossorigin: ActionController::Base.asset_host ? 'anonymous' : nil) end def sign_in_with_redirect? diff --git a/app/helpers/search_helper.rb b/app/helpers/search_helper.rb index 8fbbd18c9ae..64a5c28de86 100644 --- a/app/helpers/search_helper.rb +++ b/app/helpers/search_helper.rb @@ -373,17 +373,10 @@ module SearchHelper def users_autocomplete(term, limit = 5) return [] unless current_user && Ability.allowed?(current_user, :read_users_list) - users = if Feature.enabled?(:autocomplete_users_use_search_service) - ::SearchService - .new(current_user, { scope: 'users', per_page: limit, search: term }) - .search_objects - else - is_current_user_admin = current_user.can_admin_all_resources? - scope = is_current_user_admin ? User.all : User.without_forbidden_states - scope.search(term, with_private_emails: is_current_user_admin, use_minimum_char_limit: false).limit(limit) - end - - users.map do |user| + ::SearchService + .new(current_user, { scope: 'users', per_page: limit, search: term }) + .search_objects + .map do |user| { category: "Users", id: user.id, diff --git a/app/views/layouts/_head.html.haml b/app/views/layouts/_head.html.haml index d3a4c5c5ba8..69a36e6c2e3 100644 --- a/app/views/layouts/_head.html.haml +++ b/app/views/layouts/_head.html.haml @@ -20,12 +20,9 @@ = favicon_link_tag favicon, id: 'favicon', data: { original_href: favicon }, type: 'image/png' - - if startup_css_enabled? - = render 'layouts/startup_css', { startup_filename: local_assigns.fetch(:startup_filename, nil) } - - else - - diffs_colors = user_diffs_colors - = stylesheet_link_tag "themes/#{user_application_theme_css_filename}" if user_application_theme_css_filename - = render 'layouts/diffs_colors_css', diffs_colors if diffs_colors.present? || request.path == profile_preferences_path + - diffs_colors = user_diffs_colors + = stylesheet_link_tag "themes/#{user_application_theme_css_filename}" if user_application_theme_css_filename + = render 'layouts/diffs_colors_css', diffs_colors if diffs_colors.present? || request.path == profile_preferences_path - if user_application_theme == 'gl-dark' %meta{ name: 'color-scheme', content: 'dark light' } @@ -43,9 +40,6 @@ = stylesheet_link_tag_defer "highlight/themes/#{user_color_scheme}" - - if startup_css_enabled? - = render 'layouts/startup_css_activation' - = stylesheet_link_tag 'performance_bar' if performance_bar_enabled? = render 'layouts/snowplow' diff --git a/app/views/layouts/_startup_css.haml b/app/views/layouts/_startup_css.haml deleted file mode 100644 index 64a86cf319e..00000000000 --- a/app/views/layouts/_startup_css.haml +++ /dev/null @@ -1,9 +0,0 @@ -- startup_filename_default = user_application_theme == 'gl-dark' ? 'dark' : 'general' -- startup_filename = local_assigns.fetch(:startup_filename, nil) || startup_filename_default -- diffs_colors = user_diffs_colors - -%style - = Rails.application.assets_manifest.find_sources("themes/#{user_application_theme_css_filename}.css").first.to_s.html_safe if user_application_theme_css_filename - = Rails.application.assets_manifest.find_sources("startup/startup-#{startup_filename}.css").first.to_s.html_safe - -= render 'layouts/diffs_colors_css', diffs_colors if diffs_colors.present? || request.path == profile_preferences_path diff --git a/app/views/layouts/_startup_css_activation.haml b/app/views/layouts/_startup_css_activation.haml deleted file mode 100644 index 7dfb9cd1530..00000000000 --- a/app/views/layouts/_startup_css_activation.haml +++ /dev/null @@ -1,7 +0,0 @@ -= javascript_tag do - :plain - document.querySelectorAll('link[media="print"]').forEach(linkTag => { - linkTag.setAttribute('data-startupcss', 'loading'); - const startupLinkLoadedEvent = new CustomEvent('CSSStartupLinkLoaded'); - linkTag.addEventListener('load',function(){this.media='all';this.setAttribute('data-startupcss', 'loaded');document.dispatchEvent(startupLinkLoadedEvent);},{once: true}); - }) diff --git a/config/feature_flags/development/autocomplete_users_use_search_service.yml b/config/feature_flags/development/autocomplete_users_use_search_service.yml deleted file mode 100644 index 1fe9b295076..00000000000 --- a/config/feature_flags/development/autocomplete_users_use_search_service.yml +++ /dev/null @@ -1,8 +0,0 @@ ---- -name: autocomplete_users_use_search_service -introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/122289 -rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/413972 -milestone: '16.1' -type: development -group: group::global search -default_enabled: false diff --git a/config/feature_flags/development/remove_startup_css.yml b/config/feature_flags/development/remove_startup_css.yml deleted file mode 100644 index 91e78682755..00000000000 --- a/config/feature_flags/development/remove_startup_css.yml +++ /dev/null @@ -1,8 +0,0 @@ ---- -name: remove_startup_css -introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/117495 -rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/407140 -milestone: '15.11' -type: development -group: group::project management -default_enabled: false diff --git a/db/docs/external_pull_requests.yml b/db/docs/external_pull_requests.yml index e3777ae67ba..8a737959bd5 100644 --- a/db/docs/external_pull_requests.yml +++ b/db/docs/external_pull_requests.yml @@ -1,6 +1,7 @@ --- table_name: external_pull_requests classes: +- Ci::ExternalPullRequest - ExternalPullRequest feature_categories: - continuous_integration diff --git a/db/post_migrate/20230626070723_drop_unused_sent_notification_columns.rb b/db/post_migrate/20230626070723_drop_unused_sent_notification_columns.rb new file mode 100644 index 00000000000..82a125c1ff5 --- /dev/null +++ b/db/post_migrate/20230626070723_drop_unused_sent_notification_columns.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class DropUnusedSentNotificationColumns < Gitlab::Database::Migration[2.1] + enable_lock_retries! + + def up + remove_column :sent_notifications, :line_code + remove_column :sent_notifications, :note_type + remove_column :sent_notifications, :position + end + + def down + add_column :sent_notifications, :line_code, :string + add_column :sent_notifications, :note_type, :string + add_column :sent_notifications, :position, :text + end +end diff --git a/db/schema_migrations/20230626070723 b/db/schema_migrations/20230626070723 new file mode 100644 index 00000000000..c0528c8a9b5 --- /dev/null +++ b/db/schema_migrations/20230626070723 @@ -0,0 +1 @@ +3154c7f63689ab430342229b526380cdc02ab9e11f855cf914cb382ba2850ab1
\ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index 5cff7ab4337..09c5941f1b5 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -22602,9 +22602,6 @@ CREATE TABLE sent_notifications ( recipient_id integer, commit_id character varying, reply_key character varying NOT NULL, - line_code character varying, - note_type character varying, - "position" text, in_reply_to_discussion_id character varying, id bigint NOT NULL ); diff --git a/doc/api/environments.md b/doc/api/environments.md index d2335149301..87f99bc9034 100644 --- a/doc/api/environments.md +++ b/doc/api/environments.md @@ -7,6 +7,8 @@ type: concepts, howto # Environments API **(FREE)** +> Support for [GitLab CI/CD job token](../ci/jobs/ci_job_token.md) authentication [introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/414549) in GitLab 16.2. + ## List environments Get all environments for a given project. diff --git a/doc/ci/jobs/ci_job_token.md b/doc/ci/jobs/ci_job_token.md index a67cd2de4e8..c2fe3071b52 100644 --- a/doc/ci/jobs/ci_job_token.md +++ b/doc/ci/jobs/ci_job_token.md @@ -25,6 +25,7 @@ You can use a GitLab CI/CD job token to authenticate with specific API endpoints - [Releases](../../api/releases/index.md) and [Release links](../../api/releases/links.md). - [Terraform plan](../../user/infrastructure/index.md). - [Deployments](../../api/deployments.md). +- [Environments](../../api/environments.md). The token has the same permissions to access the API as the user that caused the job to run. A user can cause a job to run by taking action like pushing a commit, diff --git a/doc/ci/testing/unit_test_report_examples.md b/doc/ci/testing/unit_test_report_examples.md index 1b1600b3d99..8527d0b712d 100644 --- a/doc/ci/testing/unit_test_report_examples.md +++ b/doc/ci/testing/unit_test_report_examples.md @@ -295,3 +295,23 @@ run unittests: junit: - report.xml ``` + +## Helm + +This example uses [Helm Unittest](https://github.com/helm-unittest/helm-unittest#docker-usage) plugin, with the `-t junit` flag to format the output to a JUnit report in XML format. + +```yaml +helm: + image: helmunittest/helm-unittest:latest + stage: test + script: + - '-t JUnit -o report.xml -f tests/*[._]test.yaml .' + artifacts: + reports: + junit: report.xml +``` + +The `-f tests/*[._]test.yaml` flag configures `helm-unittest` to look for files in the `tests/` directory that end in either: + +- `.test.yaml` +- `_test.yaml` diff --git a/lib/api/environments.rb b/lib/api/environments.rb index bb261079d2a..b94391359ed 100644 --- a/lib/api/environments.rb +++ b/lib/api/environments.rb @@ -38,6 +38,7 @@ module API desc: 'List all environments that match a specific state. Accepted values: `available`, `stopping`, or `stopped`. If no state value given, returns all environments' mutually_exclusive :name, :search, message: 'cannot be used together' end + route_setting :authentication, job_token_allowed: true get ':id/environments' do authorize! :read_environment, user_project @@ -66,6 +67,7 @@ module API optional :slug, absence: { message: "is automatically generated and cannot be changed" }, documentation: { hidden: true } optional :tier, type: String, values: Environment.tiers.keys, desc: 'The tier of the new environment. Allowed values are `production`, `staging`, `testing`, `development`, and `other`' end + route_setting :authentication, job_token_allowed: true post ':id/environments' do authorize! :create_environment, user_project @@ -94,6 +96,7 @@ module API optional :slug, absence: { message: "is automatically generated and cannot be changed" }, documentation: { hidden: true } optional :tier, type: String, values: Environment.tiers.keys, desc: 'The tier of the new environment. Allowed values are `production`, `staging`, `testing`, `development`, and `other`' end + route_setting :authentication, job_token_allowed: true put ':id/environments/:environment_id' do authorize! :update_environment, user_project @@ -126,6 +129,7 @@ module API optional :limit, type: Integer, desc: "Maximum number of environments to delete. Defaults to 100", default: 100, values: 1..1000 optional :dry_run, type: Boolean, desc: "Defaults to true for safety reasons. It performs a dry run where no actual deletion will be performed. Set to false to actually delete the environment", default: true end + route_setting :authentication, job_token_allowed: true delete ":id/environments/review_apps" do authorize! :read_environment, user_project @@ -156,6 +160,7 @@ module API params do requires :environment_id, type: Integer, desc: 'The ID of the environment' end + route_setting :authentication, job_token_allowed: true delete ':id/environments/:environment_id' do authorize! :read_environment, user_project @@ -178,6 +183,7 @@ module API requires :environment_id, type: Integer, desc: 'The ID of the environment' optional :force, type: Boolean, default: false, desc: 'Force environment to stop without executing `on_stop` actions' end + route_setting :authentication, job_token_allowed: true post ':id/environments/:environment_id/stop' do authorize! :read_environment, user_project @@ -202,6 +208,7 @@ module API type: DateTime, desc: 'Stop all environments that were last modified or deployed to before this date.' end + route_setting :authentication, job_token_allowed: true post ':id/environments/stop_stale' do authorize! :stop_environment, user_project @@ -229,6 +236,7 @@ module API params do requires :environment_id, type: Integer, desc: 'The ID of the environment' end + route_setting :authentication, job_token_allowed: true get ':id/environments/:environment_id' do authorize! :read_environment, user_project diff --git a/lib/gitlab/search_results.rb b/lib/gitlab/search_results.rb index a733dca6a56..4fedc450f9b 100644 --- a/lib/gitlab/search_results.rb +++ b/lib/gitlab/search_results.rb @@ -107,11 +107,7 @@ module Gitlab def users return User.none unless Ability.allowed?(current_user, :read_users_list) - if Feature.enabled?(:autocomplete_users_use_search_service) - UsersFinder.new(current_user, { search: query, use_minimum_char_limit: false }).execute - else - UsersFinder.new(current_user, search: query).execute - end + UsersFinder.new(current_user, { search: query, use_minimum_char_limit: false }).execute end # highlighting is only performed by Elasticsearch backed results diff --git a/spec/finders/users_finder_spec.rb b/spec/finders/users_finder_spec.rb index e0a9237a79b..c931de92d1c 100644 --- a/spec/finders/users_finder_spec.rb +++ b/spec/finders/users_finder_spec.rb @@ -70,19 +70,6 @@ RSpec.describe UsersFinder do expect(users).to be_empty end - - context 'when autocomplete_users_use_search_service feature flag is disabled' do - before do - stub_feature_flags(autocomplete_users_use_search_service: false) - end - - it 'does not pass use_minimum_char_limit from params' do - search_term = normal_user.username[..1] - expect(User).to receive(:search).with(search_term, with_private_emails: anything).once.and_call_original - - described_class.new(user, { search: search_term, use_minimum_char_limit: false }).execute - end - end end it 'filters by external users' do diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index 8ff36280dbc..f82b4146643 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -720,21 +720,7 @@ RSpec.describe ApplicationHelper do end describe 'stylesheet_link_tag_defer' do - it 'uses print stylesheet when feature flag disabled' do - stub_feature_flags(remove_startup_css: false) - - expect(helper.stylesheet_link_tag_defer('test')).to eq( '<link rel="stylesheet" href="/stylesheets/test.css" media="print" />') - end - - it 'uses regular stylesheet when feature flag enabled' do - stub_feature_flags(remove_startup_css: true) - - expect(helper.stylesheet_link_tag_defer('test')).to eq( '<link rel="stylesheet" href="/stylesheets/test.css" media="all" />') - end - - it 'uses regular stylesheet when no_startup_css param present' do - allow(helper.controller).to receive(:params).and_return({ no_startup_css: '' }) - + it 'uses media="all" in stylesheet' do expect(helper.stylesheet_link_tag_defer('test')).to eq( '<link rel="stylesheet" href="/stylesheets/test.css" media="all" />') end end diff --git a/spec/helpers/search_helper_spec.rb b/spec/helpers/search_helper_spec.rb index b2606fcfae1..5c55c1d604a 100644 --- a/spec/helpers/search_helper_spec.rb +++ b/spec/helpers/search_helper_spec.rb @@ -153,15 +153,7 @@ RSpec.describe SearchHelper, feature_category: :global_search do end end - [true, false].each do |enabled| - context "with feature flag autcomplete_users_use_search_service #{enabled}" do - before do - stub_feature_flags(autocomplete_users_use_search_service: enabled) - end - - include_examples 'for users' - end - end + include_examples 'for users' it "includes the required project attrs" do project = create(:project, namespace: create(:namespace, owner: user)) diff --git a/spec/lib/gitlab/search_results_spec.rb b/spec/lib/gitlab/search_results_spec.rb index ce54f853e1b..662eab11cc0 100644 --- a/spec/lib/gitlab/search_results_spec.rb +++ b/spec/lib/gitlab/search_results_spec.rb @@ -302,18 +302,6 @@ RSpec.describe Gitlab::SearchResults, feature_category: :global_search do results.objects('users') end - - context 'when autocomplete_users_use_search_service feature flag is disabled' do - before do - stub_feature_flags(autocomplete_users_use_search_service: false) - end - - it 'calls the UsersFinder without use_minimum_char_limit' do - expect(UsersFinder).to receive(:new).with(user, search: 'foo').and_call_original - - results.objects('users') - end - end end end diff --git a/spec/requests/api/environments_spec.rb b/spec/requests/api/environments_spec.rb index 9a435b3bce9..498e030da0b 100644 --- a/spec/requests/api/environments_spec.rb +++ b/spec/requests/api/environments_spec.rb @@ -31,6 +31,14 @@ RSpec.describe API::Environments, feature_category: :continuous_delivery do expect(json_response.first).not_to have_key('last_deployment') end + it 'returns 200 HTTP status when using JOB-TOKEN auth' do + job = create(:ci_build, :running, project: project, user: user) + + get api("/projects/#{project.id}/environments"), params: { job_token: job.token } + + expect(response).to have_gitlab_http_status(:ok) + end + context 'when filtering' do let_it_be(:stopped_environment) { create(:environment, :stopped, project: project) } @@ -132,6 +140,14 @@ RSpec.describe API::Environments, feature_category: :continuous_delivery do expect(json_response['external']).to be nil end + it 'returns 200 HTTP status when using JOB-TOKEN auth' do + job = create(:ci_build, :running, project: project, user: user) + + post api("/projects/#{project.id}/environments"), params: { name: "mepmep", job_token: job.token } + + expect(response).to have_gitlab_http_status(:created) + end + it 'requires name to be passed' do post api("/projects/#{project.id}/environments", user), params: { external_url: 'test.gitlab.com' } @@ -173,6 +189,15 @@ RSpec.describe API::Environments, feature_category: :continuous_delivery do expect(response).to have_gitlab_http_status(:ok) end + it 'returns 200 HTTP status when using JOB-TOKEN auth' do + job = create(:ci_build, :running, project: project, user: user) + + post api("/projects/#{project.id}/environments/stop_stale"), + params: { before: 1.week.ago.to_date.to_s, job_token: job.token } + + expect(response).to have_gitlab_http_status(:ok) + end + it 'returns a 400 for bad input date' do post api("/projects/#{project.id}/environments/stop_stale", user), params: { before: 1.day.ago.to_date.to_s } @@ -229,6 +254,15 @@ RSpec.describe API::Environments, feature_category: :continuous_delivery do expect(json_response['tier']).to eq('production') end + it 'returns 200 HTTP status when using JOB-TOKEN auth' do + job = create(:ci_build, :running, project: project, user: user) + + put api("/projects/#{project.id}/environments/#{environment.id}"), + params: { tier: 'production', job_token: job.token } + + expect(response).to have_gitlab_http_status(:ok) + end + it "won't allow slug to be changed" do slug = environment.slug api_url = api("/projects/#{project.id}/environments/#{environment.id}", user) @@ -261,6 +295,17 @@ RSpec.describe API::Environments, feature_category: :continuous_delivery do expect(response).to have_gitlab_http_status(:no_content) end + it 'returns 204 HTTP status when using JOB-TOKEN auth' do + environment.stop + + job = create(:ci_build, :running, project: project, user: user) + + delete api("/projects/#{project.id}/environments/#{environment.id}"), + params: { job_token: job.token } + + expect(response).to have_gitlab_http_status(:no_content) + end + it 'returns a 404 for non existing id' do delete api("/projects/#{project.id}/environments/#{non_existing_record_id}", user) @@ -291,17 +336,23 @@ RSpec.describe API::Environments, feature_category: :continuous_delivery do context 'with a stoppable environment' do before do environment.update!(state: :available) - - post api("/projects/#{project.id}/environments/#{environment.id}/stop", user) end it 'returns a 200' do + post api("/projects/#{project.id}/environments/#{environment.id}/stop", user) + expect(response).to have_gitlab_http_status(:ok) expect(response).to match_response_schema('public_api/v4/environment') + expect(environment.reload).to be_stopped end - it 'actually stops the environment' do - expect(environment.reload).to be_stopped + it 'returns 200 HTTP status when using JOB-TOKEN auth' do + job = create(:ci_build, :running, project: project, user: user) + + post api("/projects/#{project.id}/environments/#{environment.id}/stop"), + params: { job_token: job.token } + + expect(response).to have_gitlab_http_status(:ok) end end @@ -333,6 +384,15 @@ RSpec.describe API::Environments, feature_category: :continuous_delivery do expect(response).to match_response_schema('public_api/v4/environment') expect(json_response['last_deployment']).to be_present end + + it 'returns 200 HTTP status when using JOB-TOKEN auth' do + job = create(:ci_build, :running, project: project, user: user) + + get api("/projects/#{project.id}/environments/#{environment.id}"), + params: { job_token: job.token } + + expect(response).to have_gitlab_http_status(:ok) + end end context 'as non member' do |