Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
85558bab
Commit
85558bab
authored
Jun 17, 2021
by
David Fernandez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve gradle QA scenario
by adding the pull action Changelog: other
parent
095e2843
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
205 additions
and
85 deletions
+205
-85
app/views/shared/deploy_tokens/_form.html.haml
app/views/shared/deploy_tokens/_form.html.haml
+1
-1
qa/qa/page/project/settings/deploy_tokens.rb
qa/qa/page/project/settings/deploy_tokens.rb
+3
-1
qa/qa/resource/deploy_token.rb
qa/qa/resource/deploy_token.rb
+1
-1
qa/qa/resource/package.rb
qa/qa/resource/package.rb
+3
-4
qa/qa/specs/features/browser_ui/5_package/maven_gradle_repository_spec.rb
...ures/browser_ui/5_package/maven_gradle_repository_spec.rb
+197
-78
No files found.
app/views/shared/deploy_tokens/_form.html.haml
View file @
85558bab
...
...
@@ -38,7 +38,7 @@
-
if
packages_registry_enabled?
(
group_or_project
)
%fieldset
.form-group.form-check
=
f
.
check_box
:read_package_registry
,
class:
'form-check-input'
=
f
.
check_box
:read_package_registry
,
class:
'form-check-input'
,
data:
{
qa_selector:
'deploy_token_read_package_registry_checkbox'
}
=
f
.
label
:read_package_registry
,
'read_package_registry'
,
class:
'label-bold form-check-label'
.text-secondary
=
s_
(
'DeployTokens|Allows read access to the package registry.'
)
...
...
qa/qa/page/project/settings/deploy_tokens.rb
View file @
85558bab
...
...
@@ -9,6 +9,7 @@ module QA
element
:deploy_token_name_field
element
:deploy_token_expires_at_field
element
:deploy_token_read_repository_checkbox
element
:deploy_token_read_package_registry_checkbox
element
:deploy_token_read_registry_checkbox
element
:create_deploy_token_button
end
...
...
@@ -27,8 +28,9 @@ module QA
fill_element
(
:deploy_token_expires_at_field
,
expires_at
.
to_s
+
"
\n
"
)
end
def
fill_scopes
(
read_repository
:
,
read_registry
:
)
def
fill_scopes
(
read_repository:
false
,
read_registry:
false
,
read_package_registry:
false
)
check_element
(
:deploy_token_read_repository_checkbox
)
if
read_repository
check_element
(
:deploy_token_read_package_registry_checkbox
)
if
read_package_registry
check_element
(
:deploy_token_read_registry_checkbox
)
if
read_registry
end
...
...
qa/qa/resource/deploy_token.rb
View file @
85558bab
...
...
@@ -37,7 +37,7 @@ module QA
setting
.
expand_deploy_tokens
do
|
page
|
page
.
fill_token_name
(
name
)
page
.
fill_token_expires_at
(
expires_at
)
page
.
fill_scopes
(
read_repository:
true
,
read_
registry:
fals
e
)
page
.
fill_scopes
(
read_repository:
true
,
read_
package_registry:
tru
e
)
page
.
add_token
end
...
...
qa/qa/resource/package.rb
View file @
85558bab
...
...
@@ -15,11 +15,10 @@ module QA
end
attribute
:id
do
packages
=
project
.
packages
return
unless
(
this_package
=
packages
&
.
find
{
|
package
|
package
[
:name
]
==
"
#{
project
.
path_with_namespace
}
/
#{
name
}
"
})
# rubocop:disable Cop/AvoidReturnFromBlocks
this_package
=
project
.
packages
&
.
find
{
|
package
|
package
[
:name
]
==
name
}
this_package
[
:id
]
this_package
.
try
(
:fetch
,
:id
)
end
def
fabricate!
...
...
qa/qa/specs/features/browser_ui/5_package/maven_gradle_repository_spec.rb
View file @
85558bab
...
...
@@ -3,39 +3,45 @@
module
QA
RSpec
.
describe
'Package'
,
:orchestrated
,
:packages
do
describe
'Maven Repository with Gradle'
do
using
RSpec
::
Parameterized
::
TableSyntax
include
Runtime
::
Fixtures
let
(
:group_id
)
{
'com.gitlab.qa'
}
let
(
:artifact_id
)
{
'maven_gradle'
}
let
(
:package_name
)
{
"
#{
group_id
}
/
#{
artifact_id
}
"
.
tr
(
'.'
,
'/'
)
}
let
(
:auth_token
)
do
unless
Page
::
Main
::
Menu
.
perform
(
&
:signed_in?
)
Flow
::
Login
.
sign_in
end
let
(
:package_version
)
{
'1.3.7'
}
Resource
::
PersonalAccessToken
.
fabricate!
.
token
end
let
(
:personal_access_token
)
{
Runtime
::
Env
.
personal_access_token
}
let
(
:project
)
do
let
(
:p
ackage_p
roject
)
do
Resource
::
Project
.
fabricate_via_api!
do
|
project
|
project
.
name
=
'maven-with-gradle-project'
project
.
initialize_with_readme
=
true
project
.
visibility
=
:private
end
end
let
(
:client_project
)
do
Resource
::
Project
.
fabricate_via_api!
do
|
client_project
|
client_project
.
name
=
'gradle_client'
client_project
.
initialize_with_readme
=
true
client_project
.
group
=
package_project
.
group
end
end
let
(
:package
)
do
Resource
::
Package
.
init
do
|
package
|
package
.
name
=
package_name
package
.
project
=
project
package
.
project
=
p
ackage_p
roject
end
end
let
!
(
:runner
)
do
let
(
:runner
)
do
Resource
::
Runner
.
fabricate!
do
|
runner
|
runner
.
name
=
"qa-runner-
#{
Time
.
now
.
to_i
}
"
runner
.
tags
=
[
"runner-for-
#{
p
roject
.
name
}
"
]
runner
.
tags
=
[
"runner-for-
#{
p
ackage_project
.
group
.
name
}
"
]
runner
.
executor
=
:docker
runner
.
project
=
project
runner
.
token
=
package_project
.
group
.
runners_token
end
end
...
...
@@ -44,87 +50,200 @@ module QA
"
#{
uri
.
scheme
}
://
#{
uri
.
host
}
:
#{
uri
.
port
}
"
end
let
(
:project_deploy_token
)
do
Resource
::
DeployToken
.
fabricate_via_browser_ui!
do
|
deploy_token
|
deploy_token
.
name
=
'maven-with-gradle-deploy-token'
deploy_token
.
project
=
package_project
end
end
let
(
:package_gitlab_ci_file
)
do
{
file_path:
'.gitlab-ci.yml'
,
content:
<<~
YAML
deploy:
image: gradle:6.5-jdk11
script:
- 'gradle publish'
only:
- "
#{
package_project
.
default_branch
}
"
tags:
- "runner-for-
#{
package_project
.
group
.
name
}
"
YAML
}
end
let
(
:package_build_gradle_file
)
do
{
file_path:
'build.gradle'
,
content:
<<~
EOF
plugins {
id 'java'
id 'maven-publish'
}
publishing {
publications {
library(MavenPublication) {
groupId '
#{
group_id
}
'
artifactId '
#{
artifact_id
}
'
version '
#{
package_version
}
'
from components.java
}
}
repositories {
maven {
url "
#{
gitlab_address_with_port
}
/api/v4/projects/
#{
package_project
.
id
}
/packages/maven"
credentials(HttpHeaderCredentials) {
name = "Private-Token"
value = "
#{
personal_access_token
}
"
}
authentication {
header(HttpHeaderAuthentication)
}
}
}
}
EOF
}
end
let
(
:client_gitlab_ci_file
)
do
{
file_path:
'.gitlab-ci.yml'
,
content:
<<~
YAML
build:
image: gradle:6.5-jdk11
script:
- 'gradle build'
only:
- "
#{
client_project
.
default_branch
}
"
tags:
- "runner-for-
#{
client_project
.
group
.
name
}
"
YAML
}
end
before
do
Flow
::
Login
.
sign_in_unless_signed_in
runner
end
after
do
runner
.
remove_via_api!
package
.
remove_via_api!
package_project
.
remove_via_api!
client_project
.
remove_via_api!
end
it
'publishes a maven package via gradle'
,
testcase:
'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1074'
do
Resource
::
Repository
::
Commit
.
fabricate_via_api!
do
|
commit
|
commit
.
project
=
project
commit
.
commit_message
=
'Add .gitlab-ci.yml'
commit
.
add_files
([{
file_path:
'.gitlab-ci.yml'
,
content:
<<~
YAML
deploy:
image: gradle:6.5-jdk11
script:
- 'gradle publish'
only:
- "
#{
project
.
default_branch
}
"
tags:
- "runner-for-
#{
project
.
name
}
"
YAML
},
{
file_path:
'build.gradle'
,
content:
<<~
EOF
plugins {
id 'java'
id 'maven-publish'
}
publishing {
publications {
library(MavenPublication) {
groupId '
#{
group_id
}
'
artifactId '
#{
artifact_id
}
'
from components.java
}
}
repositories {
maven {
url "
#{
gitlab_address_with_port
}
/api/v4/projects/
#{
project
.
id
}
/packages/maven"
credentials(HttpHeaderCredentials) {
name = "Private-Token"
value = "
#{
auth_token
}
"
}
authentication {
header(HttpHeaderAuthentication)
}
}
}
}
EOF
}])
end
project
.
visit!
Flow
::
Pipeline
.
visit_latest_pipeline
where
(
:authentication_token_type
,
:maven_header_name
)
do
:personal_access_token
|
'Private-Token'
:ci_job_token
|
'Job-Token'
:project_deploy_token
|
'Deploy-Token'
end
Page
::
Project
::
Pipeline
::
Show
.
perform
do
|
pipeline
|
pipeline
.
click_job
(
'deploy'
)
with_them
do
let
(
:token
)
do
case
authentication_token_type
when
:personal_access_token
"
\"
#{
personal_access_token
}
\"
"
when
:ci_job_token
'System.getenv("CI_JOB_TOKEN")'
when
:project_deploy_token
"
\"
#{
project_deploy_token
.
password
}
\"
"
end
end
Page
::
Project
::
Job
::
Show
.
perform
do
|
job
|
expect
(
job
).
to
be_successful
(
timeout:
800
)
let
(
:client_build_gradle_file
)
do
{
file_path:
'build.gradle'
,
content:
<<~
EOF
plugins {
id 'java'
id 'application'
}
repositories {
jcenter()
maven {
url "
#{
gitlab_address_with_port
}
/api/v4/projects/
#{
package_project
.
id
}
/packages/maven"
name "GitLab"
credentials(HttpHeaderCredentials) {
name = '
#{
maven_header_name
}
'
value =
#{
token
}
}
authentication {
header(HttpHeaderAuthentication)
}
}
}
dependencies {
implementation group: '
#{
group_id
}
', name: '
#{
artifact_id
}
', version: '
#{
package_version
}
'
testImplementation 'junit:junit:4.12'
}
application {
mainClassName = 'gradle_maven_app.App'
}
EOF
}
end
Page
::
Project
::
Menu
.
perform
(
&
:click_packages_link
)
it
"pushes and pulls a maven package via gradle using
#{
params
[
:authentication_token_type
]
}
"
,
testcase:
'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1074'
do
# pushing
Resource
::
Repository
::
Commit
.
fabricate_via_api!
do
|
commit
|
commit
.
project
=
package_project
commit
.
commit_message
=
'Add .gitlab-ci.yml'
commit
.
add_files
([
package_gitlab_ci_file
,
package_build_gradle_file
])
end
Page
::
Project
::
Packages
::
Index
.
perform
do
|
index
|
expect
(
index
).
to
have_package
(
package_name
)
package_project
.
visit!
index
.
click_package
(
package_name
)
end
Flow
::
Pipeline
.
visit_latest_pipeline
Page
::
Project
::
Pipeline
::
Show
.
perform
do
|
pipeline
|
pipeline
.
click_job
(
'deploy'
)
end
Page
::
Project
::
Job
::
Show
.
perform
do
|
job
|
expect
(
job
).
to
be_successful
(
timeout:
800
)
end
Page
::
Project
::
Menu
.
perform
(
&
:click_packages_link
)
Page
::
Project
::
Packages
::
Index
.
perform
do
|
index
|
expect
(
index
).
to
have_package
(
package_name
)
index
.
click_package
(
package_name
)
end
Page
::
Project
::
Packages
::
Show
.
perform
do
|
show
|
expect
(
show
).
to
have_package_info
(
package_name
,
package_version
)
end
# pulling
Resource
::
Repository
::
Commit
.
fabricate_via_api!
do
|
commit
|
commit
.
project
=
client_project
commit
.
commit_message
=
'Add .gitlab-ci.yml'
commit
.
add_files
([
client_gitlab_ci_file
,
client_build_gradle_file
])
end
client_project
.
visit!
Flow
::
Pipeline
.
visit_latest_pipeline
Page
::
Project
::
Packages
::
Show
.
perform
(
&
:click_delete
)
Page
::
Project
::
Pipeline
::
Show
.
perform
do
|
pipeline
|
pipeline
.
click_job
(
'build'
)
end
Page
::
Project
::
Packages
::
Index
.
perform
do
|
index
|
expect
(
index
).
to
have_content
(
"Package deleted successfully"
)
e
xpect
(
index
).
not_to
have_package
(
package_name
)
Page
::
Project
::
Job
::
Show
.
perform
do
|
job
|
expect
(
job
).
to
be_successful
(
timeout:
800
)
e
nd
end
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment