diff options
Diffstat (limited to 'qa/qa/specs/features/browser_ui/5_package/package_registry/nuget_repository_spec.rb')
-rw-r--r-- | qa/qa/specs/features/browser_ui/5_package/package_registry/nuget_repository_spec.rb | 160 |
1 files changed, 85 insertions, 75 deletions
diff --git a/qa/qa/specs/features/browser_ui/5_package/package_registry/nuget_repository_spec.rb b/qa/qa/specs/features/browser_ui/5_package/package_registry/nuget_repository_spec.rb index 0b4825715c1..d63bf486f11 100644 --- a/qa/qa/specs/features/browser_ui/5_package/package_registry/nuget_repository_spec.rb +++ b/qa/qa/specs/features/browser_ui/5_package/package_registry/nuget_repository_spec.rb @@ -9,6 +9,7 @@ module QA Resource::Project.fabricate_via_api! do |project| project.name = 'nuget-package-project' project.template_name = 'dotnetcore' + project.visibility = :private end end @@ -21,9 +22,14 @@ module QA end let(:group_deploy_token) do - Resource::GroupDeployToken.fabricate_via_browser_ui! do |deploy_token| + Resource::GroupDeployToken.fabricate_via_api! do |deploy_token| deploy_token.name = 'nuget-group-deploy-token' deploy_token.group = project.group + deploy_token.scopes = %w[ + read_repository + read_package_registry + write_package_registry + ] end end @@ -70,7 +76,7 @@ module QA when :ci_job_token '${CI_JOB_TOKEN}' when :group_deploy_token - "\"#{group_deploy_token.password}\"" + "\"#{group_deploy_token.token}\"" end end @@ -88,35 +94,37 @@ module QA it "publishes a nuget package at the project level, installs and deletes it at the group level using a #{params[:token_name]}" do Flow::Login.sign_in - Resource::Repository::Commit.fabricate_via_api! do |commit| - commit.project = project - commit.commit_message = 'Add .gitlab-ci.yml' - commit.update_files( - [ - { - file_path: '.gitlab-ci.yml', - content: <<~YAML - image: mcr.microsoft.com/dotnet/sdk:5.0 - - stages: - - deploy - - deploy: - stage: deploy - script: - - dotnet restore -p:Configuration=Release - - dotnet build -c Release - - dotnet pack -c Release -p:PackageID=#{package.name} - - dotnet nuget add source "$CI_SERVER_URL/api/v4/projects/$CI_PROJECT_ID/packages/nuget/index.json" --name gitlab --username #{auth_token_username} --password #{auth_token_password} --store-password-in-clear-text - - dotnet nuget push "bin/Release/*.nupkg" --source gitlab - rules: - - if: '$CI_COMMIT_BRANCH == "#{project.default_branch}"' - tags: - - "runner-for-#{project.group.name}" - YAML - } - ] - ) + Support::Retrier.retry_on_exception(max_attempts: 3, sleep_interval: 2) do + Resource::Repository::Commit.fabricate_via_api! do |commit| + commit.project = project + commit.commit_message = 'Add .gitlab-ci.yml' + commit.update_files( + [ + { + file_path: '.gitlab-ci.yml', + content: <<~YAML + image: mcr.microsoft.com/dotnet/sdk:5.0 + + stages: + - deploy + + deploy: + stage: deploy + script: + - dotnet restore -p:Configuration=Release + - dotnet build -c Release + - dotnet pack -c Release -p:PackageID=#{package.name} + - dotnet nuget add source "$CI_SERVER_URL/api/v4/projects/$CI_PROJECT_ID/packages/nuget/index.json" --name gitlab --username #{auth_token_username} --password #{auth_token_password} --store-password-in-clear-text + - dotnet nuget push "bin/Release/*.nupkg" --source gitlab + rules: + - if: '$CI_COMMIT_BRANCH == "#{project.default_branch}"' + tags: + - "runner-for-#{project.group.name}" + YAML + } + ] + ) + end end project.visit! @@ -132,50 +140,52 @@ module QA another_project.visit! - Resource::Repository::Commit.fabricate_via_api! do |commit| - commit.project = another_project - commit.commit_message = 'Add new csproj file' - commit.add_files( - [ - { - file_path: 'otherdotnet.csproj', - content: <<~EOF - <Project Sdk="Microsoft.NET.Sdk"> - - <PropertyGroup> - <OutputType>Exe</OutputType> - <TargetFramework>net5.0</TargetFramework> - </PropertyGroup> - - </Project> - EOF - } - ] - ) - commit.update_files( - [ - { - file_path: '.gitlab-ci.yml', - content: <<~YAML - image: mcr.microsoft.com/dotnet/sdk:5.0 - - stages: - - install - - install: - stage: install - script: - - dotnet nuget locals all --clear - - dotnet nuget add source "$CI_SERVER_URL/api/v4/groups/#{another_project.group.id}/-/packages/nuget/index.json" --name gitlab --username #{auth_token_username} --password #{auth_token_password} --store-password-in-clear-text - - "dotnet add otherdotnet.csproj package #{package.name} --version 1.0.0" - only: - - "#{another_project.default_branch}" - tags: - - "runner-for-#{project.group.name}" - YAML - } - ] - ) + Support::Retrier.retry_on_exception(max_attempts: 3, sleep_interval: 2) do + Resource::Repository::Commit.fabricate_via_api! do |commit| + commit.project = another_project + commit.commit_message = 'Add new csproj file' + commit.add_files( + [ + { + file_path: 'otherdotnet.csproj', + content: <<~EOF + <Project Sdk="Microsoft.NET.Sdk"> + + <PropertyGroup> + <OutputType>Exe</OutputType> + <TargetFramework>net5.0</TargetFramework> + </PropertyGroup> + + </Project> + EOF + } + ] + ) + commit.update_files( + [ + { + file_path: '.gitlab-ci.yml', + content: <<~YAML + image: mcr.microsoft.com/dotnet/sdk:5.0 + + stages: + - install + + install: + stage: install + script: + - dotnet nuget locals all --clear + - dotnet nuget add source "$CI_SERVER_URL/api/v4/groups/#{another_project.group.id}/-/packages/nuget/index.json" --name gitlab --username #{auth_token_username} --password #{auth_token_password} --store-password-in-clear-text + - "dotnet add otherdotnet.csproj package #{package.name} --version 1.0.0" + only: + - "#{another_project.default_branch}" + tags: + - "runner-for-#{project.group.name}" + YAML + } + ] + ) + end end Flow::Pipeline.visit_latest_pipeline |