Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Gepetto
dashboard
Commits
fc825f68
Commit
fc825f68
authored
Feb 12, 2018
by
Guilhem Saurel
Browse files
generate gitlab-ci.yml, show docker cmds
parent
060a8b1d
Changes
5
Hide whitespace changes
Inline
Side-by-side
Dockerfile
View file @
fc825f68
...
...
@@ -7,10 +7,6 @@ FROM ${REGISTRY}/${FROM}:${TARGET}
ARG
ROBOTPKG
ARG
ROBOTPKG_DEPS=true
ARG
ADDITIONAL_DEPENDENCIES=""
ARG
CHECKOUT=false
RUN
/get_deps.sh robotpkg-
${
ROBOTPKG
}
RUN
apt-get update
-qq
&&
apt-get
install
-qqy
\
$(
sort
-u
/system_deps
$(
${
ROBOTPKG_DEPS
}
&&
echo
/robotpkg_deps
))
\
${
ADDITIONAL_DEPENDENCIES
}
\
&&
rm
-rf
/var/lib/apt/lists/
*
RUN
/get_deps.sh robotpkg-
${
ROBOTPKG
}
$CHECKOUT
rainboard/management/commands/robotpkg.py
View file @
fc825f68
...
...
@@ -19,8 +19,9 @@ class Command(BaseCommand):
update_robotpkg
(
path
)
for
project
in
Project
.
objects
.
all
():
for
pkg
in
path
.
glob
(
f
'*/
{
project
.
slug
}
'
):
logger
.
info
(
f
'
{
project
}
found in
{
pkg
}
'
)
obj
,
created
=
Robotpkg
.
objects
.
get_or_create
(
name
=
pkg
.
name
,
category
=
pkg
.
parent
.
name
,
project
=
project
)
if
created
:
obj
.
update
(
pull
=
False
)
for
slug
in
[
project
.
slug
,
project
.
slug
.
replace
(
'_'
,
'-'
)]:
for
pkg
in
path
.
glob
(
f
'*/
{
slug
}
'
):
obj
,
created
=
Robotpkg
.
objects
.
get_or_create
(
name
=
pkg
.
name
,
category
=
pkg
.
parent
.
name
,
project
=
project
)
if
created
:
logger
.
info
(
f
'
{
project
}
found in
{
pkg
}
'
)
obj
.
update
(
pull
=
False
)
rainboard/models.py
View file @
fc825f68
...
...
@@ -5,6 +5,7 @@ from subprocess import check_output, CalledProcessError
from
django.conf
import
settings
from
django.db
import
models
from
django.template.loader
import
get_template
from
django.utils.dateparse
import
parse_datetime
from
django.utils.safestring
import
mark_safe
...
...
@@ -554,6 +555,12 @@ class Robotpkg(NamedModel):
self
.
save
()
def
valid_images
(
self
):
return
self
.
image_set
.
filter
(
created__isnull
=
False
)
def
gitlabciyml
(
self
):
return
get_template
(
'rainboard/gitlab-ci.yml'
).
render
({
'robotpkg'
:
self
})
class
RobotpkgBuild
(
TimeStampedModel
):
robotpkg
=
models
.
ForeignKey
(
Robotpkg
,
on_delete
=
models
.
CASCADE
)
...
...
@@ -583,15 +590,20 @@ class Image(models.Model):
def
build
(
self
):
args
=
self
.
get_build_args
()
build_args
=
sum
(([
'--build-arg'
,
f
'
{
key
}
=
{
value
}
'
]
for
key
,
value
in
args
.
items
()),
list
())
cmd
=
[
'docker'
,
'build'
,
'-t'
,
self
.
get_image_name
()]
+
build_args
+
[
'.'
]
return
' '
.
join
(
cmd
)
return
[
'docker'
,
'build'
,
'-t'
,
self
.
get_image_name
()]
+
build_args
+
[
'.'
]
def
pull
(
self
):
return
[
'docker'
,
'pull'
,
self
.
get_image_name
()]
def
push
(
self
):
return
[
'docker'
,
'push'
,
self
.
get_image_name
()]
def
update
(
self
):
image
=
check_output
([
'docker'
,
'images'
,
'-q'
,
self
.
get_image_name
()]).
decode
().
strip
()
if
not
image
:
try
:
logger
.
info
(
f
' pulling
{
self
}
'
)
check_output
(
[
'docker'
,
'pull'
,
self
.
get_image_name
()
]
)
check_output
(
self
.
pull
())
image
=
check_output
([
'docker'
,
'images'
,
'-q'
,
self
.
get_image_name
()]).
decode
().
strip
()
except
CalledProcessError
:
return
...
...
rainboard/templates/rainboard/gitlab-ci.yml
0 → 100644
View file @
fc825f68
variables
:
GIT_SSL_NO_VERIFY
:
"
true"
GIT_SUBMODULE_STRATEGY
:
"
recursive"
GIT_DEPTH
:
"
3"
NAMESPACE
:
{{
robotpkg.project.main_namespace.slug
}}
PROJECT
:
{{
robotpkg.project
}}
ROBOTPKG
:
{{
robotpkg
}}
CATEGORY
:
{{
robotpkg.category
}}
IMAGE
:
"
${CI_REGISTRY}/${NAMESPACE}/${PROJECT}"
cache
:
paths
:
-
build/ccache
.build
:
&build
before_script
:
-
mkdir -p build/ccache
-
cd build
-
export CCACHE_BASEDIR=${PWD}
-
export CCACHE_DIR=${PWD}/ccache
script
:
-
cd /root/robotpkg/${CATEGORY}/${ROBOTPKG}
-
make install
-
cd work.*/${ROBOTPKG}*/
-
make test
retry
:
2
except
:
-
gh-pages
{
%
for image in robotpkg.valid_images %
}
{{
image
}}
:
<<
:
*build
image
:
${IMAGE}:{{ image.get_target_display }}
{
%
endfor %
}
rainboard/templates/rainboard/project_detail.html
View file @
fc825f68
...
...
@@ -44,9 +44,12 @@
{% render_table table %}
{% if 'images' in request.path %}
<pre>
{% for image in object_list %}
{{ image.build }}
{% endfor %}
# Pull {% for image in object_list %}
{{ image.pull|join:' ' }}{% endfor %}
# Build {% for image in object_list %}
{{ image.build|join:' ' }}{% endfor %}
# Push {% for image in object_list %}
{{ image.push|join:' ' }}{% endfor %}
</pre>
{% endif %}
...
...
@@ -73,6 +76,11 @@
<dt>
Build page
</dt>
<dd><a
href=
"{{ rpkg.build_page }}"
>
{{ rpkg.build_page }}
</a></dd>
</dl>
<h4>
gitlab-ci configuration
</h4>
<pre>
{{ rpkg.gitlabciyml }}
</pre>
{% endfor %}
{% endif %}
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment