diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-12-21 21:07:13 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-12-21 21:07:13 +0300 |
commit | d380b256b976811e54dc4eb7c9ba3ecc5a9ab5be (patch) | |
tree | 08e2636afd8c045961c04b05361ad4880c767aa2 | |
parent | d4aa95428e9ae63a476196bc8c1193d3de253530 (diff) |
Add latest changes from gitlab-org/gitlab@master
70 files changed, 723 insertions, 187 deletions
diff --git a/.gitlab/merge_request_templates/New Version of gitlab-styles.md b/.gitlab/merge_request_templates/New Version of gitlab-styles.md index e6cde691e19..22062616900 100644 --- a/.gitlab/merge_request_templates/New Version of gitlab-styles.md +++ b/.gitlab/merge_request_templates/New Version of gitlab-styles.md @@ -1,10 +1,11 @@ -<!-- Title suggestion: Upgrade `gilab-styles` to <VERSION X.Y.Z> - dry-run --> +<!-- Title suggestion: Upgrade `gitlab-styles` to <VERSION X.Y.Z> - dry-run --> ## What does this MR do and why? Validating upcoming release of `gitlab-styles` <VERSION X.Y.Z>. See <LINK TO RELEASE MR>. This MR can be reused to upgrade `gitlab-styles` in this project after a new version of `gitlab-styles` is released. + ### Checklist - [ ] Verify upcoming release of `gitlab-styles` @@ -13,8 +14,8 @@ This MR can be reused to upgrade `gitlab-styles` in this project after a new ver - [ ] Update [bundler's checksum file](https://docs.gitlab.com/ee/development/gemfile.html#updating-the-checksum-file) via `bundle exec bundler-checksum init` - [ ] `rubocop` job - [ ] Inspect any warnings/errors - - [ ] (Optional) [Generate TODOs](https://docs.gitlab.com/ee/development/contributing/style_guides.html#resolving-rubocop-exceptions) for pending offenses - - [ ] Put :new: cop rules (or if configuration is changed) in "grace period". See [docs](https://docs.gitlab.com/ee/development/contributing/style_guides.html#enabling-a-new-cop). + - [ ] (Optional) [Generate TODOs](https://docs.gitlab.com/ee/development/rubocop_development_guide.html#resolving-rubocop-exceptions) for pending offenses + - [ ] Put :new: cop rules (or if configuration is changed) in "grace period". See [docs](https://docs.gitlab.com/ee/development/rubocop_development_guide.html#enabling-a-new-cop). - [ ] (Optional) Remove any offenses for disabled cops - Use `grep --perl-regexp -o ":\d+\d+: \w: \[\S+\] ([\w/]+)" raw_job_output.log | awk '{print $4}' | sort | uniq -c` to get a list of cop rules with offenses. Where `raw_job_output.log` is the raw output of the `rubocop` job - [ ] Ignore offenses related to temporary changes in `Gemfile` diff --git a/GITALY_SERVER_VERSION b/GITALY_SERVER_VERSION index 7c0f335267c..3077eca8e9b 100644 --- a/GITALY_SERVER_VERSION +++ b/GITALY_SERVER_VERSION @@ -1 +1 @@ -50c8cb6e62396936c9e568e859dd717595281788 +0ec4abd0c0b834dd49144c0821e056baaf8fe025 diff --git a/app/assets/stylesheets/pages/projects.scss b/app/assets/stylesheets/pages/projects.scss index 15a32ea8ad3..5abd3e89cac 100644 --- a/app/assets/stylesheets/pages/projects.scss +++ b/app/assets/stylesheets/pages/projects.scss @@ -122,7 +122,7 @@ padding: 0; background: transparent; border: 0; - line-height: 34px; + line-height: $gl-line-height-32; margin: 0; a { diff --git a/app/models/event.rb b/app/models/event.rb index 2cee786912c..333841b1f90 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -84,6 +84,7 @@ class Event < ApplicationRecord scope :recent, -> { reorder(id: :desc) } scope :for_wiki_page, -> { where(target_type: 'WikiPage::Meta') } scope :for_design, -> { where(target_type: 'DesignManagement::Design') } + scope :for_issue, -> { where(target_type: ISSUE_TYPES) } scope :for_fingerprint, ->(fingerprint) do fingerprint.present? ? where(fingerprint: fingerprint) : none end diff --git a/app/models/members/member_role.rb b/app/models/members/member_role.rb index e9d7b1d3f80..36cbc97d049 100644 --- a/app/models/members/member_role.rb +++ b/app/models/members/member_role.rb @@ -11,6 +11,7 @@ class MemberRole < ApplicationRecord # rubocop:disable Gitlab/NamespacedClass validates :base_access_level, presence: true validate :belongs_to_top_level_namespace validate :validate_namespace_locked, on: :update + validate :attributes_locked_after_member_associated, on: :update validates_associated :members @@ -27,4 +28,11 @@ class MemberRole < ApplicationRecord # rubocop:disable Gitlab/NamespacedClass errors.add(:namespace, s_("MemberRole|can't be changed")) end + + def attributes_locked_after_member_associated + return unless members.present? + + errors.add(:base, s_("MemberRole|cannot be changed because it is already assigned to a user. "\ + "Please create a new Member Role instead")) + end end diff --git a/app/services/import/github/gists_import_service.rb b/app/services/import/github/gists_import_service.rb index df1bbe306e7..e57430916fa 100644 --- a/app/services/import/github/gists_import_service.rb +++ b/app/services/import/github/gists_import_service.rb @@ -3,16 +3,20 @@ module Import module Github class GistsImportService < ::BaseService - def initialize(user, params) + def initialize(user, client, params) @current_user = user @params = params + @client = client end def execute return error('Import already in progress', 422) if import_status.started? + check_user_token start_import success + rescue Octokit::Unauthorized + error('Access denied to the GitHub account.', 401) end private @@ -29,6 +33,10 @@ module Import Gitlab::GithubGistsImport::StartImportWorker.perform_async(current_user.id, encrypted_token) import_status.start! end + + def check_user_token + @client.octokit.user.present? + end end end end diff --git a/app/views/users/calendar_activities.html.haml b/app/views/users/calendar_activities.html.haml index 8da1aa09215..3571031fbfa 100644 --- a/app/views/users/calendar_activities.html.haml +++ b/app/views/users/calendar_activities.html.haml @@ -20,7 +20,7 @@ - if event.note? = link_to event.note_target.to_reference, event_note_target_url(event), class: 'has-tooltip', title: event.target_title - elsif event.target - = link_to event.target.to_reference, [event.project, event.target], class: 'has-tooltip', title: event.target_title + = link_to event.target.to_reference, Gitlab::UrlBuilder.build(event.target, only_path: true), class: 'has-tooltip', title: event.target_title = s_('UserProfile|at') %strong diff --git a/db/docs/ci_minutes_additional_packs.yml b/db/docs/ci_minutes_additional_packs.yml index 2be58f2cdde..be4b0a19621 100644 --- a/db/docs/ci_minutes_additional_packs.yml +++ b/db/docs/ci_minutes_additional_packs.yml @@ -3,7 +3,7 @@ table_name: ci_minutes_additional_packs classes: - Ci::Minutes::AdditionalPack feature_categories: -- utilization +- purchase description: TODO introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/62393 milestone: '14.0' diff --git a/db/docs/ci_namespace_mirrors.yml b/db/docs/ci_namespace_mirrors.yml index dd6b8eab821..1566f043a0e 100644 --- a/db/docs/ci_namespace_mirrors.yml +++ b/db/docs/ci_namespace_mirrors.yml @@ -3,7 +3,7 @@ table_name: ci_namespace_mirrors classes: - Ci::NamespaceMirror feature_categories: -- sharding +- pods description: Mirrors some data from the `main` database into the `ci` database so that we can join directly in a single query introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/75621 milestone: '14.6' diff --git a/db/docs/ci_project_mirrors.yml b/db/docs/ci_project_mirrors.yml index d6619880b20..8e332a10194 100644 --- a/db/docs/ci_project_mirrors.yml +++ b/db/docs/ci_project_mirrors.yml @@ -3,7 +3,7 @@ table_name: ci_project_mirrors classes: - Ci::ProjectMirror feature_categories: -- sharding +- pods description: Mirrors some data from the `main` database into the `ci` database so that we can join directly in a single query introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/75621 milestone: '14.6' diff --git a/db/docs/clusters_applications_cilium.yml b/db/docs/clusters_applications_cilium.yml index 8744ee73633..b28d674cef0 100644 --- a/db/docs/clusters_applications_cilium.yml +++ b/db/docs/clusters_applications_cilium.yml @@ -3,7 +3,7 @@ table_name: clusters_applications_cilium classes: - Clusters::Applications::Cilium feature_categories: -- container_network_security +- security_policy_management description: Information about installed instance of Cilium in the cluster introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/34601 milestone: '13.2' diff --git a/db/docs/elastic_reindexing_slices.yml b/db/docs/elastic_reindexing_slices.yml index b547c96a35d..84e42b16d57 100644 --- a/db/docs/elastic_reindexing_slices.yml +++ b/db/docs/elastic_reindexing_slices.yml @@ -3,7 +3,7 @@ table_name: elastic_reindexing_slices classes: - Elastic::ReindexingSlice feature_categories: -- memory +- application_performance description: TODO introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/55681 milestone: '13.12' diff --git a/db/docs/elasticsearch_indexed_projects.yml b/db/docs/elasticsearch_indexed_projects.yml index 78d8e2e58f7..17e2e116fdd 100644 --- a/db/docs/elasticsearch_indexed_projects.yml +++ b/db/docs/elasticsearch_indexed_projects.yml @@ -3,7 +3,7 @@ table_name: elasticsearch_indexed_projects classes: - ElasticsearchIndexedProject feature_categories: -- memory +- application_performance description: TODO introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/9861 milestone: '11.10' diff --git a/db/docs/historical_data.yml b/db/docs/historical_data.yml index 020cc33b25d..a7af9e04c14 100644 --- a/db/docs/historical_data.yml +++ b/db/docs/historical_data.yml @@ -3,8 +3,8 @@ table_name: historical_data classes: - HistoricalData feature_categories: -- utilization +- sm_provisioning description: TODO -introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/commit/85c04a8aa654d1b7f898e55a113e50521bacaaf2 +introduced_by_url: https://dev.gitlab.org/gitlab/gitlab-ee/-/merge_requests/390 milestone: '7.11' gitlab_schema: gitlab_main diff --git a/db/docs/loose_foreign_keys_deleted_records.yml b/db/docs/loose_foreign_keys_deleted_records.yml index aeaf241ef4a..8ce8d4e52b3 100644 --- a/db/docs/loose_foreign_keys_deleted_records.yml +++ b/db/docs/loose_foreign_keys_deleted_records.yml @@ -3,7 +3,7 @@ table_name: loose_foreign_keys_deleted_records classes: - LooseForeignKeys::DeletedRecord feature_categories: -- sharding +- pods description: Used by the loose foreign keys feature as a queue of parent records whose child records (via foreign keys) need to be deleted/nullified introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/70152 milestone: '14.3' diff --git a/db/docs/ml_candidate_metadata.yml b/db/docs/ml_candidate_metadata.yml index 485544f0f59..96396a6485e 100644 --- a/db/docs/ml_candidate_metadata.yml +++ b/db/docs/ml_candidate_metadata.yml @@ -4,7 +4,6 @@ classes: - Ml::CandidateMetadata feature_categories: - mlops - - incubation gitlab_schema: gitlab_main description: A Candidate Metadata record holds extra information about the candidate introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/104267 diff --git a/db/docs/ml_candidate_metrics.yml b/db/docs/ml_candidate_metrics.yml index 24489973dd5..4b6087c977e 100644 --- a/db/docs/ml_candidate_metrics.yml +++ b/db/docs/ml_candidate_metrics.yml @@ -4,7 +4,6 @@ classes: - Ml::CandidateMetric feature_categories: - mlops - - incubation description: Metrics recorded for a Machine Learning model candidate introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/95168 milestone: '15.4' diff --git a/db/docs/ml_candidate_params.yml b/db/docs/ml_candidate_params.yml index 25372de7c7f..2d0dc29795e 100644 --- a/db/docs/ml_candidate_params.yml +++ b/db/docs/ml_candidate_params.yml @@ -4,7 +4,6 @@ classes: - Ml::CandidateParams feature_categories: - mlops - - incubation description: Configuration parameters recorded for a Machine Learning model candidate introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/95168 milestone: '15.4' diff --git a/db/docs/ml_candidates.yml b/db/docs/ml_candidates.yml index c057eb45675..a79729e1548 100644 --- a/db/docs/ml_candidates.yml +++ b/db/docs/ml_candidates.yml @@ -4,7 +4,6 @@ classes: - Ml::Candidate feature_categories: - mlops - - incubation description: A Model Candidate is a record of the results on training a model on some configuration introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/95168 milestone: '15.4' diff --git a/db/docs/ml_experiment_metadata.yml b/db/docs/ml_experiment_metadata.yml index a77781cb601..812a33fe176 100644 --- a/db/docs/ml_experiment_metadata.yml +++ b/db/docs/ml_experiment_metadata.yml @@ -4,7 +4,6 @@ classes: - Ml::ExperimentMetadata feature_categories: - mlops - - incubation gitlab_schema: gitlab_main description: An Experiment Metadata record holds extra information about the experiment introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/104267 diff --git a/db/docs/ml_experiments.yml b/db/docs/ml_experiments.yml index bada30749d3..efae3c53119 100644 --- a/db/docs/ml_experiments.yml +++ b/db/docs/ml_experiments.yml @@ -4,7 +4,6 @@ classes: - Ml::Experiment feature_categories: - mlops - - incubation description: A Machine Learning Experiments groups many Model Candidates introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/95168 milestone: '15.4' diff --git a/db/docs/namespace_aggregation_schedules.yml b/db/docs/namespace_aggregation_schedules.yml index c961c33f2ee..56ac5ee3ed6 100644 --- a/db/docs/namespace_aggregation_schedules.yml +++ b/db/docs/namespace_aggregation_schedules.yml @@ -3,7 +3,7 @@ table_name: namespace_aggregation_schedules classes: - Namespace::AggregationSchedule feature_categories: -- utilization +- subscription_cost_management description: Keeps update schedules for namespace_root_storage_statistics introduced_by_url: https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/29570 milestone: '12.1' diff --git a/db/docs/namespace_limits.yml b/db/docs/namespace_limits.yml index 8601d163d9d..bcc687de858 100644 --- a/db/docs/namespace_limits.yml +++ b/db/docs/namespace_limits.yml @@ -3,7 +3,7 @@ table_name: namespace_limits classes: - NamespaceLimit feature_categories: -- utilization +- subscription_cost_management description: Contains limits for namespace features like storage and ci introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/34746 milestone: '13.2' diff --git a/db/docs/namespace_root_storage_statistics.yml b/db/docs/namespace_root_storage_statistics.yml index 2a3e19ab108..ac2207d7698 100644 --- a/db/docs/namespace_root_storage_statistics.yml +++ b/db/docs/namespace_root_storage_statistics.yml @@ -3,7 +3,7 @@ table_name: namespace_root_storage_statistics classes: - Namespace::RootStorageStatistics feature_categories: -- utilization +- application_instrumentation description: TODO introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/commit/bde41ee866d0fe0b1bb5ece1130fb6e24d95ad17 milestone: '12.1' diff --git a/db/docs/namespace_statistics.yml b/db/docs/namespace_statistics.yml index fd7dcb4b62e..e84d5d563f8 100644 --- a/db/docs/namespace_statistics.yml +++ b/db/docs/namespace_statistics.yml @@ -3,7 +3,7 @@ table_name: namespace_statistics classes: - NamespaceStatistics feature_categories: -- utilization +- application_instrumentation description: TODO introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/commit/48d8bdca0493056a717cd7d9fee2e8b51d6b0502 milestone: '9.0' diff --git a/db/docs/namespaces_sync_events.yml b/db/docs/namespaces_sync_events.yml index f143ac29804..f089ca85789 100644 --- a/db/docs/namespaces_sync_events.yml +++ b/db/docs/namespaces_sync_events.yml @@ -3,7 +3,7 @@ table_name: namespaces_sync_events classes: - Namespaces::SyncEvent feature_categories: -- sharding +- pods description: Used as a queue of data that needs to be synchronized between the `ci` and `main` database introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/75517 milestone: '14.6' diff --git a/db/docs/notes.yml b/db/docs/notes.yml index a6bc81f093f..a9268c4b352 100644 --- a/db/docs/notes.yml +++ b/db/docs/notes.yml @@ -12,7 +12,7 @@ classes: - SyntheticNote - WeightNote feature_categories: -- code_review +- code_review_workflow - portfolio_management - service_desk - snippets diff --git a/db/docs/operations_feature_flags.yml b/db/docs/operations_feature_flags.yml index 9207ab20b3a..25c3f0bfe95 100644 --- a/db/docs/operations_feature_flags.yml +++ b/db/docs/operations_feature_flags.yml @@ -3,7 +3,7 @@ table_name: operations_feature_flags classes: - Operations::FeatureFlag feature_categories: -- release +- feature_flags description: TODO introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/7433 milestone: '11.4' diff --git a/db/docs/project_statistics.yml b/db/docs/project_statistics.yml index a3afb678877..9bc6175b45f 100644 --- a/db/docs/project_statistics.yml +++ b/db/docs/project_statistics.yml @@ -3,7 +3,7 @@ table_name: project_statistics classes: - ProjectStatistics feature_categories: -- utilization +- application_instrumentation description: Records statistics about the usage of various product features introduced_by_url: https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/7754 milestone: '8.16' diff --git a/db/docs/projects_sync_events.yml b/db/docs/projects_sync_events.yml index 7e03e5abe63..70e325d1c0a 100644 --- a/db/docs/projects_sync_events.yml +++ b/db/docs/projects_sync_events.yml @@ -3,7 +3,7 @@ table_name: projects_sync_events classes: - Projects::SyncEvent feature_categories: -- sharding +- pods description: Used as a queue of data that needs to be synchronized between the `ci` and `main` database introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/75517 milestone: '14.6' diff --git a/db/docs/security_orchestration_policy_configurations.yml b/db/docs/security_orchestration_policy_configurations.yml index 7d23d30de82..c015de47123 100644 --- a/db/docs/security_orchestration_policy_configurations.yml +++ b/db/docs/security_orchestration_policy_configurations.yml @@ -3,7 +3,7 @@ table_name: security_orchestration_policy_configurations classes: - Security::OrchestrationPolicyConfiguration feature_categories: -- security_orchestration +- security_policy_management description: | Relates a Project/Namespace and Security Orchestration Policy Project, where Security Policies are stored in the repository as a YAML file. diff --git a/db/docs/security_orchestration_policy_rule_schedules.yml b/db/docs/security_orchestration_policy_rule_schedules.yml index 8d1067d8f58..bcb81544f43 100644 --- a/db/docs/security_orchestration_policy_rule_schedules.yml +++ b/db/docs/security_orchestration_policy_rule_schedules.yml @@ -3,7 +3,7 @@ table_name: security_orchestration_policy_rule_schedules classes: - Security::OrchestrationPolicyRuleSchedule feature_categories: -- security_orchestration +- security_policy_management description: | Security policies scheduled to run based on cadence defined in the policy introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/59842 diff --git a/db/docs/uploads.yml b/db/docs/uploads.yml index b22f8b1d1ad..50ba713c413 100644 --- a/db/docs/uploads.yml +++ b/db/docs/uploads.yml @@ -3,7 +3,7 @@ table_name: uploads classes: - Upload feature_categories: -- code_review +- code_review_workflow - design_management - importers - portfolio_management diff --git a/db/docs/user_highest_roles.yml b/db/docs/user_highest_roles.yml index 8713aff5f3f..cc12e3080ff 100644 --- a/db/docs/user_highest_roles.yml +++ b/db/docs/user_highest_roles.yml @@ -3,8 +3,8 @@ table_name: user_highest_roles classes: - UserHighestRole feature_categories: -- utilization -description: TODO +- authentication_and_authorization +description: Stores highest role per User they have in a Group or a Project. If a User has an open invite or pending access request or no membership the highest role will be set to nil. introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/26987 milestone: '12.9' gitlab_schema: gitlab_main diff --git a/db/docs/users_statistics.yml b/db/docs/users_statistics.yml index 9110ee6063d..5fdbc60616f 100644 --- a/db/docs/users_statistics.yml +++ b/db/docs/users_statistics.yml @@ -3,7 +3,7 @@ table_name: users_statistics classes: - UsersStatistics feature_categories: -- utilization +- application_instrumentation description: User statistics introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/26261 milestone: '12.9' diff --git a/doc/.vale/gitlab/Uppercase.yml b/doc/.vale/gitlab/Uppercase.yml index 724194695c4..19e0fec6622 100644 --- a/doc/.vale/gitlab/Uppercase.yml +++ b/doc/.vale/gitlab/Uppercase.yml @@ -47,10 +47,10 @@ exceptions: - CSS - CSV - CTE - - CWE - CVE - CVS - CVSS + - CWE - DAG - DAST - DDL @@ -148,6 +148,7 @@ exceptions: - NTP - OCI - OKD + - OKR - ONLY - OSS - OTP diff --git a/doc/.vale/gitlab/spelling-exceptions.txt b/doc/.vale/gitlab/spelling-exceptions.txt index 81b21f026f4..5203cf6a112 100644 --- a/doc/.vale/gitlab/spelling-exceptions.txt +++ b/doc/.vale/gitlab/spelling-exceptions.txt @@ -547,8 +547,8 @@ Mattermost mbox memoization memoize -memoizes memoized +memoizes memoizing Memorystore mergeability @@ -589,8 +589,8 @@ mutex nameserver nameservers namespace -namespaced namespace's +namespaced namespaces namespacing namespacings @@ -620,6 +620,7 @@ offboarding offboards OIDs OKRs +OKRs Okta OmniAuth onboarding @@ -639,12 +640,12 @@ Packwerk paginator parallelization parallelizations +parsable PascalCase PascalCased passthrough passthroughs passwordless -parsable Patroni PDFs performant @@ -827,8 +828,8 @@ Salesforce sandboxing sanitization SBOMs -SBT sbt +SBT scalers scatterplot scatterplots diff --git a/doc/api/import.md b/doc/api/import.md index 7a1eb4fe8b3..723176bdf02 100644 --- a/doc/api/import.md +++ b/doc/api/import.md @@ -116,6 +116,38 @@ Returns the following status codes: - `400 Bad Request`: the project import cannot be canceled. - `404 Not Found`: the project associated with `project_id` does not exist. +## Import GitHub gists into GitLab snippets + +> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/371099) in GitLab 15.8. + +You can use the GitLab API to import personal GitHub gists (with up to 10 files) into personal GitLab snippets. +GitHub gists with more than 10 files are skipped. You should manually migrate these GitHub gists. + +```plaintext +POST /import/github/gists +``` + +| Attribute | Type | Required | Description | +|------------|---------|----------|---------------------| +| `personal_access_token` | string | yes | GitHub personal access token | + +```shell +curl --request POST \ + --url "https://gitlab.example.com/api/v4/import/github/gists" \ + --header "content-type: application/json" \ + --header "PRIVATE-TOKEN: <your_gitlab_access_token>" \ + --data '{ + "personal_access_token": "<your_github_personal_access_token>" +}' +``` + +Returns the following status codes: + +- `202 Accepted`: the gists import is being started. +- `401 Unauthorized`: user's GitHub personal access token is invalid. +- `422 Unprocessable Entity`: the gists import is already in progress. +- `429 Too Many Requests`: the user has exceeded GitHub's rate limit. + ## Import repository from Bitbucket Server Import your projects from Bitbucket Server to GitLab via the API. diff --git a/doc/ci/yaml/includes.md b/doc/ci/yaml/includes.md index daf2e653250..ae76958c98a 100644 --- a/doc/ci/yaml/includes.md +++ b/doc/ci/yaml/includes.md @@ -56,7 +56,7 @@ You can include an array of configuration files: - template: Auto-DevOps.gitlab-ci.yml ``` -- You can define an array that combines both default and specific `include` type: +- You can define an array that combines both default and specific `include` types: ```yaml include: @@ -333,52 +333,82 @@ see this [CI/CD variable demo](https://youtu.be/4XR8gw3Pkos). ## Use `rules` with `include` > - Introduced in GitLab 14.2 [with a flag](../../administration/feature_flags.md) named `ci_include_rules`. Disabled by default. -> - [Enabled on GitLab.com](https://gitlab.com/gitlab-org/gitlab/-/issues/337507) in GitLab 14.3. -> - [Enabled on self-managed](https://gitlab.com/gitlab-org/gitlab/-/issues/337507) GitLab 14.3. -> - [Feature flag `ci_include_rules` removed](https://gitlab.com/gitlab-org/gitlab/-/issues/337507) in GitLab 14.4. -> - [Generally available](https://gitlab.com/gitlab-org/gitlab/-/issues/337507) in GitLab 14.4. +> - [Enabled on GitLab.com and self-managed](https://gitlab.com/gitlab-org/gitlab/-/issues/337507) in GitLab 14.3. +> - [Generally available](https://gitlab.com/gitlab-org/gitlab/-/issues/337507) in GitLab 14.4. Feature flag `ci_include_rules` removed. > - [Support for `exists` keyword added](https://gitlab.com/gitlab-org/gitlab/-/issues/341511) in GitLab 14.5. You can use [`rules`](index.md#rules) with `include` to conditionally include other configuration files. -You can only use the following rules with `include` (and only with [certain variables](#use-variables-with-include)): +You can only use `rules` with [certain variables](#use-variables-with-include), and +these keywords: -- [`if` rules](index.md#rulesif). For example: +- [`rules:if`](index.md#rulesif). +- [`rules:exists`](index.md#rulesexists). - ```yaml - include: - - local: builds.yml - rules: - - if: $INCLUDE_BUILDS == "true" - - local: deploys.yml - rules: - - if: $CI_COMMIT_BRANCH == "main" - - test: - stage: test - script: exit 0 - ``` +You cannot use [`needs:`](index.md#needs) to create a job dependency that points to +a job added with `include:local:rules`. When the configuration is validated, +GitLab returns `undefined need: <job-name>`. [Issue 345377](https://gitlab.com/gitlab-org/gitlab/-/issues/345377) +proposes improving this behavior. -- [`exists` rules](index.md#rulesexists). For example: +### `include` with `rules:if` - ```yaml - include: - - local: builds.yml - rules: - - exists: - - file.md - - test: - stage: test - script: exit 0 - ``` +Use [`rules:if`](index.md#rulesif) to conditionally include other configuration files +based on the status of CI/CD variables. For example: -`rules` keyword `changes` is not supported. +```yaml +include: + - local: builds.yml + rules: + - if: $INCLUDE_BUILDS == "true" + - local: deploys.yml + rules: + - if: $CI_COMMIT_BRANCH == "main" + +test: + stage: test + script: exit 0 +``` -You cannot use [`needs:`](index.md#needs) to create a job dependency that points to -a job added with `include:local:rules`. When the configuration is checked for validity, -GitLab returns `undefined need: <job-name>`. An [issue exists](https://gitlab.com/gitlab-org/gitlab/-/issues/345377) -to improve this behavior. +### `include` with `rules:exists` + +Use [`rules:exists`](index.md#rulesexists) to conditionally include other configuration files +based on the existence of files. For example: + +```yaml +include: + - local: builds.yml + rules: + - exists: + - file.md + +test: + stage: test + script: exit 0 +``` + +In this example, GitLab checks for the existence of `file.md` in the current project. + +There is a known issue if you configure `include` with `rules:exists` to add a configuration file +from a different project. GitLab checks for the existence of the file in the _other_ project. +For example: + +```yaml +include: +- project: my-group/my-project-2 + ref: main + file: test-file.yml + rules: + - exists: + - file.md + +test: + stage: test + script: exit 0 +``` + +In this example, GitLab checks for the existence of `test-file.yml` in `my-group/my-project-2`, +not the current project. Follow [issue 386040](https://gitlab.com/gitlab-org/gitlab/-/issues/386040) +for information about work to improve this behavior. ## Use `include:local` with wildcard file paths diff --git a/doc/topics/plan_and_track.md b/doc/topics/plan_and_track.md index 862c41aa4d9..8b1fb1657a0 100644 --- a/doc/topics/plan_and_track.md +++ b/doc/topics/plan_and_track.md @@ -58,3 +58,4 @@ Align your work across teams. - [View health status](../user/project/issues/managing_issues.md#health-status) - [Roadmaps](../user/group/roadmap/index.md) - [Planning hierarchies](../user/group/planning_hierarchy/index.md) +- [Objectives and key results](../user/okrs.md) diff --git a/doc/user/okrs.md b/doc/user/okrs.md new file mode 100644 index 00000000000..0b6bffa97ce --- /dev/null +++ b/doc/user/okrs.md @@ -0,0 +1,254 @@ +--- +stage: Plan +group: Product Planning +info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments +--- + +# Objectives and key results (OKR) **(ULTIMATE)** + +> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/103355) in GitLab 15.6 [with a flag](../administration/feature_flags.md) named `okrs_mvc`. Disabled by default. + +WARNING: +OKRs are in [**Alpha**](../policy/alpha-beta-support.md#alpha-features). +For the OKR feature roadmap, see [epic 7864](https://gitlab.com/groups/gitlab-org/-/epics/7864). + +FLAG: +On self-managed GitLab, by default this feature is not available. To make it available, +ask an administrator to [enable the featured flag](../administration/feature_flags.md) named `okrs_mvc`. +The feature is not ready for production use. + +Use objectives and key results to align your workforce towards common goals and track the progress. +Set a big goal with an objective and use [child objectives and key results](#child-objectives-and-key-results) +to measure the big goal's completion. + +The objective and the key result in GitLab share many features. In the documentation, the term +**OKR** refers to either an objective or a key result. + +OKRs are a type of work item, a step towards [default issue types](https://gitlab.com/gitlab-org/gitlab/-/issues/323404) +in GitLab. +For the roadmap of migrating [issues](project/issues/index.md) and [epics](group/epics/index.md) +to work items and adding custom work item types, see +[epic 6033](https://gitlab.com/groups/gitlab-org/-/epics/6033) or the +[Plan direction page](https://about.gitlab.com/direction/plan/). + +## Create an objective + +Prerequisites: + +- You must have at least the Guest role for the project. + +To create an objective: + +1. On the top bar, select **Main menu > Projects** and find your project. +1. On the left sidebar, select **Issues**. +1. In the top right corner, next to **New issue**, select the down arrow **{chevron-lg-down}** and then select **New objective**. +1. Select **New objective** again. +1. Enter the objective title. +1. Select **Create objective**. + +To create a key result, [add it as a child](#add-a-child-key-result) to an existing objective. + +## View an objective + +Prerequisites: + +- You must have at least the Guest role for the project. + +To view an objective: + +1. On the top bar, select **Main menu > Projects** and find your project. +1. On the left sidebar, select **Issues**. +1. [Filter the list of issues](project/issues/managing_issues.md#filter-the-list-of-issues) +for `Type = objective`. +1. Select the title of an objective from the list. + +## View a key result + +Prerequisites: + +- You must have at least the Guest role for the project. + +To view a key result: + +1. On the top bar, select **Main menu > Projects** and find your project. +1. On the left sidebar, select **Issues**. +1. [Filter the list of issues](project/issues/managing_issues.md#filter-the-list-of-issues) +for `Type = key_result`. +1. Select the title of a key result from the list. + +Alternatively, you can access a key result from the **Child objectives and key results** section in +its parent's objective. + +## Edit title and description + +Prerequisites: + +- You must have at least the Reporter role for the project. + +To edit an OKR: + +1. [Open the objective](okrs.md#view-an-objective) or [key result](#view-a-key-result) that you want to edit. +1. Optional. To edit the title, select it, make your changes, and select any area outside the title + text box. +1. Optional. To edit the description, select the edit icon (**{pencil}**), make your changes, and + select **Save**. + +## Assign users + +To show who is responsible for an OKR, you can assign users to it. + +Users on GitLab Free can assign one user per OKR. +Users on GitLab Premium and higher can assign multiple users to a single OKR. +See also [multiple assignees for issues](project/issues/multiple_assignees_for_issues.md). + +Prerequisites: + +- You must have at least the Reporter role for the project. + +To change the assignee on an OKR: + +1. [Open the objective](okrs.md#view-an-objective) or [key result](#view-a-key-result) that you want to edit. +1. Next to **Assignees**, select **Add assignees**. +1. From the dropdown list, select the users to add as an assignee. +1. Select any area outside the dropdown list. + +## Assign labels + +Prerequisites: + +- You must have at least the Reporter role for the project. + +Use [labels](project/labels.md) to organize OKRs among teams. + +To add labels to an OKR: + +1. [Open the objective](okrs.md#view-an-objective) or [key result](#view-a-key-result) that you want to edit. +1. Next to **Labels**, select **Add labels**. +1. From the dropdown list, select the labels to add. +1. Select any area outside the dropdown list. + +## Add an objective to a milestone + +> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/367463) in GitLab 15.7. + +You can add an objective to a [milestone](project/milestones/index.md). +You can see the milestone title when you view an objective. + +Prerequisites: + +- You must have at least the Reporter role for the project. + +To add an objective to a milestone: + +1. [Open the objective](okrs.md#view-an-objective) that you want to edit. +1. Next to **Milestone**, select **Add to milestone**. + If an objective already belongs to a milestone, the dropdown list shows the current milestone. +1. From the dropdown list, select the milestone to be associated with the objective. + +## Set objective progress + +Show how much of the work needed to achieve an objective is finished. + +You can only set progress manually on objectives, and it's not rolled up from child objectives or +key results. + +Prerequisites: + +- You must have at least the Reporter role for the project. + +To set progress of an objective: + +1. [Open the objective](okrs.md#view-an-objective) that you want to edit. +1. Next to **Progress**, select the text box. +1. Enter a number from 0 to 100. + +## Set health status + +> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/381899) in GitLab 15.7. + +To better track the risk in meeting your goals, you can assign a [health status](project/issues/managing_issues.md#health-status) +to each objective and key result. +You can use health status to signal to others in your organization whether OKRs are progressing +as planned or need attention to stay on schedule. + +Prerequisites: + +- You must have at least the Reporter role for the project. + +To set health status of an OKR: + +1. [Open the key result](okrs.md#view-a-key-result) that you want to edit. +1. Next to **Health status**, select the dropdown list and select the desired health status. + +## Close an OKR + +When an OKR is achieved, you can close it. +The OKR is marked as closed but is not deleted. + +Prerequisites: + +- You must have at least the Reporter role for the project. + +To close an OKR: + +1. [Open the objective](okrs.md#view-an-objective) that you want to edit. +1. Next to **Status**, select **Closed**. + +You can reopen a closed OKR the same way. + +## Child objectives and key results + +In GitLab, objectives are similar to key results. +In your workflow, use key results to measure the goal described in the objective. + +You can add child objectives to a total of 9 levels. An objective can have up to 100 child OKRs. +Key results are children of objectives and cannot have children items themselves. + +Child objectives and key results are available in the **Child objectives and key results** section +below an objective's description. + +### Add a child objective + +Prerequisites: + +- You must have at least the Guest role for the project. + +To add a new objective to an objective: + +1. In an objective, in the **Child objectives and key results** section, select **Add** and then + select **New objective**. +1. Enter a title for the new objective. +1. Select **Create objective**. + +To add an existing objective to an objective: + +1. In an objective, in the **Child objectives and key results** section, select **Add** and then + select **Existing objective**. +1. Search for the desired objective by entering part of its title, then selecting the + desired match. + + To add multiple objectives, repeat this step. +1. Select **Add objective**. + +### Add a child key result + +Prerequisites: + +- You must have at least the Guest role for the project. + +To add a new key result to an objective: + +1. In an objective, in the **Child objectives and key results** section, select **Add** and then + select **New key result**. +1. Enter a title for the new key result. +1. Select **Create key result**. + +To add an existing key result to an objective: + +1. In an objective, in the **Child objectives and key results** section, select **Add** and then + select **Existing key result**. +1. Search for the desired OKR by entering part of its title, then selecting the + desired match. + + To add multiple objectives, repeat this step. +1. Select **Add key result**. diff --git a/doc/user/project/remote_development/index.md b/doc/user/project/remote_development/index.md index 119ca930f92..71cc6f19c6b 100644 --- a/doc/user/project/remote_development/index.md +++ b/doc/user/project/remote_development/index.md @@ -6,7 +6,7 @@ info: To determine the technical writer assigned to the Stage/Group associated w # Remote Development **(FREE)** -> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/95169) in GitLab 15.6 [with a flag](../../../administration/feature_flags.md) named `vscode_web_ide`. Disabled by default. +> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/95169) in GitLab 15.4 [with a flag](../../../administration/feature_flags.md) named `vscode_web_ide`. Disabled by default. FLAG: On self-managed GitLab, by default this feature is not available. To make it available, ask an administrator to [enable the feature flag](../../../administration/feature_flags.md) named `vscode_web_ide`. On GitLab.com, this feature is available. The feature is not ready for production use. @@ -22,7 +22,7 @@ As with all projects, the items mentioned on this page are subject to change or The development, release, and timing of any products, features, or functionality remain at the sole discretion of GitLab Inc. -You can use the [Web IDE](../web_ide/index.md) to commit changes to a project directly from your web browser without installing any dependencies or cloning any repositories. The Web IDE, however, lacks a native runtime environment on which you would compile code, run tests, or generate real-time feedback in the IDE. For a more complete IDE experience, you can pair the Web IDE with a Remote Development environment that has been properly configured to run as a host. +You can use the [Web IDE](../web_ide/index.md) to commit changes to a project directly from your web browser without installing any dependencies or cloning any repositories. The Web IDE, however, lacks a native runtime environment on which you would compile code, run tests, or generate real-time feedback in the IDE. For a more complete IDE experience, you can pair the [Web IDE Beta](../web_ide_beta/index.md) with a Remote Development environment that has been properly configured to run as a host. ## Connect a remote machine to the Web IDE @@ -154,3 +154,8 @@ Alternatively, you can pass the parameters from a URL and connect directly to th ``` 1. Go to that URL and enter the [token you fetched](#fetch-a-token). + +## Related topics + +- [Web IDE](../web_ide/index.md) +- [Web IDE Beta](../web_ide_beta/index.md) diff --git a/doc/user/project/web_ide/index.md b/doc/user/project/web_ide/index.md index fb100986df9..4143ad6cbc2 100644 --- a/doc/user/project/web_ide/index.md +++ b/doc/user/project/web_ide/index.md @@ -446,13 +446,12 @@ when: - You select any area outside the file editor after editing a file. - A file or folder is created, deleted, or renamed. -### Limitations +### Known issues The Web IDE has a few limitations: - Interactive Terminals is in a beta phase and continues to be improved in upcoming releases. In the meantime, the user is limited to having only one active terminal at a time. - - LFS files can be rendered and displayed but they cannot be updated and committed using the Web IDE. If an LFS file is modified and pushed to the repository, the LFS pointer in the repository is overwritten with the modified LFS file content. ### Troubleshooting @@ -463,3 +462,7 @@ The Web IDE has a few limitations: - If the terminal displays **Connection Failure**, then the terminal could not connect to the runner. Try to stop and restart the terminal. If the problem persists, double check your runner configuration. + +## Related topics + +- [Web IDE Beta](../web_ide_beta/index.md) diff --git a/doc/user/project/web_ide_beta/index.md b/doc/user/project/web_ide_beta/index.md index ef07cca465d..85913874be7 100644 --- a/doc/user/project/web_ide_beta/index.md +++ b/doc/user/project/web_ide_beta/index.md @@ -6,17 +6,17 @@ info: To determine the technical writer assigned to the Stage/Group associated w # Web IDE Beta **(FREE)** -> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/95169) in GitLab 15.4 [with a flag](../../../administration/feature_flags.md) named `vscode_web_ide`. Disabled by default. +> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/95169) in GitLab 15.7 [with a flag](../../../administration/feature_flags.md) named `vscode_web_ide`. Disabled by default. FLAG: -On self-managed GitLab, by default this feature is not available. To make it available, ask an administrator to [enable the feature flag](../../../administration/feature_flags.md) named `vscode_web_ide`. On GitLab.com, this feature is available. +On self-managed GitLab, by default this feature is not available. To make it available, ask an administrator to [enable the feature flag](../../../administration/feature_flags.md) named `vscode_web_ide`. On GitLab.com, this feature is available. The feature is not ready for production use. As announced in [this blog post](https://about.gitlab.com/blog/2022/05/23/the-future-of-the-gitlab-web-ide/), -the current implementation of the Web IDE is being replaced with an -implementation inspired by Visual Studio Code. +the current implementation of the [Web IDE](../web_ide/index.md) is being replaced +with an implementation inspired by Visual Studio Code. This effort is still under +development. For updates, see [this epic](https://gitlab.com/groups/gitlab-org/-/epics/7683). -This effort is currently under development. For updates, -see [this epic](https://gitlab.com/groups/gitlab-org/-/epics/7683). +To connect a remote machine to the Web IDE Beta, see [Remote Development](../remote_development/index.md). ## Enable the Web IDE Beta @@ -34,7 +34,7 @@ To open the Web IDE Beta from anywhere in the UI: - Use the <kbd>.</kbd> [keyboard shortcut](../../shortcuts.md). You can also open the Web IDE Beta when viewing a file, the repository file list, -and from merge requests. +or a merge request. ### Use when viewing a file or the repository file list @@ -59,45 +59,48 @@ To open the Web IDE Beta from a merge request: To open any file by its name: -1. Type **Command** + **`P`** (<kbd>⌘</kbd> + <kbd>P</kbd>). -1. Type the name of your file. +1. Press <kbd>Command</kbd>+<kbd>P</kbd>. +1. Enter the name of your file. ![fuzzy_finder_v15_7](img/fuzzy_finder_v15_7.png) ## Search across files -You can use VS Code to quickly search all files in the currently opened folder. +You can use VS Code to quickly search all files in the opened folder. -To enter your search term: +To search across files: -1. Type **Shift** + **Command** + **`F`** (<kbd>⇧</kbd> + <kbd>⌘</kbd> + <kbd>F</kbd>). +1. Press <kbd>Shift</kbd>+<kbd>Command</kbd>+<kbd>F</kbd>. 1. Enter your search term. In the Web IDE Beta, only partial results from opened files are displayed. Full file search is planned for a later date. -## View list of changed files +## View a list of changed files -To view the list of files you changed in the Web IDE Beta: +To view a list of files you changed in the Web IDE Beta, +in the Activity Bar on the left, select **Source Control**. +Your `CHANGES`, `STAGED CHANGES`, and `MERGE CHANGES` are displayed. -- On the VS Code Activity Bar, on the left, select the Source Control icon: +For details, see the [VS Code documentation](https://code.visualstudio.com/docs/sourcecontrol/overview#_commit). -Your `CHANGES`, `STAGED CHANGES` and `MERGE CHANGES` are displayed. +## Stop using the Web IDE Beta -For details, see [the VS Code documentation](https://code.visualstudio.com/docs/sourcecontrol/overview#_commit). +If you do not want to use the Web IDE Beta, you can change your personal preferences. + +1. On the top bar, in the top right corner, select your avatar. +1. Select **Preferences**. +1. In the **Web IDE** section, select the **Opt out of the Web IDE Beta** checkbox. +1. Select **Save changes**. ## Known issues The [Web Terminal](../web_ide/index.md#interactive-web-terminals-for-the-web-ide) and [Live Preview](../web_ide/index.md#live-preview) are not available in the Web IDE Beta. -These features may become available at a later date. +These features might become available at a later date. -### Stop using the Web IDE Beta +## Related topics -If you do not want to use the Web IDE Beta, you can change your personal preferences. - -1. On the top bar, in the top right corner, select your avatar. -1. Select **Preferences**. -1. In the **Web IDE** section, select the **Opt out of the Web IDE Beta** checkbox. -1. Select **Save changes**. +- [Remote Development](../remote_development/index.md) +- [Web IDE](../web_ide/index.md) diff --git a/doc/user/tasks.md b/doc/user/tasks.md index ffe7777fac0..aad53f4165c 100644 --- a/doc/user/tasks.md +++ b/doc/user/tasks.md @@ -30,8 +30,8 @@ and so you can provide a more accurate issue weight and completion criteria. Tasks are a type of work item, a step towards [default issue types](https://gitlab.com/gitlab-org/gitlab/-/issues/323404) in GitLab. For the roadmap of migrating issues and [epics](group/epics/index.md) -to work items and adding custom work item types, visit -[epic 6033](https://gitlab.com/groups/gitlab-org/-/epics/6033) or +to work items and adding custom work item types, see +[epic 6033](https://gitlab.com/groups/gitlab-org/-/epics/6033) or the [Plan direction page](https://about.gitlab.com/direction/plan/). ## View tasks @@ -168,6 +168,10 @@ To change the assignee on a task: > [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/339756) in GitLab 15.5. +Prerequisites: + +- You must have at least the Reporter role for the project. + To add [labels](project/labels.md) to a task: 1. In the issue description, in the **Tasks** section, select the title of the task you want to edit. The task window opens. @@ -225,7 +229,7 @@ To add a task to a milestone: 1. In the issue description, in the **Tasks** section, select the title of the task you want to edit. The task window opens. 1. Next to **Milestone**, select **Add to milestone**. -If a task already belongs to a milestone, the dropdown list shows the current milestone. + If a task already belongs to a milestone, the dropdown list shows the current milestone. 1. From the dropdown list, select the milestone to be associated with the task. ## Set task weight **(PREMIUM)** diff --git a/lib/api/import_github.rb b/lib/api/import_github.rb index d742e3732a8..a5aa40fc40d 100644 --- a/lib/api/import_github.rb +++ b/lib/api/import_github.rb @@ -8,6 +8,7 @@ module API urgency :low rescue_from Octokit::Unauthorized, with: :provider_unauthorized + rescue_from Gitlab::GithubImport::RateLimitError, with: :too_many_requests helpers do def client @@ -33,6 +34,10 @@ module API def provider_unauthorized error!("Access denied to your #{Gitlab::ImportSources.title(provider.to_s)} account.", 401) end + + def too_many_requests + error!('Too Many Requests', 429) + end end desc 'Import a GitHub project' do @@ -92,5 +97,30 @@ module API render_api_error!(result[:message], result[:http_status]) end end + + desc 'Import User Gists' do + detail 'This feature was introduced in GitLab 15.8' + success code: 202 + failure [ + { code: 401, message: 'Unauthorized' }, + { code: 422, message: 'Unprocessable Entity' }, + { code: 429, message: 'Too Many Requests' } + ] + end + params do + requires :personal_access_token, type: String, desc: 'GitHub personal access token' + end + post 'import/github/gists' do + authorize! :create_snippet + + result = Import::Github::GistsImportService.new(current_user, client, access_params).execute + + if result[:status] == :success + status 202 + else + status result[:http_status] + { errors: result[:message] } + end + end end end diff --git a/lib/event_filter.rb b/lib/event_filter.rb index d26a1cfeebc..ed14affda71 100644 --- a/lib/event_filter.rb +++ b/lib/event_filter.rb @@ -38,7 +38,7 @@ class EventFilter when TEAM events.where(action: Event::TEAM_ACTIONS) when ISSUE - events.where(action: Event::ISSUE_ACTIONS, target_type: Event::ISSUE_TYPES) + events.where(action: Event::ISSUE_ACTIONS).for_issue when WIKI wiki_events(events) when DESIGNS @@ -97,7 +97,7 @@ class EventFilter when ISSUE in_operator_params( array_data: array_data, - scope: Event.where(target_type: Event::ISSUE_TYPES), + scope: Event.for_issue, in_column: :action, in_values: Event.actions.values_at(*Event::ISSUE_ACTIONS) ) diff --git a/lib/gitlab/ci/pipeline/chain/populate.rb b/lib/gitlab/ci/pipeline/chain/populate.rb index 654e24be8e1..c59ef2ba6a4 100644 --- a/lib/gitlab/ci/pipeline/chain/populate.rb +++ b/lib/gitlab/ci/pipeline/chain/populate.rb @@ -18,7 +18,8 @@ module Gitlab pipeline.stages = @command.pipeline_seed.stages if stage_names.empty? - return error('No stages / jobs for this pipeline.') + return error('Pipeline will not run for the selected trigger. ' \ + 'The rules configuration prevented any jobs from being added to the pipeline.') end if pipeline.invalid? diff --git a/locale/gitlab.pot b/locale/gitlab.pot index 8c78bdbee90..610503697eb 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -25763,6 +25763,9 @@ msgstr "" msgid "MemberRole|can't be changed" msgstr "" +msgid "MemberRole|cannot be changed because it is already assigned to a user. Please create a new Member Role instead" +msgstr "" + msgid "MemberRole|must be top-level namespace" msgstr "" diff --git a/qa/qa/runtime/browser.rb b/qa/qa/runtime/browser.rb index af1a4e06473..faf2023f7c2 100644 --- a/qa/qa/runtime/browser.rb +++ b/qa/qa/runtime/browser.rb @@ -96,12 +96,11 @@ module QA capabilities['goog:chromeOptions'][:args] << 'disable-dev-shm-usage' if QA::Runtime::Env.disable_dev_shm? # Set chrome default download path - if QA::Runtime::Env.chrome_default_download_path - capabilities['goog:chromeOptions'][:prefs] = { - 'download.default_directory' => File.expand_path(QA::Runtime::Env.chrome_default_download_path), - 'download.prompt_for_download' => false - } - end + + capabilities['goog:chromeOptions'][:prefs] = { + 'download.default_directory' => File.expand_path(QA::Runtime::Env.chrome_default_download_path), + 'download.prompt_for_download' => false + } # Specify the user-agent to allow challenges to be bypassed # See https://gitlab.com/gitlab-com/gl-infra/infrastructure/-/issues/11938 diff --git a/qa/qa/runtime/env.rb b/qa/qa/runtime/env.rb index b2a5890e960..346d40780fd 100644 --- a/qa/qa/runtime/env.rb +++ b/qa/qa/runtime/env.rb @@ -495,7 +495,7 @@ module QA end def chrome_default_download_path - ENV['DEFAULT_CHROME_DOWNLOAD_PATH'] + ENV['DEFAULT_CHROME_DOWNLOAD_PATH'] || Dir.tmpdir end private diff --git a/scripts/setup/as-if-jh.sh b/scripts/setup/as-if-jh.sh index 38c3ac9b913..70bfdd7b484 100755 --- a/scripts/setup/as-if-jh.sh +++ b/scripts/setup/as-if-jh.sh @@ -19,7 +19,7 @@ download_jh_path() { echoinfo "Downloading ${path}" - curl --location -o "${output}" -H "Private-Token: ${ADD_JH_FILES_TOKEN}" "https://gitlab.com/api/v4/projects/${GITLAB_JH_MIRROR_PROJECT}/repository/archive?sha=${JH_BRANCH}&path=${path}" + curl --location --output "${output}" --header "Private-Token: ${ADD_JH_FILES_TOKEN}" --get --data-urlencode "sha=${JH_BRANCH}" --data-urlencode "path=${path}" "https://gitlab.com/api/v4/projects/${GITLAB_JH_MIRROR_PROJECT}/repository/archive" tar -zxf "${output}" rm "${output}" diff --git a/scripts/setup/find-jh-branch.rb b/scripts/setup/find-jh-branch.rb index 5b36aa7a1f4..67e83423d9c 100755 --- a/scripts/setup/find-jh-branch.rb +++ b/scripts/setup/find-jh-branch.rb @@ -92,7 +92,7 @@ class FindJhBranch def gitlab @gitlab ||= Gitlab.client( endpoint: API::DEFAULT_OPTIONS[:endpoint], - private_token: API::DEFAULT_OPTIONS[:api_token] || '' + private_token: ENV['ADD_JH_FILES_TOKEN'] || '' ) end end diff --git a/spec/lib/gitlab/ci/pipeline/chain/populate_spec.rb b/spec/lib/gitlab/ci/pipeline/chain/populate_spec.rb index 62de4d2e96d..91bb94bbb11 100644 --- a/spec/lib/gitlab/ci/pipeline/chain/populate_spec.rb +++ b/spec/lib/gitlab/ci/pipeline/chain/populate_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Gitlab::Ci::Pipeline::Chain::Populate do +RSpec.describe Gitlab::Ci::Pipeline::Chain::Populate, feature_category: :continuous_integration do let_it_be(:project) { create(:project, :repository) } let_it_be(:user) { create(:user) } @@ -90,7 +90,8 @@ RSpec.describe Gitlab::Ci::Pipeline::Chain::Populate do it 'appends an error about missing stages' do expect(pipeline.errors.to_a) - .to include 'No stages / jobs for this pipeline.' + .to include 'Pipeline will not run for the selected trigger. ' \ + 'The rules configuration prevented any jobs from being added to the pipeline.' end it 'wastes pipeline iid' do diff --git a/spec/lib/gitlab/ci/status/bridge/factory_spec.rb b/spec/lib/gitlab/ci/status/bridge/factory_spec.rb index 6081f104e42..c13901a4776 100644 --- a/spec/lib/gitlab/ci/status/bridge/factory_spec.rb +++ b/spec/lib/gitlab/ci/status/bridge/factory_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Gitlab::Ci::Status::Bridge::Factory do +RSpec.describe Gitlab::Ci::Status::Bridge::Factory, feature_category: :continuous_integration do let(:user) { create(:user) } let(:project) { bridge.project } let(:status) { factory.fabricate! } @@ -59,13 +59,15 @@ RSpec.describe Gitlab::Ci::Status::Bridge::Factory do context 'failed with downstream_pipeline_creation_failed' do before do - bridge.options = { downstream_errors: ['No stages / jobs for this pipeline.', 'other error'] } + bridge.options = { downstream_errors: ['Pipeline will not run for the selected trigger. ' \ + 'The rules configuration prevented any jobs from being added to the pipeline.', 'other error'] } bridge.failure_reason = 'downstream_pipeline_creation_failed' end it 'fabricates correct status_tooltip' do expect(status.status_tooltip).to eq( - "#{s_('CiStatusText|failed')} - (downstream pipeline can not be created, No stages / jobs for this pipeline., other error)" + "#{s_('CiStatusText|failed')} - (downstream pipeline can not be created, Pipeline will not run for the selected trigger. " \ + "The rules configuration prevented any jobs from being added to the pipeline., other error)" ) end end diff --git a/spec/lib/gitlab/ci/templates/Jobs/code_quality_gitlab_ci_yaml_spec.rb b/spec/lib/gitlab/ci/templates/Jobs/code_quality_gitlab_ci_yaml_spec.rb index 16c5d7a4b6d..286f3d10b7f 100644 --- a/spec/lib/gitlab/ci/templates/Jobs/code_quality_gitlab_ci_yaml_spec.rb +++ b/spec/lib/gitlab/ci/templates/Jobs/code_quality_gitlab_ci_yaml_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'Jobs/Code-Quality.gitlab-ci.yml' do +RSpec.describe 'Jobs/Code-Quality.gitlab-ci.yml', feature_category: :continuous_integration do subject(:template) { Gitlab::Template::GitlabCiYmlTemplate.find('Jobs/Code-Quality') } describe 'the created pipeline' do @@ -63,7 +63,8 @@ RSpec.describe 'Jobs/Code-Quality.gitlab-ci.yml' do context 'on master' do it 'has no jobs' do expect(build_names).to be_empty - expect(pipeline.errors.full_messages).to match_array(["No stages / jobs for this pipeline."]) + expect(pipeline.errors.full_messages).to match_array(['Pipeline will not run for the selected trigger. ' \ + 'The rules configuration prevented any jobs from being added to the pipeline.']) end end @@ -72,7 +73,8 @@ RSpec.describe 'Jobs/Code-Quality.gitlab-ci.yml' do it 'has no jobs' do expect(build_names).to be_empty - expect(pipeline.errors.full_messages).to match_array(["No stages / jobs for this pipeline."]) + expect(pipeline.errors.full_messages).to match_array(['Pipeline will not run for the selected trigger. ' \ + 'The rules configuration prevented any jobs from being added to the pipeline.']) end end @@ -81,7 +83,8 @@ RSpec.describe 'Jobs/Code-Quality.gitlab-ci.yml' do it 'has no jobs' do expect(build_names).to be_empty - expect(pipeline.errors.full_messages).to match_array(["No stages / jobs for this pipeline."]) + expect(pipeline.errors.full_messages).to match_array(['Pipeline will not run for the selected trigger. ' \ + 'The rules configuration prevented any jobs from being added to the pipeline.']) end end end diff --git a/spec/lib/gitlab/ci/templates/Jobs/sast_iac_gitlab_ci_yaml_spec.rb b/spec/lib/gitlab/ci/templates/Jobs/sast_iac_gitlab_ci_yaml_spec.rb index 8a5aea7c0f0..68d249e31f9 100644 --- a/spec/lib/gitlab/ci/templates/Jobs/sast_iac_gitlab_ci_yaml_spec.rb +++ b/spec/lib/gitlab/ci/templates/Jobs/sast_iac_gitlab_ci_yaml_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'Jobs/SAST-IaC.gitlab-ci.yml' do +RSpec.describe 'Jobs/SAST-IaC.gitlab-ci.yml', feature_category: :continuous_integration do subject(:template) { Gitlab::Template::GitlabCiYmlTemplate.find('Jobs/SAST-IaC') } describe 'the created pipeline' do @@ -50,7 +50,8 @@ RSpec.describe 'Jobs/SAST-IaC.gitlab-ci.yml' do context 'on default branch' do it 'has no jobs' do expect(build_names).to be_empty - expect(pipeline.errors.full_messages).to match_array(["No stages / jobs for this pipeline."]) + expect(pipeline.errors.full_messages).to match_array(['Pipeline will not run for the selected trigger. ' \ + 'The rules configuration prevented any jobs from being added to the pipeline.']) end end @@ -59,7 +60,8 @@ RSpec.describe 'Jobs/SAST-IaC.gitlab-ci.yml' do it 'has no jobs' do expect(build_names).to be_empty - expect(pipeline.errors.full_messages).to match_array(["No stages / jobs for this pipeline."]) + expect(pipeline.errors.full_messages).to match_array(['Pipeline will not run for the selected trigger. ' \ + 'The rules configuration prevented any jobs from being added to the pipeline.']) end end end diff --git a/spec/lib/gitlab/ci/templates/Jobs/sast_iac_latest_gitlab_ci_yaml_spec.rb b/spec/lib/gitlab/ci/templates/Jobs/sast_iac_latest_gitlab_ci_yaml_spec.rb index d540b035f81..039a6a739dd 100644 --- a/spec/lib/gitlab/ci/templates/Jobs/sast_iac_latest_gitlab_ci_yaml_spec.rb +++ b/spec/lib/gitlab/ci/templates/Jobs/sast_iac_latest_gitlab_ci_yaml_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'Jobs/SAST-IaC.latest.gitlab-ci.yml' do +RSpec.describe 'Jobs/SAST-IaC.latest.gitlab-ci.yml', feature_category: :continuous_integration do subject(:template) { Gitlab::Template::GitlabCiYmlTemplate.find('Jobs/SAST-IaC.latest') } describe 'the created pipeline' do @@ -51,7 +51,8 @@ RSpec.describe 'Jobs/SAST-IaC.latest.gitlab-ci.yml' do context 'on default branch' do it 'has no jobs' do expect(build_names).to be_empty - expect(pipeline.errors.full_messages).to match_array(["No stages / jobs for this pipeline."]) + expect(pipeline.errors.full_messages).to match_array(['Pipeline will not run for the selected trigger. ' \ + 'The rules configuration prevented any jobs from being added to the pipeline.']) end end @@ -60,7 +61,8 @@ RSpec.describe 'Jobs/SAST-IaC.latest.gitlab-ci.yml' do it 'has no jobs' do expect(build_names).to be_empty - expect(pipeline.errors.full_messages).to match_array(["No stages / jobs for this pipeline."]) + expect(pipeline.errors.full_messages).to match_array(['Pipeline will not run for the selected trigger. ' \ + 'The rules configuration prevented any jobs from being added to the pipeline.']) end end end diff --git a/spec/lib/gitlab/ci/templates/Jobs/test_gitlab_ci_yaml_spec.rb b/spec/lib/gitlab/ci/templates/Jobs/test_gitlab_ci_yaml_spec.rb index 7cf0cf3ed33..d73d8a15feb 100644 --- a/spec/lib/gitlab/ci/templates/Jobs/test_gitlab_ci_yaml_spec.rb +++ b/spec/lib/gitlab/ci/templates/Jobs/test_gitlab_ci_yaml_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'Jobs/Test.gitlab-ci.yml' do +RSpec.describe 'Jobs/Test.gitlab-ci.yml', feature_category: :continuous_integration do subject(:template) { Gitlab::Template::GitlabCiYmlTemplate.find('Jobs/Test') } describe 'the created pipeline' do @@ -63,7 +63,8 @@ RSpec.describe 'Jobs/Test.gitlab-ci.yml' do context 'on master' do it 'has no jobs' do expect(build_names).to be_empty - expect(pipeline.errors.full_messages).to match_array(["No stages / jobs for this pipeline."]) + expect(pipeline.errors.full_messages).to match_array(['Pipeline will not run for the selected trigger. ' \ + 'The rules configuration prevented any jobs from being added to the pipeline.']) end end @@ -72,7 +73,8 @@ RSpec.describe 'Jobs/Test.gitlab-ci.yml' do it 'has no jobs' do expect(build_names).to be_empty - expect(pipeline.errors.full_messages).to match_array(["No stages / jobs for this pipeline."]) + expect(pipeline.errors.full_messages).to match_array(['Pipeline will not run for the selected trigger. ' \ + 'The rules configuration prevented any jobs from being added to the pipeline.']) end end @@ -81,7 +83,8 @@ RSpec.describe 'Jobs/Test.gitlab-ci.yml' do it 'has no jobs' do expect(build_names).to be_empty - expect(pipeline.errors.full_messages).to match_array(["No stages / jobs for this pipeline."]) + expect(pipeline.errors.full_messages).to match_array(['Pipeline will not run for the selected trigger. ' \ + 'The rules configuration prevented any jobs from being added to the pipeline.']) end end end diff --git a/spec/lib/gitlab/ci/templates/npm_spec.rb b/spec/lib/gitlab/ci/templates/npm_spec.rb index 55fd4675f11..a949a7ccfb1 100644 --- a/spec/lib/gitlab/ci/templates/npm_spec.rb +++ b/spec/lib/gitlab/ci/templates/npm_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'npm.gitlab-ci.yml' do +RSpec.describe 'npm.gitlab-ci.yml', feature_category: :continuous_integration do subject(:template) { Gitlab::Template::GitlabCiYmlTemplate.find('npm') } describe 'the created pipeline' do @@ -43,7 +43,8 @@ RSpec.describe 'npm.gitlab-ci.yml' do shared_examples 'no pipeline created' do it 'does not create a pipeline because the only job (publish) is not created' do expect(build_names).to be_empty - expect(pipeline.errors.full_messages).to match_array(["No stages / jobs for this pipeline."]) + expect(pipeline.errors.full_messages).to match_array(['Pipeline will not run for the selected trigger. ' \ + 'The rules configuration prevented any jobs from being added to the pipeline.']) end end diff --git a/spec/lib/gitlab/ci/templates/terraform_latest_gitlab_ci_yaml_spec.rb b/spec/lib/gitlab/ci/templates/terraform_latest_gitlab_ci_yaml_spec.rb index 6ae51f9783b..a81f29d0d01 100644 --- a/spec/lib/gitlab/ci/templates/terraform_latest_gitlab_ci_yaml_spec.rb +++ b/spec/lib/gitlab/ci/templates/terraform_latest_gitlab_ci_yaml_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'Terraform.latest.gitlab-ci.yml' do +RSpec.describe 'Terraform.latest.gitlab-ci.yml', feature_category: :continuous_integration do before do allow(Gitlab::Template::GitlabCiYmlTemplate).to receive(:excluded_patterns).and_return([]) end @@ -66,7 +66,12 @@ RSpec.describe 'Terraform.latest.gitlab-ci.yml' do it 'does not create a branch pipeline', :aggregate_failures do expect(branch_build_names).to be_empty - expect(branch_pipeline.errors.full_messages).to match_array(["No stages / jobs for this pipeline."]) + expect(branch_pipeline.errors.full_messages).to match_array( + [ + 'Pipeline will not run for the selected trigger. ' \ + 'The rules configuration prevented any jobs from being added to the pipeline.' + ] + ) end end end diff --git a/spec/lib/gitlab/ci/templates/themekit_gitlab_ci_yaml_spec.rb b/spec/lib/gitlab/ci/templates/themekit_gitlab_ci_yaml_spec.rb index 157fd39f1cc..607db33f61a 100644 --- a/spec/lib/gitlab/ci/templates/themekit_gitlab_ci_yaml_spec.rb +++ b/spec/lib/gitlab/ci/templates/themekit_gitlab_ci_yaml_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'ThemeKit.gitlab-ci.yml' do +RSpec.describe 'ThemeKit.gitlab-ci.yml', feature_category: :continuous_integration do before do allow(Gitlab::Template::GitlabCiYmlTemplate).to receive(:excluded_patterns).and_return([]) end @@ -52,7 +52,8 @@ RSpec.describe 'ThemeKit.gitlab-ci.yml' do it 'has no jobs' do expect(build_names).to be_empty - expect(pipeline.errors.full_messages).to match_array(["No stages / jobs for this pipeline."]) + expect(pipeline.errors.full_messages).to match_array(['Pipeline will not run for the selected trigger. ' \ + 'The rules configuration prevented any jobs from being added to the pipeline.']) end end end diff --git a/spec/models/event_spec.rb b/spec/models/event_spec.rb index 667f3ddff72..f170eeb5841 100644 --- a/spec/models/event_spec.rb +++ b/spec/models/event_spec.rb @@ -102,7 +102,20 @@ RSpec.describe Event, feature_category: :users do end describe 'scopes' do - describe 'created_at' do + describe '.for_issue' do + let(:issue_event) { create(:event, :for_issue, project: project) } + let(:work_item_event) { create(:event, :for_work_item, project: project) } + + before do + create(:event, :for_design, project: project) + end + + it 'returns events for Issue and WorkItem target_type' do + expect(described_class.for_issue).to contain_exactly(issue_event, work_item_event) + end + end + + describe '.created_at' do it 'can find the right event' do time = 1.day.ago event = create(:event, created_at: time, project: project) diff --git a/spec/models/members/member_role_spec.rb b/spec/models/members/member_role_spec.rb index f9d6757bb90..b118a3c0968 100644 --- a/spec/models/members/member_role_spec.rb +++ b/spec/models/members/member_role_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe MemberRole do +RSpec.describe MemberRole, feature_category: :authentication_and_authorization do describe 'associations' do it { is_expected.to belong_to(:namespace) } it { is_expected.to have_many(:members) } @@ -14,6 +14,27 @@ RSpec.describe MemberRole do it { is_expected.to validate_presence_of(:namespace) } it { is_expected.to validate_presence_of(:base_access_level) } + context 'for attributes_locked_after_member_associated' do + context 'when assigned to member' do + it 'cannot be changed' do + member_role.save! + member_role.members << create(:project_member) + + expect(member_role).not_to be_valid + expect(member_role.errors.messages[:base]).to include( + s_("MemberRole|cannot be changed because it is already assigned to a user. "\ + "Please create a new Member Role instead") + ) + end + end + + context 'when not assigned to member' do + it 'can be changed' do + expect(member_role).to be_valid + end + end + end + context 'when for namespace' do let_it_be(:root_group) { create(:group) } diff --git a/spec/requests/api/import_github_spec.rb b/spec/requests/api/import_github_spec.rb index dce82f1cf37..ccf16434ad9 100644 --- a/spec/requests/api/import_github_spec.rb +++ b/spec/requests/api/import_github_spec.rb @@ -6,33 +6,35 @@ RSpec.describe API::ImportGithub, feature_category: :importers do let(:token) { "asdasd12345" } let(:provider) { :github } let(:access_params) { { github_access_token: token } } + let(:provider_username) { user.username } + let(:provider_user) { double('provider', login: provider_username).as_null_object } + let(:provider_repo) do + { + name: 'vim', + full_name: "#{provider_username}/vim", + owner: double('provider', login: provider_username), + description: 'provider', + private: false, + clone_url: 'https://fake.url/vim.git', + has_wiki: true + } + end - describe "POST /import/github" do - let(:user) { create(:user) } - let(:project) { create(:project) } - let(:provider_username) { user.username } - let(:provider_user) { double('provider', login: provider_username) } - let(:provider_repo) do - { - name: 'vim', - full_name: "#{provider_username}/vim", - owner: double('provider', login: provider_username), - description: 'provider', - private: false, - clone_url: 'https://fake.url/vim.git', - has_wiki: true - } - end + let(:client) { double('client', user: provider_user, repository: provider_repo) } - before do - Grape::Endpoint.before_each do |endpoint| - allow(endpoint).to receive(:client).and_return(double('client', user: provider_user, repository: provider_repo).as_null_object) - end + before do + Grape::Endpoint.before_each do |endpoint| + allow(endpoint).to receive(:client).and_return(client) end + end - after do - Grape::Endpoint.before_each nil - end + after do + Grape::Endpoint.before_each nil + end + + describe "POST /import/github" do + let_it_be(:user) { create(:user) } + let_it_be(:project) { create(:project) } it 'rejects requests when Github Importer is disabled' do stub_application_setting(import_sources: nil) @@ -150,4 +152,60 @@ RSpec.describe API::ImportGithub, feature_category: :importers do end end end + + describe 'POST /import/github/gists' do + let_it_be(:user) { create(:user) } + let(:params) { { personal_access_token: token } } + + context 'when gists import was started' do + before do + allow(Import::Github::GistsImportService) + .to receive(:new).with(user, client, access_params) + .and_return(double(execute: { status: :success })) + end + + it 'returns 202' do + post api('/import/github/gists', user), params: params + + expect(response).to have_gitlab_http_status(:accepted) + end + end + + context 'when gists import is in progress' do + before do + allow(Import::Github::GistsImportService) + .to receive(:new).with(user, client, access_params) + .and_return(double(execute: { status: :error, message: 'Import already in progress', http_status: :unprocessable_entity })) + end + + it 'returns 422 error' do + post api('/import/github/gists', user), params: params + + expect(response).to have_gitlab_http_status(:unprocessable_entity) + expect(json_response['errors']).to eq('Import already in progress') + end + end + + context 'when unauthenticated user' do + it 'returns 403 error' do + post api('/import/github/gists'), params: params + + expect(response).to have_gitlab_http_status(:unauthorized) + end + end + + context 'when rate limit reached' do + before do + allow(Import::Github::GistsImportService) + .to receive(:new).with(user, client, access_params) + .and_raise(Gitlab::GithubImport::RateLimitError) + end + + it 'returns 429 error' do + post api('/import/github/gists', user), params: params + + expect(response).to have_gitlab_http_status(:too_many_requests) + end + end + end end diff --git a/spec/requests/users_controller_spec.rb b/spec/requests/users_controller_spec.rb index 608284c05f3..11d8be24e06 100644 --- a/spec/requests/users_controller_spec.rb +++ b/spec/requests/users_controller_spec.rb @@ -464,6 +464,18 @@ RSpec.describe UsersController, feature_category: :user_management do expect(response.body).not_to be_empty end + it 'renders the correct url for issues and work items' do + work_item = create(:work_item, :task, project: project) + issue = create(:issue, project: project) + EventCreateService.new.open_issue(work_item, public_user) + EventCreateService.new.open_issue(issue, public_user) + + get user_calendar_activities_url public_user.username + + expect(response.body).to include(project_work_items_path(project, work_item.iid, iid_path: true)) + expect(response.body).to include(project_issue_path(project, issue)) + end + it 'avoids N+1 queries', :request_store do get user_calendar_activities_url public_user.username diff --git a/spec/services/ci/create_downstream_pipeline_service_spec.rb b/spec/services/ci/create_downstream_pipeline_service_spec.rb index bcdb2b4f796..6046f9b8e19 100644 --- a/spec/services/ci/create_downstream_pipeline_service_spec.rb +++ b/spec/services/ci/create_downstream_pipeline_service_spec.rb @@ -825,11 +825,13 @@ RSpec.describe Ci::CreateDownstreamPipelineService, '#execute', feature_category it 'does not create a pipeline and drops the bridge' do expect { subject }.not_to change(downstream_project.ci_pipelines, :count) expect(subject).to be_error - expect(subject.message).to match_array(["No stages / jobs for this pipeline."]) + expect(subject.message).to match_array(['Pipeline will not run for the selected trigger. ' \ + 'The rules configuration prevented any jobs from being added to the pipeline.']) expect(bridge.reload).to be_failed expect(bridge.failure_reason).to eq('downstream_pipeline_creation_failed') - expect(bridge.options[:downstream_errors]).to eq(['No stages / jobs for this pipeline.']) + expect(bridge.options[:downstream_errors]).to match_array(['Pipeline will not run for the selected trigger. ' \ + 'The rules configuration prevented any jobs from being added to the pipeline.']) end end diff --git a/spec/services/ci/create_pipeline_service/rules_spec.rb b/spec/services/ci/create_pipeline_service/rules_spec.rb index b866293393b..26bb8b7d006 100644 --- a/spec/services/ci/create_pipeline_service/rules_spec.rb +++ b/spec/services/ci/create_pipeline_service/rules_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true require 'spec_helper' -RSpec.describe Ci::CreatePipelineService, :yaml_processor_feature_flag_corectness do +RSpec.describe Ci::CreatePipelineService, :yaml_processor_feature_flag_corectness, feature_category: :pipeline_authoring do let(:project) { create(:project, :repository) } let(:user) { project.first_owner } let(:ref) { 'refs/heads/master' } @@ -1166,7 +1166,8 @@ RSpec.describe Ci::CreatePipelineService, :yaml_processor_feature_flag_corectnes let(:ref) { 'refs/heads/master' } it 'invalidates the pipeline with an empty jobs error' do - expect(pipeline.errors[:base]).to include('No stages / jobs for this pipeline.') + expect(pipeline.errors[:base]).to include('Pipeline will not run for the selected trigger. ' \ + 'The rules configuration prevented any jobs from being added to the pipeline.') expect(pipeline).not_to be_persisted end end diff --git a/spec/services/ci/create_pipeline_service_spec.rb b/spec/services/ci/create_pipeline_service_spec.rb index 8628e95ba80..3d143f1142a 100644 --- a/spec/services/ci/create_pipeline_service_spec.rb +++ b/spec/services/ci/create_pipeline_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Ci::CreatePipelineService, :yaml_processor_feature_flag_corectness, :clean_gitlab_redis_cache do +RSpec.describe Ci::CreatePipelineService, :yaml_processor_feature_flag_corectness, :clean_gitlab_redis_cache, feature_category: :continuous_integration do include ProjectForksHelper let_it_be_with_refind(:project) { create(:project, :repository) } @@ -684,7 +684,8 @@ RSpec.describe Ci::CreatePipelineService, :yaml_processor_feature_flag_corectnes result = execute_service expect(result).to be_error - expect(result.message).to eq('No stages / jobs for this pipeline.') + expect(result.message).to eq('Pipeline will not run for the selected trigger. ' \ + 'The rules configuration prevented any jobs from being added to the pipeline.') expect(result.payload).not_to be_persisted expect(Ci::Build.all).to be_empty expect(Ci::Pipeline.count).to eq(0) @@ -1423,9 +1424,11 @@ RSpec.describe Ci::CreatePipelineService, :yaml_processor_feature_flag_corectnes it 'does not create a detached merge request pipeline', :aggregate_failures do expect(response).to be_error - expect(response.message).to eq('No stages / jobs for this pipeline.') + expect(response.message).to eq('Pipeline will not run for the selected trigger. ' \ + 'The rules configuration prevented any jobs from being added to the pipeline.') expect(pipeline).not_to be_persisted - expect(pipeline.errors[:base]).to eq(['No stages / jobs for this pipeline.']) + expect(pipeline.errors[:base]).to eq(['Pipeline will not run for the selected trigger. ' \ + 'The rules configuration prevented any jobs from being added to the pipeline.']) end end end @@ -1633,7 +1636,8 @@ RSpec.describe Ci::CreatePipelineService, :yaml_processor_feature_flag_corectnes it 'does not create a detached merge request pipeline', :aggregate_failures do expect(response).to be_error - expect(response.message).to eq('No stages / jobs for this pipeline.') + expect(response.message).to eq('Pipeline will not run for the selected trigger. ' \ + 'The rules configuration prevented any jobs from being added to the pipeline.') expect(pipeline).not_to be_persisted end end @@ -1669,7 +1673,8 @@ RSpec.describe Ci::CreatePipelineService, :yaml_processor_feature_flag_corectnes it 'does not create a detached merge request pipeline', :aggregate_failures do expect(response).to be_error - expect(response.message).to eq('No stages / jobs for this pipeline.') + expect(response.message).to eq('Pipeline will not run for the selected trigger. ' \ + 'The rules configuration prevented any jobs from being added to the pipeline.') expect(pipeline).not_to be_persisted end end @@ -1697,7 +1702,8 @@ RSpec.describe Ci::CreatePipelineService, :yaml_processor_feature_flag_corectnes it 'does not create a detached merge request pipeline', :aggregate_failures do expect(response).to be_error - expect(response.message).to eq('No stages / jobs for this pipeline.') + expect(response.message).to eq('Pipeline will not run for the selected trigger. ' \ + 'The rules configuration prevented any jobs from being added to the pipeline.') expect(pipeline).not_to be_persisted end end @@ -1727,7 +1733,8 @@ RSpec.describe Ci::CreatePipelineService, :yaml_processor_feature_flag_corectnes it 'does not create a detached merge request pipeline', :aggregate_failures do expect(response).to be_error - expect(response.message).to eq('No stages / jobs for this pipeline.') + expect(response.message).to eq('Pipeline will not run for the selected trigger. ' \ + 'The rules configuration prevented any jobs from being added to the pipeline.') expect(pipeline).not_to be_persisted end end @@ -1755,7 +1762,8 @@ RSpec.describe Ci::CreatePipelineService, :yaml_processor_feature_flag_corectnes it 'does not create a detached merge request pipeline', :aggregate_failures do expect(response).to be_error - expect(response.message).to eq('No stages / jobs for this pipeline.') + expect(response.message).to eq('Pipeline will not run for the selected trigger. ' \ + 'The rules configuration prevented any jobs from being added to the pipeline.') expect(pipeline).not_to be_persisted end end diff --git a/spec/services/import/github/gists_import_service_spec.rb b/spec/services/import/github/gists_import_service_spec.rb index c5d73e6479d..4edb38145ed 100644 --- a/spec/services/import/github/gists_import_service_spec.rb +++ b/spec/services/import/github/gists_import_service_spec.rb @@ -3,15 +3,18 @@ require 'spec_helper' RSpec.describe Import::Github::GistsImportService, feature_category: :importer do - subject(:import) { described_class.new(user, params) } + subject(:import) { described_class.new(user, client, params) } let_it_be(:user) { create(:user) } let(:params) { { github_access_token: 'token' } } let(:import_status) { instance_double('Gitlab::GithubGistsImport::Status') } + let(:client) { Gitlab::GithubImport::Client.new(params[:github_access_token]) } + let(:octokit_user) { { login: 'user_login' } } describe '#execute', :aggregate_failures do before do allow(Gitlab::GithubGistsImport::Status).to receive(:new).and_return(import_status) + allow(client.octokit).to receive(:user).and_return(octokit_user) end context 'when import in progress' do @@ -43,5 +46,24 @@ RSpec.describe Import::Github::GistsImportService, feature_category: :importer d expect(import.execute).to eq({ status: :success }) end end + + context 'when user token is invalid' do + before do + allow(client.octokit).to receive(:user).and_raise(Octokit::Unauthorized) + allow(import_status).to receive(:started?).and_return(false) + end + + let(:expected_result) do + { + http_status: 401, + message: 'Access denied to the GitHub account.', + status: :error + } + end + + it 'returns 401 error' do + expect(import.execute).to eq(expected_result) + end + end end end |