diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-18 03:09:21 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-18 03:09:21 +0000 |
commit | cfaf98a3b214c773f058ed9648314e4f147bbba4 (patch) | |
tree | c02a6855511a65696890c21270da5911896beff2 | |
parent | c48065a833f9ead3357c48ea077165c15e8d585c (diff) | |
download | gitlab-ce-cfaf98a3b214c773f058ed9648314e4f147bbba4.tar.gz |
Add latest changes from gitlab-org/gitlab@master
46 files changed, 299 insertions, 430 deletions
diff --git a/app/assets/javascripts/diffs/components/diff_view.vue b/app/assets/javascripts/diffs/components/diff_view.vue index 8747678e69b..84429f62a1c 100644 --- a/app/assets/javascripts/diffs/components/diff_view.vue +++ b/app/assets/javascripts/diffs/components/diff_view.vue @@ -51,6 +51,14 @@ export default { ); }, }, + methods: { + showCommentLeft(line) { + return !this.inline || line.left; + }, + showCommentRight(line) { + return !this.inline || (line.right && !line.left); + }, + }, userColorScheme: window.gon.user_color_scheme, }; </script> @@ -93,10 +101,7 @@ export default { :class="line.commentRowClasses" class="diff-grid-comments diff-tr notes_holder" > - <div - v-if="!inline || (line.left && line.left.discussions.length)" - class="diff-td notes-content parallel old" - > + <div v-if="showCommentLeft(line)" class="diff-td notes-content parallel old"> <diff-comment-cell v-if="line.left" :line="line.left" @@ -106,10 +111,7 @@ export default { line-position="left" /> </div> - <div - v-if="!inline || (line.right && line.right.discussions.length)" - class="diff-td notes-content parallel new" - > + <div v-if="showCommentRight(line)" class="diff-td notes-content parallel new"> <diff-comment-cell v-if="line.right" :line="line.right" diff --git a/app/controllers/projects/merge_requests/diffs_controller.rb b/app/controllers/projects/merge_requests/diffs_controller.rb index 15e16687c02..7fbeac12644 100644 --- a/app/controllers/projects/merge_requests/diffs_controller.rb +++ b/app/controllers/projects/merge_requests/diffs_controller.rb @@ -69,7 +69,7 @@ class Projects::MergeRequests::DiffsController < Projects::MergeRequests::Applic } options = additional_attributes.merge( - diff_view: Feature.enabled?(:unified_diff_lines, @merge_request.project, default_enabled: true) ? "inline" : diff_view, + diff_view: unified_diff_lines_view_type(@merge_request.project), merge_ref_head_diff: render_merge_ref_head_diff? ) diff --git a/app/controllers/projects/merge_requests_controller.rb b/app/controllers/projects/merge_requests_controller.rb index b6a6e1e775a..f2b41294a85 100644 --- a/app/controllers/projects/merge_requests_controller.rb +++ b/app/controllers/projects/merge_requests_controller.rb @@ -481,7 +481,7 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo def endpoint_metadata_url(project, merge_request) params = request.query_parameters - params[:view] = cookies[:diff_view] if params[:view].blank? && cookies[:diff_view].present? + params[:view] = unified_diff_lines_view_type(project) if Feature.enabled?(:default_merge_ref_for_diffs, project) params = params.merge(diff_head: true) diff --git a/app/graphql/types/commit_type.rb b/app/graphql/types/commit_type.rb index 12d294bcf04..c24b47f08ef 100644 --- a/app/graphql/types/commit_type.rb +++ b/app/graphql/types/commit_type.rb @@ -44,12 +44,5 @@ module Types null: true, description: 'Pipelines of the commit ordered latest first', resolver: Resolvers::CommitPipelinesResolver - - field :latest_pipeline, - type: Types::Ci::PipelineType, - null: true, - deprecated: { reason: 'Use `pipelines`', milestone: '12.5' }, - description: 'Latest pipeline of the commit', - resolver: Resolvers::CommitPipelinesResolver.last end end diff --git a/app/graphql/types/grafana_integration_type.rb b/app/graphql/types/grafana_integration_type.rb index 7db733fc62a..6625af36f82 100644 --- a/app/graphql/types/grafana_integration_type.rb +++ b/app/graphql/types/grafana_integration_type.rb @@ -16,13 +16,5 @@ module Types description: 'Timestamp of the issue\'s creation' field :updated_at, Types::TimeType, null: false, description: 'Timestamp of the issue\'s last activity' - - field :token, GraphQL::STRING_TYPE, null: false, - deprecated: { reason: 'Plain text token has been masked for security reasons', milestone: '12.7' }, - description: 'API token for the Grafana integration' - - def token - object.masked_token - end end end diff --git a/app/graphql/types/issue_type.rb b/app/graphql/types/issue_type.rb index 7973cca24ba..49c84f75e1a 100644 --- a/app/graphql/types/issue_type.rb +++ b/app/graphql/types/issue_type.rb @@ -98,11 +98,6 @@ module Types field :task_completion_status, Types::TaskCompletionStatus, null: false, description: 'Task completion status of the issue' - field :designs, Types::DesignManagement::DesignCollectionType, null: true, - method: :design_collection, - deprecated: { reason: 'Use `designCollection`', milestone: '12.2' }, - description: 'The designs associated with this issue' - field :design_collection, Types::DesignManagement::DesignCollectionType, null: true, description: 'Collection of design images associated with this issue' diff --git a/app/graphql/types/merge_request_type.rb b/app/graphql/types/merge_request_type.rb index aef04f3517a..e68d6706c43 100644 --- a/app/graphql/types/merge_request_type.rb +++ b/app/graphql/types/merge_request_type.rb @@ -88,9 +88,6 @@ module Types description: 'Rebase commit SHA of the merge request' field :rebase_in_progress, GraphQL::BOOLEAN_TYPE, method: :rebase_in_progress?, null: false, calls_gitaly: true, description: 'Indicates if there is a rebase currently in progress for the merge request' - field :merge_commit_message, GraphQL::STRING_TYPE, method: :default_merge_commit_message, null: true, - deprecated: { reason: 'Use `defaultMergeCommitMessage`', milestone: '11.8' }, - description: 'Default merge commit message of the merge request' field :default_merge_commit_message, GraphQL::STRING_TYPE, null: true, description: 'Default merge commit message of the merge request' field :merge_ongoing, GraphQL::BOOLEAN_TYPE, method: :merge_ongoing?, null: false, diff --git a/app/helpers/diff_helper.rb b/app/helpers/diff_helper.rb index 69a2efebb1f..d6d06434590 100644 --- a/app/helpers/diff_helper.rb +++ b/app/helpers/diff_helper.rb @@ -203,6 +203,14 @@ module DiffHelper set_secure_cookie(:diff_view, params.delete(:view), type: CookiesHelper::COOKIE_TYPE_PERMANENT) if params[:view].present? end + def unified_diff_lines_view_type(project) + if Feature.enabled?(:unified_diff_lines, project, default_enabled: true) + 'inline' + else + diff_view + end + end + private def diff_btn(title, name, selected) diff --git a/changelogs/unreleased/jdb-fix-comment-cell-inline.yml b/changelogs/unreleased/jdb-fix-comment-cell-inline.yml new file mode 100644 index 00000000000..6fc5dafe528 --- /dev/null +++ b/changelogs/unreleased/jdb-fix-comment-cell-inline.yml @@ -0,0 +1,5 @@ +--- +title: Fix comment cells not rendering in unified component inline view +merge_request: 47693 +author: +type: fixed diff --git a/changelogs/unreleased/lm-add-ci-lint-warnings.yml b/changelogs/unreleased/lm-add-ci-lint-warnings.yml new file mode 100644 index 00000000000..d595e3c2433 --- /dev/null +++ b/changelogs/unreleased/lm-add-ci-lint-warnings.yml @@ -0,0 +1,5 @@ +--- +title: Adds warnings to API response for /lint +merge_request: 47037 +author: +type: added diff --git a/changelogs/unreleased/ph-280579-fixDiffMetadataStartupJS.yml b/changelogs/unreleased/ph-280579-fixDiffMetadataStartupJS.yml new file mode 100644 index 00000000000..ee1faca8310 --- /dev/null +++ b/changelogs/unreleased/ph-280579-fixDiffMetadataStartupJS.yml @@ -0,0 +1,5 @@ +--- +title: Fixed diff metadata endpoint being called twice +merge_request: 47265 +author: +type: fixed diff --git a/doc/api/graphql/index.md b/doc/api/graphql/index.md index e0557db6567..91917ea47a4 100644 --- a/doc/api/graphql/index.md +++ b/doc/api/graphql/index.md @@ -82,6 +82,10 @@ The process is as follows: release post (at or prior to X.11 and X.5 releases). 1. Fields meeting criteria are removed in X.0 or X.6. +### List of removed items + +View the [fields, enums, and other items we removed](removed_items.md) from the GraphQL API. + ## Available queries The GraphQL API includes the following queries at the root level: diff --git a/doc/api/graphql/reference/gitlab_schema.graphql b/doc/api/graphql/reference/gitlab_schema.graphql index 7de0b97b160..58f7d8ecdcf 100644 --- a/doc/api/graphql/reference/gitlab_schema.graphql +++ b/doc/api/graphql/reference/gitlab_schema.graphql @@ -2849,26 +2849,6 @@ type Commit { id: ID! """ - Latest pipeline of the commit. Deprecated in 12.5: Use `pipelines` - """ - latestPipeline( - """ - Filter pipelines by the ref they are run for - """ - ref: String - - """ - Filter pipelines by the sha of the commit they are run for - """ - sha: String - - """ - Filter pipelines by their status - """ - status: PipelineStatusEnum - ): Pipeline @deprecated(reason: "Use `pipelines`. Deprecated in 12.5") - - """ Raw commit message """ message: String @@ -7746,11 +7726,6 @@ type EpicIssue implements CurrentUserTodos & Noteable { designCollection: DesignCollection """ - The designs associated with this issue. Deprecated in 12.2: Use `designCollection` - """ - designs: DesignCollection @deprecated(reason: "Use `designCollection`. Deprecated in 12.2") - - """ Indicates discussion is locked on the issue """ discussionLocked: Boolean! @@ -8555,11 +8530,6 @@ type GrafanaIntegration { id: ID! """ - API token for the Grafana integration. Deprecated in 12.7: Plain text token has been masked for security reasons - """ - token: String! @deprecated(reason: "Plain text token has been masked for security reasons. Deprecated in 12.7") - - """ Timestamp of the issue's last activity """ updatedAt: Time! @@ -10373,11 +10343,6 @@ type Issue implements CurrentUserTodos & Noteable { designCollection: DesignCollection """ - The designs associated with this issue. Deprecated in 12.2: Use `designCollection` - """ - designs: DesignCollection @deprecated(reason: "Use `designCollection`. Deprecated in 12.2") - - """ Indicates discussion is locked on the issue """ discussionLocked: Boolean! @@ -12491,11 +12456,6 @@ type MergeRequest implements CurrentUserTodos & Noteable { ): LabelConnection """ - Default merge commit message of the merge request. Deprecated in 11.8: Use `defaultMergeCommitMessage` - """ - mergeCommitMessage: String @deprecated(reason: "Use `defaultMergeCommitMessage`. Deprecated in 11.8") - - """ SHA of the merge request commit (set once merged) """ mergeCommitSha: String @@ -21323,11 +21283,6 @@ input Timeframe { type Timelog { """ - Timestamp of when the time tracked was spent at. Deprecated in 12.10: Use `spentAt` - """ - date: Time! @deprecated(reason: "Use `spentAt`. Deprecated in 12.10") - - """ The issue that logged time was added to """ issue: Issue diff --git a/doc/api/graphql/reference/gitlab_schema.json b/doc/api/graphql/reference/gitlab_schema.json index bb42b0765eb..de3f9c2665f 100644 --- a/doc/api/graphql/reference/gitlab_schema.json +++ b/doc/api/graphql/reference/gitlab_schema.json @@ -7793,49 +7793,6 @@ "deprecationReason": null }, { - "name": "latestPipeline", - "description": "Latest pipeline of the commit. Deprecated in 12.5: Use `pipelines`", - "args": [ - { - "name": "status", - "description": "Filter pipelines by their status", - "type": { - "kind": "ENUM", - "name": "PipelineStatusEnum", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "ref", - "description": "Filter pipelines by the ref they are run for", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "sha", - "description": "Filter pipelines by the sha of the commit they are run for", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "Pipeline", - "ofType": null - }, - "isDeprecated": true, - "deprecationReason": "Use `pipelines`. Deprecated in 12.5" - }, - { "name": "message", "description": "Raw commit message", "args": [ @@ -21469,20 +21426,6 @@ "deprecationReason": null }, { - "name": "designs", - "description": "The designs associated with this issue. Deprecated in 12.2: Use `designCollection`", - "args": [ - - ], - "type": { - "kind": "OBJECT", - "name": "DesignCollection", - "ofType": null - }, - "isDeprecated": true, - "deprecationReason": "Use `designCollection`. Deprecated in 12.2" - }, - { "name": "discussionLocked", "description": "Indicates discussion is locked on the issue", "args": [ @@ -23704,24 +23647,6 @@ "deprecationReason": null }, { - "name": "token", - "description": "API token for the Grafana integration. Deprecated in 12.7: Plain text token has been masked for security reasons", - "args": [ - - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": true, - "deprecationReason": "Plain text token has been masked for security reasons. Deprecated in 12.7" - }, - { "name": "updatedAt", "description": "Timestamp of the issue's last activity", "args": [ @@ -28370,20 +28295,6 @@ "deprecationReason": null }, { - "name": "designs", - "description": "The designs associated with this issue. Deprecated in 12.2: Use `designCollection`", - "args": [ - - ], - "type": { - "kind": "OBJECT", - "name": "DesignCollection", - "ofType": null - }, - "isDeprecated": true, - "deprecationReason": "Use `designCollection`. Deprecated in 12.2" - }, - { "name": "discussionLocked", "description": "Indicates discussion is locked on the issue", "args": [ @@ -34205,20 +34116,6 @@ "deprecationReason": null }, { - "name": "mergeCommitMessage", - "description": "Default merge commit message of the merge request. Deprecated in 11.8: Use `defaultMergeCommitMessage`", - "args": [ - - ], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": true, - "deprecationReason": "Use `defaultMergeCommitMessage`. Deprecated in 11.8" - }, - { "name": "mergeCommitSha", "description": "SHA of the merge request commit (set once merged)", "args": [ @@ -61925,24 +61822,6 @@ "description": null, "fields": [ { - "name": "date", - "description": "Timestamp of when the time tracked was spent at. Deprecated in 12.10: Use `spentAt`", - "args": [ - - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Time", - "ofType": null - } - }, - "isDeprecated": true, - "deprecationReason": "Use `spentAt`. Deprecated in 12.10" - }, - { "name": "issue", "description": "The issue that logged time was added to", "args": [ diff --git a/doc/api/graphql/reference/index.md b/doc/api/graphql/reference/index.md index 9d43874dee8..c46f12bcdcd 100644 --- a/doc/api/graphql/reference/index.md +++ b/doc/api/graphql/reference/index.md @@ -15,6 +15,8 @@ fields and methods on a model are available via GraphQL. CAUTION: **Caution:** Fields that are deprecated are marked with **{warning-solid}**. +Items (fields, enums, etc) that have been removed according to our [deprecation process](../index.md#deprecation-process) can be found +in [Removed Items](../removed_items.md). ## Object types @@ -472,7 +474,6 @@ Represents the code coverage summary for a project. | `description` | String | Description of the commit message | | `descriptionHtml` | String | The GitLab Flavored Markdown rendering of `description` | | `id` | ID! | ID (global ID) of the commit | -| `latestPipeline` **{warning-solid}** | Pipeline | **Deprecated:** Use `pipelines`. Deprecated in 12.5 | | `message` | String | Raw commit message | | `pipelines` | PipelineConnection | Pipelines of the commit ordered latest first | | `sha` | String! | SHA1 ID of the commit | @@ -1290,7 +1291,6 @@ Relationship between an epic and an issue. | `description` | String | Description of the issue | | `descriptionHtml` | String | The GitLab Flavored Markdown rendering of `description` | | `designCollection` | DesignCollection | Collection of design images associated with this issue | -| `designs` **{warning-solid}** | DesignCollection | **Deprecated:** Use `designCollection`. Deprecated in 12.2 | | `discussionLocked` | Boolean! | Indicates discussion is locked on the issue | | `discussions` | DiscussionConnection! | All discussions on this noteable | | `downvotes` | Int! | Number of downvotes the issue has received | @@ -1400,7 +1400,6 @@ Autogenerated return type of EpicTreeReorder. | `enabled` | Boolean! | Indicates whether Grafana integration is enabled | | `grafanaUrl` | String! | URL for the Grafana host for the Grafana integration | | `id` | ID! | Internal ID of the Grafana integration | -| `token` **{warning-solid}** | String! | **Deprecated:** Plain text token has been masked for security reasons. Deprecated in 12.7 | | `updatedAt` | Time! | Timestamp of the issue's last activity | ### Group @@ -1579,7 +1578,6 @@ Represents a recorded measurement (object count) for the Admins. | `description` | String | Description of the issue | | `descriptionHtml` | String | The GitLab Flavored Markdown rendering of `description` | | `designCollection` | DesignCollection | Collection of design images associated with this issue | -| `designs` **{warning-solid}** | DesignCollection | **Deprecated:** Use `designCollection`. Deprecated in 12.2 | | `discussionLocked` | Boolean! | Indicates discussion is locked on the issue | | `discussions` | DiscussionConnection! | All discussions on this noteable | | `downvotes` | Int! | Number of downvotes the issue has received | @@ -1900,7 +1898,6 @@ Autogenerated return type of MarkAsSpamSnippet. | `iid` | String! | Internal ID of the merge request | | `inProgressMergeCommitSha` | String | Commit SHA of the merge request if merge is in progress | | `labels` | LabelConnection | Labels of the merge request | -| `mergeCommitMessage` **{warning-solid}** | String | **Deprecated:** Use `defaultMergeCommitMessage`. Deprecated in 11.8 | | `mergeCommitSha` | String | SHA of the merge request commit (set once merged) | | `mergeError` | String | Error message due to a merge error | | `mergeOngoing` | Boolean! | Indicates if a merge is currently occurring | @@ -3167,7 +3164,6 @@ Represents a historically accurate report about the timebox. | Field | Type | Description | | ----- | ---- | ----------- | -| `date` **{warning-solid}** | Time! | **Deprecated:** Use `spentAt`. Deprecated in 12.10 | | `issue` | Issue | The issue that logged time was added to | | `note` | Note | The note where the quick action to add the logged time was executed | | `spentAt` | Time | Timestamp of when the time tracked was spent at | diff --git a/doc/api/graphql/removed_items.md b/doc/api/graphql/removed_items.md new file mode 100644 index 00000000000..f05b23495bb --- /dev/null +++ b/doc/api/graphql/removed_items.md @@ -0,0 +1,17 @@ +# GraphQL API removed items + +GraphQL is a versionless API, unlike the REST API. +Occasionally, items have to be updated or removed from the GraphQL API. +According to our [process for removing items](index.md#deprecation-process), here are the items that have been removed. + +## GitLab 13.6 + +Fields removed in [GitLab 13.6](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/44866): + +| Field name | GraphQL type | Deprecated in | Use instead | +| -------------------- | -------------------- | ------------- | -------------------------- | +| `date` | `Timelog` **(STARTER)** | 12.10 | `spentAt` | +| `designs` | `Issue`, `EpicIssue` | 12.2 | `designCollection` | +| `latestPipeline` | `Commit` | 12.5 | `pipelines` | +| `mergeCommitMessage` | `MergeRequest` | 11.8 | `latestMergeCommitMessage` | +| `token` | `GrafanaIntegration` | 12.7 | None. Plaintext tokens no longer supported for security reasons. | diff --git a/doc/api/lint.md b/doc/api/lint.md index a1e68e70b8a..24de4a24ff1 100644 --- a/doc/api/lint.md +++ b/doc/api/lint.md @@ -36,7 +36,20 @@ Example responses: ```json { "status": "valid", - "errors": [] + "errors": [], + "warnings": [] + } + ``` + +- Valid content with warnings: + + ```json + { + "status": "valid", + "errors": [], + "warnings": ["jobs:job may allow multiple pipelines to run for a single action due to + `rules:when` clause with no `workflow:rules` - read more: + https://docs.gitlab.com/ee/ci/troubleshooting.html#pipeline-warnings"] } ``` @@ -47,7 +60,8 @@ Example responses: "status": "invalid", "errors": [ "variables config should be a hash of key value pairs" - ] + ], + "warnings": [] } ``` diff --git a/doc/ci/interactive_web_terminal/index.md b/doc/ci/interactive_web_terminal/index.md index 125e7dabecf..a131d21039d 100644 --- a/doc/ci/interactive_web_terminal/index.md +++ b/doc/ci/interactive_web_terminal/index.md @@ -16,7 +16,7 @@ is deployed, some [security precautions](../../administration/integration/termin taken to protect the users. NOTE: **Note:** -[Shared runners on GitLab.com](../quick_start/README.md#shared-runners) do not +[Shared runners on GitLab.com](../runners/README.md#shared-runners) do not provide an interactive web terminal. Follow [this issue](https://gitlab.com/gitlab-org/gitlab/-/issues/24674) for progress on adding support. For groups and projects hosted on GitLab.com, interactive web diff --git a/doc/ci/quick_start/README.md b/doc/ci/quick_start/README.md index 9db42538092..f3e60fae13a 100644 --- a/doc/ci/quick_start/README.md +++ b/doc/ci/quick_start/README.md @@ -5,229 +5,153 @@ info: To determine the technical writer assigned to the Stage/Group associated w type: reference --- -# Getting started with GitLab CI/CD +# Get started with GitLab CI/CD -GitLab offers a [continuous integration](https://about.gitlab.com/stages-devops-lifecycle/continuous-integration/) service. For each commit or push to trigger your CI -[pipeline](../pipelines/index.md), you must: +Use this document to get started with +GitLab [continuous integration](https://about.gitlab.com/stages-devops-lifecycle/continuous-integration/). -- Add a [`.gitlab-ci.yml` file](#creating-a-gitlab-ciyml-file) to your repository's root directory. -- Ensure your project is configured to use a [runner](#configuring-a-runner). +Before you start, make sure you have: -The `.gitlab-ci.yml` file defines the structure and order of the pipelines, and determines: +- A project in GitLab that you would like to use CI/CD for. +- Maintainer or owner access for the project. -- What to execute using [GitLab Runner](https://docs.gitlab.com/runner/). -- What decisions to make when specific conditions are encountered. For example, when a process succeeds or fails. +If you are migrating from another CI/CD tool, view this documentation: -A simple pipeline commonly has -three [stages](../yaml/README.md#stages): +- [Migrate from CircleCI](../migration/circleci.md). +- [Migrate from Jenkins](../migration/jenkins.md). -- `build` -- `test` -- `deploy` +## CI/CD process overview -You do not need to use all three stages; stages with no jobs are ignored. +To use GitLab CI/CD: -The pipeline appears under the project's **CI/CD > Pipelines** page. If everything runs OK (no non-zero -return values), you get a green check mark associated with the commit. This makes it easy to see -whether a commit caused any of the tests to fail before you even look at the job (test) log. Many projects use -GitLab's CI service to run the test suite, so developers get immediate feedback if they broke -something. +1. [Ensure you have runners available](#ensure-you-have-runners-available) to run your jobs. + If you don't have a runner, [install GitLab Runner](https://docs.gitlab.com/runner/install/) + and [register a runner](https://docs.gitlab.com/runner/register/) for your instance, project, or group. +1. [Create a `.gitlab-ci.yml` file](#create-a-gitlab-ciyml-file) + at the root of your repository. This file is where you define your CI/CD jobs. -It's also common to use pipelines to automatically deploy -tested code to staging and production environments. +When you commit the file to your repository, the runner runs your jobs. +The job results [are displayed in a pipeline](#view-the-status-of-your-pipeline-and-jobs). -If you're already familiar with general CI/CD concepts, you can review which -[pipeline architectures](../pipelines/pipeline_architectures.md) can be used -in your projects. If you're coming over to GitLab from Jenkins, you can check out -our [reference](../migration/jenkins.md) for converting your pre-existing pipelines -over to our format. +### Ensure you have runners available -This guide assumes that you have: +In GitLab, runners are agents that run your CI/CD jobs. -- A working GitLab instance of version 8.0+ or are using - [GitLab.com](https://gitlab.com). -- A project in GitLab that you would like to use CI for. -- Maintainer or owner access to the project +You might already have runners available for your project, including +[shared runners](../runners/README.md#shared-runners), which are +available to all projects in your GitLab instance. -Let's break it down to pieces and work on solving the GitLab CI/CD puzzle. +To view available runners: -## Creating a `.gitlab-ci.yml` file +- Go to **Settings > CI/CD** and expand **Runners**. -Before you create `.gitlab-ci.yml` let's first explain in brief what this is -all about. +As long as you have at least one runner that's active, with a green circle next to it, +you have a runner available to process your jobs. -### What is `.gitlab-ci.yml` +If no runners are listed on the **Runners** page in the UI, you or an administrator +must [install GitLab Runner](https://docs.gitlab.com/runner/install/) and +[register](https://docs.gitlab.com/runner/register/) at least one runner. -The `.gitlab-ci.yml` file is where you configure what CI does with your project. -It lives in the root of your repository. +If you are testing CI/CD, you can install GitLab Runner and register runners on your local machine. +When your CI/CD jobs run, they will run on your local machine. -On any push to your repository, GitLab will look for the `.gitlab-ci.yml` -file and start jobs on _runners_ according to the contents of the file, -for that commit. +### Create a `.gitlab-ci.yml` file -Because `.gitlab-ci.yml` is in the repository and is version controlled, old -versions still build successfully, forks can easily make use of CI, branches can -have different pipelines and jobs, and you have a single source of truth for CI. -You can read more about the reasons why we are using `.gitlab-ci.yml` [in our -blog about it](https://about.gitlab.com/blog/2015/05/06/why-were-replacing-gitlab-ci-jobs-with-gitlab-ci-dot-yml/). +The `.gitlab-ci.yml` file is a [YAML](https://en.wikipedia.org/wiki/YAML) file where +you configure specific instructions for GitLab CI/CD. -### Creating a simple `.gitlab-ci.yml` file +In this file, you define: -You need to create a file named `.gitlab-ci.yml` in the root directory of your -repository. This is a [YAML](https://en.wikipedia.org/wiki/YAML) file -so you have to pay extra attention to indentation. Always use spaces, not tabs. +- The structure and order of jobs that the runner should execute. +- The decisions the runner should make when specific conditions are encountered. -Below is an example for a Ruby on Rails project: +For example, you might want to run a suite of tests when you commit to +any branch except `master`. When you commit to `master`, you want +to run the same suite, but also publish your application. -```yaml -default: - image: ruby:2.5 - before_script: - - apt-get update - - apt-get install -y sqlite3 libsqlite3-dev nodejs - - ruby -v - - which ruby - - gem install bundler --no-document - - bundle install --jobs $(nproc) "${FLAGS[@]}" +All of this is defined in the `.gitlab-ci.yml` file. -rspec: - script: - - bundle exec rspec +To create a `.gitlab-ci.yml` file: -rubocop: - script: - - bundle exec rubocop -``` +1. Go to **Project overview > Details**. +1. Above the file list, select the branch you want to commit to, + click the plus icon, then select **New file**: -This is the simplest possible configuration that will work for most Ruby -applications: +  -1. Define two jobs `rspec` and `rubocop` (the names are arbitrary) with - different commands to be executed. -1. Before every job, the commands defined by `before_script` are executed. +1. For the **File name** type `.gitlab-ci.yml` and in the larger window, + paste this sample code: -The `.gitlab-ci.yml` file defines sets of jobs with constraints of how and when -they should be run. The jobs are defined as top-level elements with a name (in -our case `rspec` and `rubocop`) and always have to contain the `script` keyword. -Jobs are used to create jobs, which are then picked by -[runners](../runners/README.md) and executed within the environment of the runner. + ```yaml + build-job: + stage: build + script: + - echo "Hello, $GITLAB_USER_LOGIN!" -What is important is that each job is run independently from each other. + test-job1: + stage: test + script: + - echo "This job tests something" -If you want to check whether the `.gitlab-ci.yml` of your project is valid, there is a -[CI Lint tool](../lint.md) available in every project. + test-job2: + stage: test + script: + - echo "This job tests something, but takes more time than test-job1." + - echo "After the echo commands complete, it runs the sleep command for 20 seconds" + - echo "which simulates a test that runs 20 seconds longer than test-job1" + - sleep 20 -You can use the [CI/CD configuration visualization](../yaml/visualization.md) to -see a graphical representation of your `.gitlab-ci.yml`. + deploy-prod: + stage: deploy + script: + - echo "This job deploys something from the $CI_COMMIT_BRANCH branch." + ``` -For more information and a complete `.gitlab-ci.yml` syntax, please read -[the reference documentation on `.gitlab-ci.yml`](../yaml/README.md). + `$GITLAB_USER_LOGIN` and `$CI_COMMIT_BRANCH` are + [predefined variables](../variables/predefined_variables.md) + that populate when the job runs. -TIP: **Tip:** -A GitLab team member has made an [unofficial visual pipeline editor](https://unofficial.gitlab.tools/visual-pipelines/). -There is a [plan to make it an official part of GitLab](https://gitlab.com/groups/gitlab-org/-/epics/4069) -in the future, but it's available for anyone who wants to try it at the above link. +1. Click **Commit changes**. -### Push `.gitlab-ci.yml` to GitLab +The pipeline starts when the commit is committed. -After you've created a `.gitlab-ci.yml`, you should add it to your Git repository -and push it to GitLab. +#### `.gitlab-ci.yml` tips -```shell -git add .gitlab-ci.yml -git commit -m "Add .gitlab-ci.yml" -git push origin master -``` +- If you want the runner to use a Docker image to run the jobs, edit the `.gitlab-ci.yml` file + to include your image name: -Now if you go to the **Pipelines** page you will see that the pipeline is -pending. + ```yaml + default: + image: ruby:2.7.2 + ``` -NOTE: **Note:** -If you have a [mirrored repository where GitLab pulls from](../../user/project/repository/repository_mirroring.md#pulling-from-a-remote-repository), -you may need to enable pipeline triggering in your project's -**Settings > Repository > Pull from a remote repository > Trigger pipelines for mirror updates**. + This command tells the runner to use a Ruby image from Docker Hub. -You can also go to the **Commits** page and notice the little pause icon next -to the commit SHA. +- To validate your `.gitlab-ci.yml` file, use the + [CI Lint tool](../lint.md), which is available in every project. +- You can also use [CI/CD configuration visualization](../yaml/visualization.md) to + view a graphical representation of your `.gitlab-ci.yml` file. +- For the complete `.gitlab-ci.yml` syntax, see + [the `.gitlab-ci.yml` reference topic](../yaml/README.md). - +### View the status of your pipeline and jobs -Clicking on it you will be directed to the jobs page for that specific commit. +When you committed your changes, a pipeline started. - +To view your pipeline: -Notice that there is a pending job which is named after what we wrote in -`.gitlab-ci.yml`. "stuck" indicates that there is no runner configured -yet for this job. +- Go **CI/CD > Pipelines**. -The next step is to configure a runner so that it picks the pending jobs. + A pipeline with three stages should be displayed: -## Configuring a runner +  -In GitLab, runners run the jobs that you define in `.gitlab-ci.yml`. A runner -can be a virtual machine, a VPS, a bare-metal machine, a Docker container, or -even a cluster of containers. GitLab and the runner communicate through an API, -so the only requirement is that the runner's machine has network access to the -GitLab server. +- To view a visual representation of your pipeline, click the pipeline ID. -A runner can be specific to a certain project or serve multiple projects in -GitLab. If it serves all projects, it's called a _shared runner_. +  -Find more information about runners in the -[runner](../runners/README.md) documentation. +- To view details of a job, click the job name, for example, `deploy-prod`. -The official runner supported by GitLab is written in Go. -View [the documentation](https://docs.gitlab.com/runner/). +  -For a runner to be available in GitLab, you must: - -1. [Install GitLab Runner](https://docs.gitlab.com/runner/install/). -1. [Register a runner for your group or project](https://docs.gitlab.com/runner/register/). - -When a runner is available, you can view it by -clicking **Settings > CI/CD** and expanding **Runners**. - - - -### Shared runners - -If you use [GitLab.com](https://gitlab.com/), you can use the **shared runners** -provided by GitLab. - -These are special virtual machines that run on GitLab's infrastructure and can -build any project. - -To enable shared runners, go to your project's or group's -**Settings > CI/CD** and click **Enable shared runners**. - -[Read more about shared runners](../runners/README.md#shared-runners). - -## Viewing the status of your pipeline and jobs - -After configuring the runner successfully, you should see the status of your -last commit change from _pending_ to either _running_, _success_ or _failed_. - -You can view all pipelines by going to the **Pipelines** page in your project. - - - -Or you can view all jobs, by going to the **Pipelines ➔ Jobs** page. - - - -By clicking on a job's status, you will be able to see the log of that job. -This is important to diagnose why a job failed or acted differently than -you expected. - - - -You are also able to view the status of any commit in the various pages in -GitLab, such as **Commits** and **Merge requests**. - -## Additional resources - -Visit the [examples README](../examples/README.md) to see a list of examples using GitLab -CI with various languages. - -For help making your new pipelines faster and more efficient, see the -[pipeline efficiency documentation](../pipelines/pipeline_efficiency.md). +If the job status is `stuck`, check to ensure a runner is probably configured for the project. diff --git a/doc/ci/quick_start/img/build_log.png b/doc/ci/quick_start/img/build_log.png Binary files differdeleted file mode 100644 index 16698629edc..00000000000 --- a/doc/ci/quick_start/img/build_log.png +++ /dev/null diff --git a/doc/ci/quick_start/img/builds_status.png b/doc/ci/quick_start/img/builds_status.png Binary files differdeleted file mode 100644 index b4aeeb988d2..00000000000 --- a/doc/ci/quick_start/img/builds_status.png +++ /dev/null diff --git a/doc/ci/quick_start/img/job_details_v13_6.png b/doc/ci/quick_start/img/job_details_v13_6.png Binary files differnew file mode 100644 index 00000000000..e94287f90ba --- /dev/null +++ b/doc/ci/quick_start/img/job_details_v13_6.png diff --git a/doc/ci/quick_start/img/new_commit.png b/doc/ci/quick_start/img/new_commit.png Binary files differdeleted file mode 100644 index 507eb93ac0c..00000000000 --- a/doc/ci/quick_start/img/new_commit.png +++ /dev/null diff --git a/doc/ci/quick_start/img/new_file_v13_6.png b/doc/ci/quick_start/img/new_file_v13_6.png Binary files differnew file mode 100644 index 00000000000..c71923f9b90 --- /dev/null +++ b/doc/ci/quick_start/img/new_file_v13_6.png diff --git a/doc/ci/quick_start/img/pipeline_graph_v13_6.png b/doc/ci/quick_start/img/pipeline_graph_v13_6.png Binary files differnew file mode 100644 index 00000000000..fcf7e02d1f3 --- /dev/null +++ b/doc/ci/quick_start/img/pipeline_graph_v13_6.png diff --git a/doc/ci/quick_start/img/pipelines_status.png b/doc/ci/quick_start/img/pipelines_status.png Binary files differdeleted file mode 100644 index 39a77a26b25..00000000000 --- a/doc/ci/quick_start/img/pipelines_status.png +++ /dev/null diff --git a/doc/ci/quick_start/img/single_commit_status_pending.png b/doc/ci/quick_start/img/single_commit_status_pending.png Binary files differdeleted file mode 100644 index ffc7054d3b0..00000000000 --- a/doc/ci/quick_start/img/single_commit_status_pending.png +++ /dev/null diff --git a/doc/ci/quick_start/img/three_stages_v13_6.png b/doc/ci/quick_start/img/three_stages_v13_6.png Binary files differnew file mode 100644 index 00000000000..a6c049e3e6c --- /dev/null +++ b/doc/ci/quick_start/img/three_stages_v13_6.png diff --git a/lib/api/lint.rb b/lib/api/lint.rb index 01faa41cb19..58181adaa93 100644 --- a/lib/api/lint.rb +++ b/lib/api/lint.rb @@ -17,9 +17,9 @@ module API status 200 response = if error.blank? - { status: 'valid', errors: [] } + { status: 'valid', errors: [], warnings: result.warnings } else - { status: 'invalid', errors: [error] } + { status: 'invalid', errors: [error], warnings: result.warnings } end response.tap do |response| diff --git a/lib/gitlab/ci/templates/Security/Dependency-Scanning.gitlab-ci.yml b/lib/gitlab/ci/templates/Security/Dependency-Scanning.gitlab-ci.yml index 3789f0edc1c..b534dad9593 100644 --- a/lib/gitlab/ci/templates/Security/Dependency-Scanning.gitlab-ci.yml +++ b/lib/gitlab/ci/templates/Security/Dependency-Scanning.gitlab-ci.yml @@ -28,11 +28,8 @@ dependency_scanning: .ds-analyzer: extends: dependency_scanning allow_failure: true - rules: - - if: $DEPENDENCY_SCANNING_DISABLED - when: never - - if: $CI_COMMIT_BRANCH && - $GITLAB_FEATURES =~ /\bdependency_scanning\b/ + # `rules` must be overridden explicitly by each child job + # see https://gitlab.com/gitlab-org/gitlab/-/issues/218444 script: - /analyzer run diff --git a/lib/gitlab/ci/templates/Security/SAST.gitlab-ci.yml b/lib/gitlab/ci/templates/Security/SAST.gitlab-ci.yml index a51cb61da6d..671e2346fcb 100644 --- a/lib/gitlab/ci/templates/Security/SAST.gitlab-ci.yml +++ b/lib/gitlab/ci/templates/Security/SAST.gitlab-ci.yml @@ -30,10 +30,8 @@ sast: .sast-analyzer: extends: sast allow_failure: true - rules: - - if: $SAST_DISABLED - when: never - - if: $CI_COMMIT_BRANCH + # `rules` must be overridden explicitly by each child job + # see https://gitlab.com/gitlab-org/gitlab/-/issues/218444 script: - /analyzer run diff --git a/lib/gitlab/ci/templates/Security/Secret-Detection.gitlab-ci.yml b/lib/gitlab/ci/templates/Security/Secret-Detection.gitlab-ci.yml index 6ebff102ccb..466981594cf 100644 --- a/lib/gitlab/ci/templates/Security/Secret-Detection.gitlab-ci.yml +++ b/lib/gitlab/ci/templates/Security/Secret-Detection.gitlab-ci.yml @@ -14,6 +14,8 @@ variables: stage: test image: "$SECURE_ANALYZERS_PREFIX/secrets:$SECRETS_ANALYZER_VERSION" services: [] + # `rules` must be overridden explicitly by each child job + # see https://gitlab.com/gitlab-org/gitlab/-/issues/218444 artifacts: reports: secret_detection: gl-secret-detection-report.json diff --git a/lib/gitlab/graphql/docs/templates/default.md.haml b/lib/gitlab/graphql/docs/templates/default.md.haml index ec052943589..97df4233905 100644 --- a/lib/gitlab/graphql/docs/templates/default.md.haml +++ b/lib/gitlab/graphql/docs/templates/default.md.haml @@ -14,6 +14,8 @@ CAUTION: **Caution:** Fields that are deprecated are marked with **{warning-solid}**. + Items (fields, enums, etc) that have been removed according to our [deprecation process](../index.md#deprecation-process) can be found + in [Removed Items](../removed_items.md). \ :plain diff --git a/package.json b/package.json index 2bdf7f644c9..cc1f4eb1bc8 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@gitlab/visual-review-tools": "1.6.1", "@rails/actioncable": "^6.0.3-3", "@rails/ujs": "^6.0.3-2", - "@sourcegraph/code-host-integration": "0.0.50", + "@sourcegraph/code-host-integration": "0.0.52", "@toast-ui/editor": "^2.5.0", "@toast-ui/vue-editor": "^2.5.0", "apollo-cache-inmemory": "^1.6.6", diff --git a/spec/controllers/projects/merge_requests_controller_spec.rb b/spec/controllers/projects/merge_requests_controller_spec.rb index d7d1278159b..f159f0e6099 100644 --- a/spec/controllers/projects/merge_requests_controller_spec.rb +++ b/spec/controllers/projects/merge_requests_controller_spec.rb @@ -95,7 +95,8 @@ RSpec.describe Projects::MergeRequestsController do project, merge_request, 'json', - diff_head: true)) + diff_head: true, + view: 'inline')) end end diff --git a/spec/frontend/diffs/components/diff_view_spec.js b/spec/frontend/diffs/components/diff_view_spec.js index 20ac844fe00..4d90112d8f6 100644 --- a/spec/frontend/diffs/components/diff_view_spec.js +++ b/spec/frontend/diffs/components/diff_view_spec.js @@ -49,12 +49,29 @@ describe('DiffView', () => { expect(wrapper.find(DiffExpansionCell).exists()).toBe(true); }); - it('renders a comment row', () => { - const wrapper = createWrapper({ - diffLines: [{ renderCommentRow: true, left: { lineDraft: {} } }], - }); - expect(wrapper.find(DiffCommentCell).exists()).toBe(true); - }); + it.each` + type | side | container | sides | total + ${'parallel'} | ${'left'} | ${'.old'} | ${{ left: { lineDraft: {} }, right: { lineDraft: {} } }} | ${2} + ${'parallel'} | ${'right'} | ${'.new'} | ${{ left: { lineDraft: {} }, right: { lineDraft: {} } }} | ${2} + ${'inline'} | ${'left'} | ${'.old'} | ${{ left: { lineDraft: {} } }} | ${1} + ${'inline'} | ${'right'} | ${'.new'} | ${{ right: { lineDraft: {} } }} | ${1} + ${'inline'} | ${'left'} | ${'.old'} | ${{ left: { lineDraft: {} }, right: { lineDraft: {} } }} | ${1} + `( + 'renders a $type comment row with comment cell on $side', + ({ type, container, sides, total }) => { + const wrapper = createWrapper({ + diffLines: [{ renderCommentRow: true, ...sides }], + inline: type === 'inline', + }); + expect(wrapper.findAll(DiffCommentCell).length).toBe(total); + expect( + wrapper + .find(container) + .find(DiffCommentCell) + .exists(), + ).toBe(true); + }, + ); it('renders a draft row', () => { const wrapper = createWrapper({ diff --git a/spec/graphql/types/commit_type_spec.rb b/spec/graphql/types/commit_type_spec.rb index d222287270d..e9bc7f6bb94 100644 --- a/spec/graphql/types/commit_type_spec.rb +++ b/spec/graphql/types/commit_type_spec.rb @@ -10,7 +10,7 @@ RSpec.describe GitlabSchema.types['Commit'] do it 'contains attributes related to commit' do expect(described_class).to have_graphql_fields( :id, :sha, :title, :description, :description_html, :message, :title_html, :authored_date, - :author_name, :author_gravatar, :author, :web_url, :web_path, :latest_pipeline, + :author_name, :author_gravatar, :author, :web_url, :web_path, :pipelines, :signature_html ) end diff --git a/spec/graphql/types/grafana_integration_type_spec.rb b/spec/graphql/types/grafana_integration_type_spec.rb index b4658db08d7..816264c36c8 100644 --- a/spec/graphql/types/grafana_integration_type_spec.rb +++ b/spec/graphql/types/grafana_integration_type_spec.rb @@ -7,7 +7,6 @@ RSpec.describe GitlabSchema.types['GrafanaIntegration'] do %i[ id grafana_url - token enabled created_at updated_at diff --git a/spec/graphql/types/issue_type_spec.rb b/spec/graphql/types/issue_type_spec.rb index 9133143cf56..558fc479af1 100644 --- a/spec/graphql/types/issue_type_spec.rb +++ b/spec/graphql/types/issue_type_spec.rb @@ -17,7 +17,7 @@ RSpec.describe GitlabSchema.types['Issue'] do fields = %i[id iid title description state reference author assignees updated_by participants labels milestone due_date confidential discussion_locked upvotes downvotes user_notes_count user_discussions_count web_path web_url relative_position emails_disabled subscribed time_estimate total_time_spent human_time_estimate human_total_time_spent closed_at created_at updated_at task_completion_status - designs design_collection alert_management_alert severity current_user_todos moved moved_to] + design_collection alert_management_alert severity current_user_todos moved moved_to] fields.each do |field_name| expect(described_class).to have_graphql_field(field_name) diff --git a/spec/graphql/types/merge_request_type_spec.rb b/spec/graphql/types/merge_request_type_spec.rb index a7512506100..8800250b103 100644 --- a/spec/graphql/types/merge_request_type_spec.rb +++ b/spec/graphql/types/merge_request_type_spec.rb @@ -21,7 +21,7 @@ RSpec.describe GitlabSchema.types['MergeRequest'] do diff_refs diff_stats diff_stats_summary force_remove_source_branch merge_status in_progress_merge_commit_sha merge_error allow_collaboration should_be_rebased rebase_commit_sha - rebase_in_progress merge_commit_message default_merge_commit_message + rebase_in_progress default_merge_commit_message merge_ongoing mergeable_discussions_state web_url source_branch_exists target_branch_exists upvotes downvotes head_pipeline pipelines task_completion_status diff --git a/spec/helpers/diff_helper_spec.rb b/spec/helpers/diff_helper_spec.rb index 3580959fde0..c085c3bdbd9 100644 --- a/spec/helpers/diff_helper_spec.rb +++ b/spec/helpers/diff_helper_spec.rb @@ -358,4 +358,30 @@ RSpec.describe DiffHelper do expect(diff_file_path_text(diff_file, max: 10)).to eq("...open.rb") end end + + describe 'unified_diff_lines_view_type' do + before do + controller.params[:view] = 'parallel' + end + + describe 'unified diffs enabled' do + before do + stub_feature_flags(unified_diff_lines: true) + end + + it 'returns inline view' do + expect(helper.unified_diff_lines_view_type(project)).to eq 'inline' + end + end + + describe 'unified diffs disabled' do + before do + stub_feature_flags(unified_diff_lines: false) + end + + it 'returns parallel view' do + expect(helper.unified_diff_lines_view_type(project)).to eq :parallel + end + end + end end diff --git a/spec/requests/api/graphql/project/grafana_integration_spec.rb b/spec/requests/api/graphql/project/grafana_integration_spec.rb index 688959e622d..9b24698f40c 100644 --- a/spec/requests/api/graphql/project/grafana_integration_spec.rb +++ b/spec/requests/api/graphql/project/grafana_integration_spec.rb @@ -45,7 +45,6 @@ RSpec.describe 'Getting Grafana Integration' do it_behaves_like 'a working graphql query' - specify { expect(integration_data['token']).to eql grafana_integration.masked_token } specify { expect(integration_data['grafanaUrl']).to eql grafana_integration.grafana_url } specify do diff --git a/spec/requests/api/graphql/project/issue/designs/notes_spec.rb b/spec/requests/api/graphql/project/issue/designs/notes_spec.rb index e25453510d5..a671ddc7ab1 100644 --- a/spec/requests/api/graphql/project/issue/designs/notes_spec.rb +++ b/spec/requests/api/graphql/project/issue/designs/notes_spec.rb @@ -30,7 +30,7 @@ RSpec.describe 'Getting designs related to an issue' do post_graphql(query(note_fields), current_user: nil) - designs_data = graphql_data['project']['issue']['designs']['designs'] + designs_data = graphql_data['project']['issue']['designCollection']['designs'] design_data = designs_data['nodes'].first note_data = design_data['notes']['nodes'].first @@ -56,7 +56,7 @@ RSpec.describe 'Getting designs related to an issue' do 'issue', { iid: design.issue.iid.to_s }, query_graphql_field( - 'designs', {}, design_node + 'designCollection', {}, design_node ) ) ) diff --git a/spec/requests/api/lint_spec.rb b/spec/requests/api/lint_spec.rb index 94ec83e2dce..aecbcfb5b5a 100644 --- a/spec/requests/api/lint_spec.rb +++ b/spec/requests/api/lint_spec.rb @@ -9,12 +9,13 @@ RSpec.describe API::Lint do File.read(Rails.root.join('spec/support/gitlab_stubs/gitlab_ci.yml')) end - it 'passes validation' do + it 'passes validation without warnings or errors' do post api('/ci/lint'), params: { content: yaml_content } expect(response).to have_gitlab_http_status(:ok) expect(json_response).to be_an Hash expect(json_response['status']).to eq('valid') + expect(json_response['warnings']).to eq([]) expect(json_response['errors']).to eq([]) end @@ -26,6 +27,20 @@ RSpec.describe API::Lint do end end + context 'with valid .gitlab-ci.yaml with warnings' do + let(:yaml_content) { { job: { script: 'ls', rules: [{ when: 'always' }] } }.to_yaml } + + it 'passes validation but returns warnings' do + post api('/ci/lint'), params: { content: yaml_content } + + expect(response).to have_gitlab_http_status(:ok) + expect(json_response['status']).to eq('valid') + expect(json_response['warnings']).not_to be_empty + expect(json_response['status']).to eq('valid') + expect(json_response['errors']).to eq([]) + end + end + context 'with an invalid .gitlab_ci.yml' do context 'with invalid syntax' do let(:yaml_content) { 'invalid content' } @@ -35,6 +50,7 @@ RSpec.describe API::Lint do expect(response).to have_gitlab_http_status(:ok) expect(json_response['status']).to eq('invalid') + expect(json_response['warnings']).to eq([]) expect(json_response['errors']).to eq(['Invalid configuration format']) end @@ -54,6 +70,7 @@ RSpec.describe API::Lint do expect(response).to have_gitlab_http_status(:ok) expect(json_response['status']).to eq('invalid') + expect(json_response['warnings']).to eq([]) expect(json_response['errors']).to eq(['jobs config should contain at least one visible job']) end @@ -82,7 +99,18 @@ RSpec.describe API::Lint do let(:project) { create(:project, :repository) } let(:dry_run) { nil } - RSpec.shared_examples 'valid config' do + RSpec.shared_examples 'valid config with warnings' do + it 'passes validation with warnings' do + ci_lint + + expect(response).to have_gitlab_http_status(:ok) + expect(json_response['valid']).to eq(true) + expect(json_response['errors']).to eq([]) + expect(json_response['warnings']).not_to be_empty + end + end + + RSpec.shared_examples 'valid config without warnings' do it 'passes validation' do ci_lint @@ -94,6 +122,7 @@ RSpec.describe API::Lint do expect(json_response).to be_an Hash expect(json_response['merged_yaml']).to eq(expected_yaml) expect(json_response['valid']).to eq(true) + expect(json_response['warnings']).to eq([]) expect(json_response['errors']).to eq([]) end end @@ -105,6 +134,7 @@ RSpec.describe API::Lint do expect(response).to have_gitlab_http_status(:ok) expect(json_response['merged_yaml']).to eq(yaml_content) expect(json_response['valid']).to eq(false) + expect(json_response['warnings']).to eq([]) expect(json_response['errors']).to eq(['jobs config should contain at least one visible job']) end end @@ -157,6 +187,7 @@ RSpec.describe API::Lint do expect(response).to have_gitlab_http_status(:ok) expect(json_response['merged_yaml']).to eq(nil) expect(json_response['valid']).to eq(false) + expect(json_response['warnings']).to eq([]) expect(json_response['errors']).to eq(['Insufficient permissions to create a new pipeline']) end end @@ -186,7 +217,7 @@ RSpec.describe API::Lint do ) end - it_behaves_like 'valid config' + it_behaves_like 'valid config without warnings' end end end @@ -242,13 +273,19 @@ RSpec.describe API::Lint do context 'when running as dry run' do let(:dry_run) { true } - it_behaves_like 'valid config' + it_behaves_like 'valid config without warnings' end context 'when running static validation' do let(:dry_run) { false } - it_behaves_like 'valid config' + it_behaves_like 'valid config without warnings' + end + + context 'With warnings' do + let(:yaml_content) { { job: { script: 'ls', rules: [{ when: 'always' }] } }.to_yaml } + + it_behaves_like 'valid config with warnings' end end diff --git a/spec/requests/git_http_spec.rb b/spec/requests/git_http_spec.rb index a3bfa7ea33c..dc735e3714d 100644 --- a/spec/requests/git_http_spec.rb +++ b/spec/requests/git_http_spec.rb @@ -433,7 +433,7 @@ RSpec.describe 'Git HTTP requests' do let(:path) { "#{redirect.path}.git" } it 'downloads get status 200 for redirects' do - clone_get(path, {}) + clone_get(path) expect(response).to have_gitlab_http_status(:ok) end @@ -465,7 +465,7 @@ RSpec.describe 'Git HTTP requests' do path: "/#{path}/info/refs?service=git-upload-pack" }) - clone_get(path, env) + clone_get(path, **env) expect(response).to have_gitlab_http_status(:forbidden) end @@ -493,7 +493,7 @@ RSpec.describe 'Git HTTP requests' do it "rejects pulls with 401 Unauthorized for unknown projects (no project existence information leak)" do user.block - download('doesnt/exist.git', env) do |response| + download('doesnt/exist.git', **env) do |response| expect(response).to have_gitlab_http_status(:unauthorized) end end @@ -693,7 +693,7 @@ RSpec.describe 'Git HTTP requests' do end it 'downloads get status 200' do - clone_get(path, env) + clone_get(path, **env) expect(response).to have_gitlab_http_status(:ok) end @@ -745,7 +745,7 @@ RSpec.describe 'Git HTTP requests' do # We know for sure it is not an information leak since pulls using # the build token must be allowed. it "rejects pushes with 403 Forbidden" do - push_get(path, env) + push_get(path, **env) expect(response).to have_gitlab_http_status(:forbidden) expect(response.body).to eq(git_access_error(:auth_upload)) @@ -754,7 +754,7 @@ RSpec.describe 'Git HTTP requests' do # We are "authenticated" as CI using a valid token here. But we are # not authorized to see any other project, so return "not found". it "rejects pulls for other project with 404 Not Found" do - clone_get("#{other_project.full_path}.git", env) + clone_get("#{other_project.full_path}.git", **env) expect(response).to have_gitlab_http_status(:not_found) expect(response.body).to eq(git_access_error(:project_not_found)) @@ -777,7 +777,7 @@ RSpec.describe 'Git HTTP requests' do let(:project) { create(:project) } it 'rejects pulls with 404 Not Found' do - clone_get path, env + clone_get(path, **env) expect(response).to have_gitlab_http_status(:not_found) expect(response.body).to eq(git_access_error(:no_repo)) @@ -785,7 +785,7 @@ RSpec.describe 'Git HTTP requests' do end it 'rejects pushes with 403 Forbidden' do - push_get path, env + push_get(path, **env) expect(response).to have_gitlab_http_status(:forbidden) expect(response.body).to eq(git_access_error(:auth_upload)) @@ -889,7 +889,7 @@ RSpec.describe 'Git HTTP requests' do end it "responds with status 200" do - clone_get(path, env) do |response| + clone_get(path, **env) do |response| expect(response).to have_gitlab_http_status(:ok) end end @@ -913,7 +913,7 @@ RSpec.describe 'Git HTTP requests' do end it 'blocks git access when the user did not accept terms', :aggregate_failures do - clone_get(path, env) do |response| + clone_get(path, **env) do |response| expect(response).to have_gitlab_http_status(:forbidden) end @@ -932,7 +932,7 @@ RSpec.describe 'Git HTTP requests' do end it 'allows clones' do - clone_get(path, env) do |response| + clone_get(path, **env) do |response| expect(response).to have_gitlab_http_status(:ok) end end diff --git a/yarn.lock b/yarn.lock index a62939b98ad..a2e89886d6d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1148,10 +1148,10 @@ dependencies: "@sinonjs/commons" "^1.7.0" -"@sourcegraph/code-host-integration@0.0.50": - version "0.0.50" - resolved "https://registry.yarnpkg.com/@sourcegraph/code-host-integration/-/code-host-integration-0.0.50.tgz#3f91be4c1b117efbf3d49c73033a6b1880db1c70" - integrity sha512-Hf4JeXDnqxOpW8lrkmgzKCYKklQhS6f87j4EPxK//UdjV7W7rtBhsxr6RQqdV2VdVaVCLQW2tfA/tkm0zDk8CQ== +"@sourcegraph/code-host-integration@0.0.52": + version "0.0.52" + resolved "https://registry.yarnpkg.com/@sourcegraph/code-host-integration/-/code-host-integration-0.0.52.tgz#3668364647b9248a0c43d738f7b046c551311338" + integrity sha512-HYmiGuQ3XOQHJIQaRv63Wcdl6y1rgryBrCLzJd/mG5gkkhydTqBuf3wWFKgfL3PCm026OrjXu4PvOYU1fCTZJQ== "@szmarczak/http-timer@^1.1.2": version "1.1.2" |