summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-05-15 00:10:46 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-05-15 00:10:46 +0000
commitd0ba8fad6dd850a76848a5032e7380a6db66748e (patch)
tree3fde17650968919f601592ebea17865d2c58b48a
parent80088b7f88992a64ef5253d57838b0b3463ce8b1 (diff)
downloadgitlab-ce-d0ba8fad6dd850a76848a5032e7380a6db66748e.tar.gz
Add latest changes from gitlab-org/gitlab@master
-rw-r--r--.gitlab/ci/rails.gitlab-ci.yml1
-rw-r--r--app/graphql/types/packages/metadata_type.rb4
-rw-r--r--app/graphql/types/packages/nuget/metadatum_type.rb19
-rw-r--r--app/graphql/types/packages/package_type.rb2
-rw-r--r--app/helpers/ci/pipelines_helper.rb3
-rw-r--r--app/policies/packages/nuget/metadatum_policy.rb8
-rw-r--r--changelogs/unreleased/285467-package-registry-graphql-api-5.yml5
-rw-r--r--changelogs/unreleased/three-stage-pipeline-template.yml5
-rw-r--r--doc/api/graphql/reference/index.md20
-rw-r--r--lib/gitlab/ci/templates/Getting-started.yml39
-rw-r--r--locale/gitlab.pot9
-rwxr-xr-xscripts/validate_migration_timestamps24
-rw-r--r--spec/fixtures/api/schemas/graphql/packages/package_details.json1
-rw-r--r--spec/fixtures/api/schemas/graphql/packages/package_nuget_metadata.json19
-rw-r--r--spec/graphql/types/packages/maven/metadatum_type_spec.rb13
-rw-r--r--spec/graphql/types/packages/nuget/metadatum_type_spec.rb13
-rw-r--r--spec/requests/api/graphql/packages/nuget_spec.rb74
17 files changed, 256 insertions, 3 deletions
diff --git a/.gitlab/ci/rails.gitlab-ci.yml b/.gitlab/ci/rails.gitlab-ci.yml
index 834ba040501..4a3cbf89edb 100644
--- a/.gitlab/ci/rails.gitlab-ci.yml
+++ b/.gitlab/ci/rails.gitlab-ci.yml
@@ -341,6 +341,7 @@ db:check-schema:
- .rails:rules:ee-mr-and-default-branch-only
script:
- source scripts/schema_changed.sh
+ - scripts/validate_migration_timestamps
db:check-migrations:
extends:
diff --git a/app/graphql/types/packages/metadata_type.rb b/app/graphql/types/packages/metadata_type.rb
index b439adf3767..94880cb9b22 100644
--- a/app/graphql/types/packages/metadata_type.rb
+++ b/app/graphql/types/packages/metadata_type.rb
@@ -6,7 +6,7 @@ module Types
graphql_name 'PackageMetadata'
description 'Represents metadata associated with a Package'
- possible_types ::Types::Packages::Composer::MetadatumType, ::Types::Packages::Conan::MetadatumType, ::Types::Packages::Maven::MetadatumType
+ possible_types ::Types::Packages::Composer::MetadatumType, ::Types::Packages::Conan::MetadatumType, ::Types::Packages::Maven::MetadatumType, ::Types::Packages::Nuget::MetadatumType
def self.resolve_type(object, context)
case object
@@ -16,6 +16,8 @@ module Types
::Types::Packages::Conan::MetadatumType
when ::Packages::Maven::Metadatum
::Types::Packages::Maven::MetadatumType
+ when ::Packages::Nuget::Metadatum
+ ::Types::Packages::Nuget::MetadatumType
else
# NOTE: This method must be kept in sync with `PackageWithoutVersionsType#metadata`,
# which must never produce data that this discriminator cannot handle.
diff --git a/app/graphql/types/packages/nuget/metadatum_type.rb b/app/graphql/types/packages/nuget/metadatum_type.rb
new file mode 100644
index 00000000000..63fae2fb197
--- /dev/null
+++ b/app/graphql/types/packages/nuget/metadatum_type.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+module Types
+ module Packages
+ module Nuget
+ class MetadatumType < BaseObject
+ graphql_name 'NugetMetadata'
+ description 'Nuget metadata'
+
+ authorize :read_package
+
+ field :id, ::Types::GlobalIDType[::Packages::Nuget::Metadatum], null: false, description: 'ID of the metadatum.'
+ field :license_url, GraphQL::STRING_TYPE, null: false, description: 'License URL of the Nuget package.'
+ field :project_url, GraphQL::STRING_TYPE, null: false, description: 'Project URL of the Nuget package.'
+ field :icon_url, GraphQL::STRING_TYPE, null: false, description: 'Icon URL of the Nuget package.'
+ end
+ end
+ end
+end
diff --git a/app/graphql/types/packages/package_type.rb b/app/graphql/types/packages/package_type.rb
index 659af4a7057..b349b655fa5 100644
--- a/app/graphql/types/packages/package_type.rb
+++ b/app/graphql/types/packages/package_type.rb
@@ -47,6 +47,8 @@ module Types
object.conan_metadatum
when 'maven'
object.maven_metadatum
+ when 'nuget'
+ object.nuget_metadatum
else
nil
end
diff --git a/app/helpers/ci/pipelines_helper.rb b/app/helpers/ci/pipelines_helper.rb
index cabb43f45fd..f42cd53ae3a 100644
--- a/app/helpers/ci/pipelines_helper.rb
+++ b/app/helpers/ci/pipelines_helper.rb
@@ -50,10 +50,9 @@ module Ci
{ name: 'Gradle', logo: image_path('illustrations/logos/gradle.svg') },
{ name: 'Grails', logo: image_path('illustrations/logos/grails.svg') },
{ name: 'dotNET', logo: image_path('illustrations/logos/dotnet.svg') },
- { name: 'Rails', logo: image_path('illustrations/logos/rails.svg') },
{ name: 'Julia', logo: image_path('illustrations/logos/julia.svg') },
{ name: 'Laravel', logo: image_path('illustrations/logos/laravel.svg') },
- { name: 'Latex', logo: image_path('illustrations/logos/latex.svg') },
+ { name: 'LaTeX', logo: image_path('illustrations/logos/latex.svg') },
{ name: 'Maven', logo: image_path('illustrations/logos/maven.svg') },
{ name: 'Mono', logo: image_path('illustrations/logos/mono.svg') },
{ name: 'Nodejs', logo: image_path('illustrations/logos/node_js.svg') },
diff --git a/app/policies/packages/nuget/metadatum_policy.rb b/app/policies/packages/nuget/metadatum_policy.rb
new file mode 100644
index 00000000000..cdf1283c11a
--- /dev/null
+++ b/app/policies/packages/nuget/metadatum_policy.rb
@@ -0,0 +1,8 @@
+# frozen_string_literal: true
+module Packages
+ module Nuget
+ class MetadatumPolicy < BasePolicy
+ delegate { @subject.package }
+ end
+ end
+end
diff --git a/changelogs/unreleased/285467-package-registry-graphql-api-5.yml b/changelogs/unreleased/285467-package-registry-graphql-api-5.yml
new file mode 100644
index 00000000000..c390ae88310
--- /dev/null
+++ b/changelogs/unreleased/285467-package-registry-graphql-api-5.yml
@@ -0,0 +1,5 @@
+---
+title: Add nuget metadata type to Package GraphQl type
+merge_request: 61695
+author:
+type: added
diff --git a/changelogs/unreleased/three-stage-pipeline-template.yml b/changelogs/unreleased/three-stage-pipeline-template.yml
new file mode 100644
index 00000000000..223375f3019
--- /dev/null
+++ b/changelogs/unreleased/three-stage-pipeline-template.yml
@@ -0,0 +1,5 @@
+---
+title: Add 3 stage pipeline template
+merge_request: 61762
+author:
+type: added
diff --git a/doc/api/graphql/reference/index.md b/doc/api/graphql/reference/index.md
index 4acc051e3c4..62234caf97d 100644
--- a/doc/api/graphql/reference/index.md
+++ b/doc/api/graphql/reference/index.md
@@ -10458,6 +10458,19 @@ four standard [pagination arguments](#connection-pagination-arguments):
| <a id="notepermissionsrepositionnote"></a>`repositionNote` | [`Boolean!`](#boolean) | Indicates the user can perform `reposition_note` on this resource. |
| <a id="notepermissionsresolvenote"></a>`resolveNote` | [`Boolean!`](#boolean) | Indicates the user can perform `resolve_note` on this resource. |
+### `NugetMetadata`
+
+Nuget metadata.
+
+#### Fields
+
+| Name | Type | Description |
+| ---- | ---- | ----------- |
+| <a id="nugetmetadataiconurl"></a>`iconUrl` | [`String!`](#string) | Icon URL of the Nuget package. |
+| <a id="nugetmetadataid"></a>`id` | [`PackagesNugetMetadatumID!`](#packagesnugetmetadatumid) | ID of the metadatum. |
+| <a id="nugetmetadatalicenseurl"></a>`licenseUrl` | [`String!`](#string) | License URL of the Nuget package. |
+| <a id="nugetmetadataprojecturl"></a>`projectUrl` | [`String!`](#string) | Project URL of the Nuget package. |
+
### `OncallParticipantType`
The rotation participant and color palette.
@@ -15025,6 +15038,12 @@ A `PackagesMavenMetadatumID` is a global ID. It is encoded as a string.
An example `PackagesMavenMetadatumID` is: `"gid://gitlab/Packages::Maven::Metadatum/1"`.
+### `PackagesNugetMetadatumID`
+
+A `PackagesNugetMetadatumID` is a global ID. It is encoded as a string.
+
+An example `PackagesNugetMetadatumID` is: `"gid://gitlab/Packages::Nuget::Metadatum/1"`.
+
### `PackagesPackageFileID`
A `PackagesPackageFileID` is a global ID. It is encoded as a string.
@@ -15161,6 +15180,7 @@ One of:
- [`ComposerMetadata`](#composermetadata)
- [`ConanMetadata`](#conanmetadata)
- [`MavenMetadata`](#mavenmetadata)
+- [`NugetMetadata`](#nugetmetadata)
#### `VulnerabilityDetail`
diff --git a/lib/gitlab/ci/templates/Getting-started.yml b/lib/gitlab/ci/templates/Getting-started.yml
new file mode 100644
index 00000000000..4dc88418671
--- /dev/null
+++ b/lib/gitlab/ci/templates/Getting-started.yml
@@ -0,0 +1,39 @@
+# This is a sample GitLab CI/CD configuration file that should run without any modifications.
+# It demonstrates a basic 3 stage CI/CD pipeline. Instead of real tests or scripts,
+# it uses echo commands to simulate the pipeline execution.
+#
+# A pipeline is composed of independent jobs that run scripts, grouped into stages.
+# Stages run in sequential order, but jobs within stages run in parallel.
+#
+# For more information, see: https://docs.gitlab.com/ee/ci/yaml/README.html#stages
+
+stages: # List of stages for jobs, and their order of execution
+ - build
+ - test
+ - deploy
+
+build-job: # This job runs in the build stage, which runs first.
+ stage: build
+ script:
+ - echo "Compiling the code..."
+ - echo "Compile complete.
+
+unit-test-job: # This job runs in the test stage.
+ stage: test # It only starts when the job in the build stage completes successfully.
+ script:
+ - echo "Running unit tests... This will take about 60 seconds."
+ - sleep 60
+ - echo "Code coverage is 90%"
+
+lint-test-job: # This job also runs in the test stage.
+ stage: test # It can run at the same time as unit-test-job (in parallel).
+ script:
+ - echo "Linting code... This will take about 10 seconds."
+ - sleep 10
+ - echo "No lint issues found."
+
+deploy-job: # This job runs in the deploy stage.
+ stage: deploy # It only runs when *both* jobs in the test stage complete successfully.
+ script:
+ - echo "Deploying application..."
+ - echo "Application successfully deployed."
diff --git a/locale/gitlab.pot b/locale/gitlab.pot
index f54303ad457..310ad4e87e0 100644
--- a/locale/gitlab.pot
+++ b/locale/gitlab.pot
@@ -5129,6 +5129,9 @@ msgstr ""
msgid "Billing|An error occurred while removing a billable member"
msgstr ""
+msgid "Billing|Cannot remove user"
+msgstr ""
+
msgid "Billing|Direct memberships"
msgstr ""
@@ -5141,6 +5144,9 @@ msgstr ""
msgid "Billing|Group invite"
msgstr ""
+msgid "Billing|Members who were invited via a group invitation cannot be removed. You can either remove the entire group, or ask an Owner of the invited group to remove the member."
+msgstr ""
+
msgid "Billing|No users to display."
msgstr ""
@@ -22744,6 +22750,9 @@ msgstr ""
msgid "Ok, let's go"
msgstr ""
+msgid "Okay"
+msgstr ""
+
msgid "Oldest first"
msgstr ""
diff --git a/scripts/validate_migration_timestamps b/scripts/validate_migration_timestamps
new file mode 100755
index 00000000000..d3722e7a4af
--- /dev/null
+++ b/scripts/validate_migration_timestamps
@@ -0,0 +1,24 @@
+#!/usr/bin/env ruby
+
+# frozen_string_literal: true
+
+require 'time'
+
+MIGRATION_DIRS = %w[db/migrate db/post_migrate].freeze
+VERSION_DIGITS = 14
+MIGRATION_TIMESTAMP_REGEX = /\A(?<version>\d{#{VERSION_DIGITS}})_/.freeze
+
+maximum_timestamp = Time.now.utc.strftime('%Y%m%d%H%M%S').to_i
+
+MIGRATION_DIRS.each do |migration_dir|
+ Dir[File.join(migration_dir, '*.rb')].each do |filename|
+ file_basename = File.basename(filename)
+ version_match = MIGRATION_TIMESTAMP_REGEX.match(file_basename)
+
+ raise "#{filename} has an invalid migration version" if version_match.nil?
+
+ migration_timestamp = version_match['version'].to_i
+
+ raise "#{filename} has a future timestamp" if migration_timestamp > maximum_timestamp
+ end
+end
diff --git a/spec/fixtures/api/schemas/graphql/packages/package_details.json b/spec/fixtures/api/schemas/graphql/packages/package_details.json
index 89e73d48c60..ca08e005e9d 100644
--- a/spec/fixtures/api/schemas/graphql/packages/package_details.json
+++ b/spec/fixtures/api/schemas/graphql/packages/package_details.json
@@ -82,6 +82,7 @@
{ "$ref": "./package_composer_metadata.json" },
{ "$ref": "./package_conan_metadata.json" },
{ "$ref": "./package_maven_metadata.json" },
+ { "$ref": "./package_nuget_metadata.json" },
{ "type": "null" }
]
},
diff --git a/spec/fixtures/api/schemas/graphql/packages/package_nuget_metadata.json b/spec/fixtures/api/schemas/graphql/packages/package_nuget_metadata.json
new file mode 100644
index 00000000000..131b9e97287
--- /dev/null
+++ b/spec/fixtures/api/schemas/graphql/packages/package_nuget_metadata.json
@@ -0,0 +1,19 @@
+{
+ "type": "object",
+ "additionalProperties": false,
+ "required": ["id", "licenseUrl", "projectUrl", "iconUrl"],
+ "properties": {
+ "id": {
+ "type": "string"
+ },
+ "licenseUrl": {
+ "type": "string"
+ },
+ "projectUrl": {
+ "type": "string"
+ },
+ "iconUrl": {
+ "type": "string"
+ }
+ }
+}
diff --git a/spec/graphql/types/packages/maven/metadatum_type_spec.rb b/spec/graphql/types/packages/maven/metadatum_type_spec.rb
new file mode 100644
index 00000000000..cf24af1456e
--- /dev/null
+++ b/spec/graphql/types/packages/maven/metadatum_type_spec.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe GitlabSchema.types['MavenMetadata'] do
+ it 'includes maven metadatum fields' do
+ expected_fields = %w[
+ id created_at updated_at path app_group app_version app_name
+ ]
+
+ expect(described_class).to include_graphql_fields(*expected_fields)
+ end
+end
diff --git a/spec/graphql/types/packages/nuget/metadatum_type_spec.rb b/spec/graphql/types/packages/nuget/metadatum_type_spec.rb
new file mode 100644
index 00000000000..e5baa7522e4
--- /dev/null
+++ b/spec/graphql/types/packages/nuget/metadatum_type_spec.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe GitlabSchema.types['NugetMetadata'] do
+ it 'includes nuget metadatum fields' do
+ expected_fields = %w[
+ id license_url project_url icon_url
+ ]
+
+ expect(described_class).to include_graphql_fields(*expected_fields)
+ end
+end
diff --git a/spec/requests/api/graphql/packages/nuget_spec.rb b/spec/requests/api/graphql/packages/nuget_spec.rb
new file mode 100644
index 00000000000..fa9d8a0e37e
--- /dev/null
+++ b/spec/requests/api/graphql/packages/nuget_spec.rb
@@ -0,0 +1,74 @@
+# frozen_string_literal: true
+require 'spec_helper'
+
+RSpec.describe 'nuget package details' do
+ include GraphqlHelpers
+
+ let_it_be(:project) { create(:project) }
+ let_it_be(:nuget_package) { create(:nuget_package, :with_metadatum, project: project) }
+
+ let(:package_global_id) { global_id_of(nuget_package) }
+ let(:metadata) { query_graphql_fragment('NugetMetadata') }
+ let(:first_file) { nuget_package.package_files.find { |f| global_id_of(f) == first_file_response['id'] } }
+
+ let(:depth) { 3 }
+ let(:excluded) { %w[metadata apiFuzzingCiConfiguration pipeline packageFiles] }
+ let(:package_files) { all_graphql_fields_for('PackageFile') }
+
+ let(:user) { project.owner }
+ let(:package_details) { graphql_data_at(:package) }
+ let(:metadata_response) { graphql_data_at(:package, :metadata) }
+ let(:package_files_response) { graphql_data_at(:package, :package_files, :nodes) }
+ let(:first_file_response) { graphql_data_at(:package, :package_files, :nodes, 0)}
+
+ let(:query) do
+ graphql_query_for(:package, { id: package_global_id }, <<~FIELDS)
+ #{all_graphql_fields_for('PackageDetailsType', max_depth: depth, excluded: excluded)}
+ metadata {
+ #{metadata}
+ }
+ packageFiles {
+ nodes {
+ #{package_files}
+ }
+ }
+ FIELDS
+ end
+
+ subject { post_graphql(query, current_user: user) }
+
+ before do
+ subject
+ end
+
+ it_behaves_like 'a working graphql query' do
+ it 'matches the JSON schema' do
+ expect(package_details).to match_schema('graphql/packages/package_details')
+ end
+ end
+
+ it 'has the correct metadata' do
+ expect(metadata_response).to include(
+ 'id' => global_id_of(nuget_package.nuget_metadatum),
+ 'licenseUrl' => nuget_package.nuget_metadatum.license_url,
+ 'projectUrl' => nuget_package.nuget_metadatum.project_url,
+ 'iconUrl' => nuget_package.nuget_metadatum.icon_url
+ )
+ end
+
+ it 'has the right amount of files' do
+ expect(package_files_response.length).to be(nuget_package.package_files.length)
+ end
+
+ it 'has the basic package files data' do
+ expect(first_file_response).to include(
+ 'id' => global_id_of(first_file),
+ 'fileName' => first_file.file_name,
+ 'size' => first_file.size.to_s,
+ 'downloadPath' => first_file.download_path,
+ 'fileSha1' => first_file.file_sha1,
+ 'fileMd5' => first_file.file_md5,
+ 'fileSha256' => first_file.file_sha256
+ )
+ end
+end