Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bob.devtools
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
bob
bob.devtools
Commits
6a318f49
Commit
6a318f49
authored
6 years ago
by
André Anjos
Browse files
Options
Downloads
Patches
Plain Diff
[ci][bootstrap] Local testing and fixes
parent
e9a79806
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#25996
failed
6 years ago
Stage: build
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ci/bootstrap.py
+23
-37
23 additions, 37 deletions
ci/bootstrap.py
with
23 additions
and
37 deletions
ci/bootstrap.py
+
23
−
37
View file @
6a318f49
...
...
@@ -100,16 +100,11 @@ def run_cmdline(cmd, env=None):
env (dict, Optional): Environment to use for running the program on. If not
set, use :py:obj:`os.environ`.
Returns:
str: The standard output and error of the command being executed
'''
if
env
is
None
:
env
=
os
.
environ
logger
.
info
(
'
$
%s
'
%
'
'
.
join
(
cmd
))
logger
.
info
(
'
(system)
%s
'
%
'
'
.
join
(
cmd
))
start
=
time
.
time
()
out
=
b
''
...
...
@@ -117,46 +112,35 @@ def run_cmdline(cmd, env=None):
p
=
subprocess
.
Popen
(
cmd
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
STDOUT
,
env
=
env
)
chunk_size
=
1
<<
13
lineno
=
1
for
chunk
in
iter
(
lambda
:
p
.
stdout
.
read
(
chunk_size
),
b
''
):
decoded
=
chunk
.
decode
()
while
'
\n
'
in
decoded
:
pos
=
decoded
.
index
(
'
\n
'
)
print
(
'
%03d: %s
'
%
(
lineno
,
decoded
[:
pos
]))
decoded
=
decoded
[
pos
+
1
:]
lineno
+=
1
out
+=
chunk
for
line
in
iter
(
p
.
stdout
.
readline
,
b
''
):
sys
.
stdout
.
write
(
line
.
decode
(
sys
.
stdout
.
encoding
))
sys
.
stdout
.
flush
()
if
p
.
wait
()
!=
0
:
logger
.
error
(
'
Command output is:
\n
%s
'
,
out
.
decode
())
raise
RuntimeError
(
"
command `%s
'
exited with error state (%d)
"
%
\
(
'
'
.
join
(
cmd
_log
),
p
.
returncode
))
(
'
'
.
join
(
cmd
),
p
.
returncode
))
total
=
time
.
time
()
-
start
logger
.
info
(
'
command took %s
'
%
human_time
(
total
))
out
=
out
.
decode
()
return
out
def
touch
(
path
):
'''
Python-implementation of the
"
touch
"
command-line application
'''
with
open
(
path
,
'
a
'
):
os
.
utime
(
path
,
times
)
os
.
utime
(
path
,
None
)
def
merge_conda_cache
(
cache
,
prefix
):
'''
Merges conda pkg caches and conda-bld folders
'''
pkgs_dir
=
os
.
path
.
join
(
prefix
,
'
pkgs
'
)
pkgs_urls_txt
=
os
.
path
.
join
(
pkgs_dir
,
'
urls.txt
'
)
if
not
os
.
path
.
exists
(
pkgs_dir
):
logger
.
info
(
'
mkdir -p %s
'
,
pkgs_dir
)
os
.
makedirs
(
pkgs_dir
)
pkgs_urls_txt
=
os
.
path
.
join
(
pkgs_dir
,
'
urls.txt
'
)
logger
.
info
(
'
touch %s
'
,
pkgs_urls_txt
)
touch
(
pkgs_urls_txt
)
...
...
@@ -205,7 +189,7 @@ def get_miniconda_sh():
else
:
path
=
path
%
'
Linux
'
logger
.
info
(
'
Reques
ting
for
https://%s
%s
...
'
,
server
,
path
)
logger
.
info
(
'
Connec
ting
to
https://%s...
'
,
server
)
conn
=
http
.
client
.
HTTPSConnection
(
server
)
conn
.
request
(
"
GET
"
,
path
)
r1
=
conn
.
getresponse
()
...
...
@@ -229,14 +213,19 @@ def install_miniconda(prefix):
else
:
logger
.
info
(
"
Re-using cached miniconda3 installer
"
)
cached
=
None
if
os
.
path
.
exists
(
prefix
):
#this is the previous cache, move it
cached
=
prefix
+
'
.cached
'
if
os
.
path
.
exists
(
cached
):
logger
.
info
(
'
(rmtree) %s
'
,
cached
)
shutil
.
rmtree
(
cached
)
logger
.
info
(
'
(move) %s -> %s
'
,
prefix
,
cached
)
os
.
rename
(
prefix
,
cached
)
run_cmdline
([
'
bash
'
,
'
miniconda.sh
'
,
'
-b
'
,
'
-p
'
,
prefix
])
merge_conda_cache
(
cached
,
prefix
)
shutil
.
rmtree
(
cached
)
if
cached
is
not
None
:
merge_conda_cache
(
cached
,
prefix
)
shutil
.
rmtree
(
cached
)
def
get_local_channels
():
...
...
@@ -309,6 +298,7 @@ if __name__ == '__main__':
if
sys
.
argv
[
1
]
==
'
test
'
:
# sets up local variables for testing
os
.
environ
[
'
CI_PROJECT_DIR
'
]
=
os
.
path
.
realpath
(
os
.
curdir
)
os
.
environ
[
'
CI_PROJECT_NAME
'
]
=
'
bob.devtools
'
os
.
environ
[
'
CONDA_ROOT
'
]
=
os
.
path
.
join
(
os
.
environ
[
'
CI_PROJECT_DIR
'
],
'
miniconda
'
)
...
...
@@ -318,25 +308,21 @@ if __name__ == '__main__':
workdir
=
os
.
environ
[
'
CI_PROJECT_DIR
'
]
logger
.
info
(
'
os.environ[
"
%s
"
] = %s
'
,
'
CI_PROJECT_DIR
'
,
workdir
)
condarc
=
os
.
path
.
join
(
prefix
,
'
condarc
'
)
os
.
environ
[
'
CONDARC
'
]
=
condarc
logger
.
info
(
'
os.environ[
"
%s
"
] = %s
'
,
'
CONDARC
'
,
condarc
)
install_miniconda
(
prefix
)
conda_bin
=
os
.
path
.
join
(
prefix
,
'
bin
'
,
'
conda
'
)
if
not
os
.
path
.
exists
(
conda_bin
):
install_miniconda
(
prefix
)
# creates the condarc file
logger
.
info
(
'
(copy) %s -> %s
'
,
baserc
,
condarc
)
condarc
=
os
.
path
.
join
(
prefix
,
'
condarc
'
)
logger
.
info
(
'
(create) %s
'
,
condarc
)
with
open
(
condarc
,
'
wt
'
)
as
f
:
write
(
BASE_CONDARC
)
shutil
.
copy2
(
baserc
,
condarc
)
f
.
write
(
BASE_CONDARC
)
os
.
environ
[
'
CONDARC
'
]
=
condarc
logger
.
info
(
'
os.environ[
"
%s
"
] = %s
'
,
'
CONDARC
'
,
condarc
)
conda_version
=
'
4
'
conda_build_version
=
'
3
'
if
sys
.
argv
[
1
]
==
'
build
'
:
if
sys
.
argv
[
1
]
in
(
'
build
'
,
'
test
'
)
:
# simple - just use the defaults channels when self building
add_channels_condarc
([
'
defaults
'
],
condarc
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment