Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.recipe.build
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
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
slapos.recipe.build
Commits
4aaf888a
Commit
4aaf888a
authored
Dec 05, 2018
by
Ayush Tiwari
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add tests
parent
eec71c3e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
68 additions
and
18 deletions
+68
-18
README.rst
README.rst
+4
-4
slapos/recipe/build/tests.py
slapos/recipe/build/tests.py
+51
-9
slapos/recipe/gitclone.py
slapos/recipe/gitclone.py
+13
-5
No files found.
README.rst
View file @
4aaf888a
...
...
@@ -391,7 +391,7 @@ Then, when update occurs, nothing is done::
Unable to update:
Traceback (most recent call last):
...
...CalledProcessError: Command '['git', 'fetch', '--all']' returned non-zero exit status 1
...CalledProcessError: Command '['git', 'fetch', '--
recurse-submodules', '--
all']' returned non-zero exit status 1
<BLANKLINE>
...
fatal: unable to access 'http://git.erp5.org/repos/nowhere/': The requested URL returned error: 500
...
...
@@ -454,8 +454,8 @@ Ignore cloning submodules
~~~~~~~~~~~~~~~~~~~~~~~~~
By default, cloning the repository will clone its submodules also. You can force
git to ignore cloinig submodules by defining `
clone-submodules` boolean optio
n
to 'fals
e'::
git to ignore cloinig submodules by defining `
ignore-cloning-submodules` boolea
n
option to 'tru
e'::
[buildout]
parts = git-clone
...
...
@@ -463,7 +463,7 @@ to 'false'::
[git-clone]
recipe = slapos.recipe.build:gitclone
repository = https://lab.nexedi.com/tiwariayush/test_erp5
clone-submodules = fals
e
ignore-cloning-submodules = tru
e
Other options
~~~~~~~~~~~~~
...
...
slapos/recipe/build/tests.py
View file @
4aaf888a
...
...
@@ -8,6 +8,7 @@ import stat
import
tempfile
import
unittest
import
zc.buildout.testing
from
subprocess
import
check_call
,
check_output
from
slapos.recipe.gitclone
import
GIT_CLONE_ERROR_MESSAGE
,
\
GIT_CLONE_CACHE_ERROR_MESSAGE
...
...
@@ -16,6 +17,7 @@ optionflags = (doctest.ELLIPSIS | doctest.NORMALIZE_WHITESPACE)
GIT_REPOSITORY
=
'https://lab.nexedi.com/nexedi/slapos.recipe.build.git'
BAD_GIT_REPOSITORY
=
'http://git.erp5.org/repos/nowhere'
GIT_REPOSITORY_WITH_SUBMODULES
=
'https://lab.nexedi.com/tiwariayush/test_erp5'
GIT_SUBMODULE_REPOSITORY
=
'https://lab.nexedi.com/tiwariayush/test_erp5_submodule'
REVISION
=
'2566127'
def
setUp
(
test
):
...
...
@@ -118,7 +120,6 @@ class GitCloneNonInformativeTests(unittest.TestCase):
# Check git clone parameters
_
=
self
.
assertIn
if
ignore_ssl_certificate
else
self
.
assertNotIn
_
(
"--config"
,
check_call_parameter_list
[
0
][
0
])
_
(
"http.sslVerify=false"
,
check_call_parameter_list
[
0
][
0
])
# Restore original check_call method
...
...
@@ -127,22 +128,63 @@ class GitCloneNonInformativeTests(unittest.TestCase):
def
test_ignore_ssl_certificate_false
(
self
):
self
.
test_ignore_ssl_certificate
(
ignore_ssl_certificate
=
False
)
def
test_clone_submodules_by_default
(
self
,
clone_submodules
=
Tru
e
):
def
test_clone_submodules_by_default
(
self
,
ignore_cloning_submodules
=
Fals
e
):
recipe
=
self
.
makeGitCloneRecipe
(
{
'repository'
:
GIT_REPOSITORY_WITH_SUBMODULES
,
'
clone-submodules'
:
str
(
clone
_submodules
).
lower
()}
'
ignore-cloning-submodules'
:
str
(
ignore_cloning
_submodules
).
lower
()}
)
recipe
.
install
()
git_repository
_path
=
os
.
path
.
join
(
self
.
parts_directory_path
,
"test"
)
self
.
assertTrue
(
os
.
path
.
exists
(
git_repository
_path
))
submodule_repo_path
=
os
.
path
.
join
(
git_repository
_path
,
'dir2'
,
'test_erp5_submodule'
)
main_repo
_path
=
os
.
path
.
join
(
self
.
parts_directory_path
,
"test"
)
self
.
assertTrue
(
os
.
path
.
exists
(
main_repo
_path
))
submodule_repo_path
=
os
.
path
.
join
(
main_repo
_path
,
'dir2'
,
'test_erp5_submodule'
)
# Check if the folder exists
self
.
assertTrue
(
os
.
path
.
exists
(
git_repository
_path
))
self
.
assertTrue
(
os
.
path
.
exists
(
main_repo
_path
))
# Check is there is anything in submodule repository path
self
.
assert
Equal
(
bool
(
clone
_submodules
),
bool
(
os
.
listdir
(
submodule_repo_path
)))
self
.
assert
NotEqual
(
bool
(
ignore_cloning
_submodules
),
bool
(
os
.
listdir
(
submodule_repo_path
)))
def
test_ignore_cloning_submodules
(
self
):
self
.
test_clone_submodules_by_default
(
clone_submodules
=
False
)
self
.
test_clone_submodules_by_default
(
ignore_cloning_submodules
=
True
)
def
test_fetch_submodules_with_main_repo
(
self
):
recipe
=
self
.
makeGitCloneRecipe
(
{
'repository'
:
GIT_REPOSITORY_WITH_SUBMODULES
}
)
recipe
.
install
()
main_repo_path
=
os
.
path
.
join
(
self
.
parts_directory_path
,
"test"
)
self
.
assertTrue
(
os
.
path
.
exists
(
main_repo_path
))
submodule_repo_path
=
os
.
path
.
join
(
main_repo_path
,
'dir2'
,
'test_erp5_submodule'
)
# Check if the submodule is not empty
self
.
assertTrue
(
os
.
listdir
(
submodule_repo_path
))
# Get the head commit of the submodule repo
head_commit_submodule_before_fetch
=
check_output
([
'git'
,
'rev-parse'
,
'HEAD'
],
cwd
=
submodule_repo_path
).
strip
()
# Now, let's update the main repo as well as submodule repository.
# Updating the repo will fetch the updated branch but doesn't checkout
# to the updated master branch.
recipe
.
update
()
head_commit_after_udpate_before_checkout
=
check_output
([
'git'
,
'submodule'
,
'status'
,
submodule_repo_path
],
cwd
=
main_repo_path
).
split
()[
0
]
# Checkout the submodule repository and get the head commit
check_call
([
'git'
,
'checkout'
,
'master'
],
cwd
=
submodule_repo_path
)
head_commit_after_update_after_checkout
=
check_output
([
'git'
,
'rev-parse'
,
'HEAD'
],
cwd
=
submodule_repo_path
).
strip
()
# Make another git clone of submodule and check the HEAD of the repo.
submodule_recipe
=
self
.
makeGitCloneRecipe
(
{
'repository'
:
GIT_SUBMODULE_REPOSITORY
}
)
submodule_recipe
.
install
()
# Check the HEAD of the submodule
head_commit
=
check_output
([
'git'
,
'rev-parse'
,
'HEAD'
],
cwd
=
main_repo_path
).
strip
()
self
.
assertNotEqual
(
head_commit_submodule_before_fetch
,
head_commit
)
self
.
assertNotEqual
(
head_commit_after_udpate_before_checkout
,
head_commit
)
self
.
assertEqual
(
head_commit_after_update_after_checkout
,
head_commit
)
def
test_suite
():
suite
=
unittest
.
TestSuite
((
...
...
slapos/recipe/gitclone.py
View file @
4aaf888a
...
...
@@ -146,7 +146,7 @@ class Recipe(object):
self
.
sparse
=
options
.
get
(
'sparse-checkout'
,
''
).
strip
()
# Set boolean values
for
key
in
(
'develop'
,
'shared'
,
'use-cache'
,
'ignore-ssl-certificate'
,
'
clone
-submodules'
):
'
ignore-cloning
-submodules'
):
setattr
(
self
,
key
.
replace
(
'-'
,
'_'
),
options
.
get
(
key
,
''
).
lower
()
in
TRUE_VALUES
)
if
self
.
shared
:
self
.
use_cache
=
False
...
...
@@ -211,13 +211,16 @@ class Recipe(object):
git_clone_command
+=
'--branch'
,
self
.
branch
if
self
.
ignore_ssl_certificate
:
config
.
append
(
'http.sslVerify=false'
)
if
self
.
clone_submodules
:
if
config
and
self
.
use_cache
:
raise
NotImplementedError
if
not
self
.
ignore_cloning_submodules
:
# `--recurse-submodules` to the git clone command will automatically
# initialize and update each submodule in the repository.
config
.
append
(
'submodule.recurse=true'
)
git_clone_command
.
append
(
'--recurse-submodules'
)
if
config
and
self
.
use_cache
:
raise
NotImplementedError
for
config
in
config
:
git_clone_command
+=
'--config'
,
config
...
...
@@ -279,7 +282,12 @@ class Recipe(object):
call
([
self
.
git_command
,
'rev-parse'
,
'--verify'
,
self
.
revision
],
cwd
=
self
.
location
)
==
0
if
not
revision_already_fetched
:
check_call
([
self
.
git_command
,
'fetch'
,
'--all'
],
cwd
=
self
.
location
)
# With --recurse-submodules, it will fetch the updated branches of the
# submodules as well as of the main repo. It will remain in a detached
# head old state
# NOTE: It won't checkout to the updated master/main-branch
check_call
([
self
.
git_command
,
'fetch'
,
'--recurse-submodules'
,
'--all'
],
cwd
=
self
.
location
)
# Also update the submodule directory
check_call
([
self
.
git_command
,
'submodule'
,
'update'
,
'--remote'
],
cwd
=
self
.
location
)
...
...
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