Skip to content
GitLab
Menu
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
7e5744da
Commit
7e5744da
authored
Mar 07, 2019
by
Guilhem Saurel
Browse files
cijob
parent
42fda413
Pipeline
#3374
failed with stages
in 1 minute and 11 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
rainboard/migrations/0032_cijob.py
0 → 100644
View file @
7e5744da
# Generated by Django 2.1.7 on 2019-03-07 01:27
from
django.db
import
migrations
,
models
import
django.db.models.deletion
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'rainboard'
,
'0031_started'
),
]
operations
=
[
migrations
.
CreateModel
(
name
=
'CIJob'
,
fields
=
[
(
'id'
,
models
.
AutoField
(
auto_created
=
True
,
primary_key
=
True
,
serialize
=
False
,
verbose_name
=
'ID'
)),
(
'passed'
,
models
.
NullBooleanField
()),
(
'job_id'
,
models
.
PositiveIntegerField
()),
(
'started'
,
models
.
DateTimeField
()),
(
'branch'
,
models
.
ForeignKey
(
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
to
=
'rainboard.Branch'
)),
(
'repo'
,
models
.
ForeignKey
(
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
to
=
'rainboard.Repo'
)),
],
options
=
{
'ordering'
:
(
'-started'
,),
},
),
]
rainboard/models.py
View file @
7e5744da
...
...
@@ -4,6 +4,7 @@ import re
from
subprocess
import
check_output
from
django.conf
import
settings
from
django.core.mail
import
mail_admins
from
django.db
import
models
from
django.db.models
import
Q
from
django.db.models.functions
import
Length
...
...
@@ -313,6 +314,10 @@ class Project(Links, NamedModel, TimeStampedModel):
branch
=
str
(
self
.
main_branch
()).
split
(
'/'
,
maxsplit
=
2
)[
2
]
self
.
git
().
head
.
commit
=
self
.
git
().
remotes
[
self
.
main_repo
().
git_remote
()].
refs
[
branch
].
commit
def
ci_jobs
(
self
):
if
self
.
main_forge
.
source
==
SOURCES
.
gitlab
:
self
.
main_repo
().
get_jobs_gitlab
()
def
update
(
self
,
only_main_branches
=
True
):
if
self
.
main_namespace
is
None
:
return
...
...
@@ -333,6 +338,7 @@ class Project(Links, NamedModel, TimeStampedModel):
self
.
updated
=
robotpkg
.
updated
else
:
self
.
updated
=
max
(
branch
.
updated
,
robotpkg
.
updated
)
self
.
ci_jobs
()
self
.
checkout
()
self
.
cmake
()
self
.
ros
()
...
...
@@ -536,7 +542,7 @@ class Repo(TimeStampedModel):
branch
,
created
=
Branch
.
objects
.
get_or_create
(
name
=
branch_name
,
project
=
self
.
project
,
repo
=
self
)
if
created
:
branch
.
update
()
CIBuild
.
objects
.
get_or_create
(
ci_build
,
created
=
CIBuild
.
objects
.
get_or_create
(
repo
=
self
,
build_id
=
pid
,
defaults
=
{
...
...
@@ -544,6 +550,37 @@ class Repo(TimeStampedModel):
'started'
:
parse_datetime
(
data
[
'created_at'
]),
'branch'
:
branch
,
})
if
not
created
and
ci_build
.
passed
!=
GITLAB_STATUS
[
pipeline
[
'status'
]]:
ci_build
.
passed
=
GITLAB_STATUS
[
pipeline
[
'status'
]]
ci_build
.
save
()
def
get_jobs_gitlab
(
self
):
for
data
in
self
.
api_list
(
'/jobs'
):
branch_name
=
f
'
{
self
.
forge
.
slug
}
/
{
self
.
namespace
.
slug
}
/
{
ref
}
'
branch
,
created
=
Branch
.
objects
.
get_or_create
(
name
=
branch_name
,
project
=
self
.
project
,
repo
=
self
)
if
created
:
branch
.
update
()
ci_job
,
created
=
CIJob
.
objects
.
get_or_create
(
repo
=
self
,
job_id
=
data
[
'id'
],
defaults
=
{
'passed'
:
GITLAB_STATUS
[
data
[
'status'
]],
'started'
:
parse_datetime
(
data
[
'created_at'
]),
'branch'
:
branch
,
})
if
not
created
and
ci_job
.
passed
!=
GITLAB_STATUS
[
data
[
'status'
]]:
ci_job
.
passed
=
GITLAB_STATUS
[
data
[
'status'
]]
ci_job
.
save
()
if
self
==
self
.
project
.
main_repo
()
and
data
[
'name'
].
startswith
(
'robotpkg-'
):
py3
=
'-py3'
in
data
[
'name'
]
debug
=
'-debug'
in
data
[
'name'
]
target
=
next
(
target
for
target
in
Target
.
objects
.
all
()
if
target
.
name
in
data
[
'name'
]).
name
robotpkg
=
data
[
'name'
][
9
:
-
(
2
+
len
(
target
)
+
(
5
if
debug
else
7
)
+
(
3
if
py3
else
0
))]
# shame.
image
=
Image
.
objects
.
get
(
robotpkg__name
=
robotpkg
,
target__name
=
target
,
debug
=
debug
,
py3
=
py3
)
if
image
.
allow_failure
and
GITLAB_STATUS
[
data
[
'status'
]]:
mail_admins
(
'Success !'
,
'allow_failure est devenu inutile sur '
+
data
[
'web_url'
])
image
.
allow_failure
=
False
image
.
save
()
def
get_builds_github
(
self
):
if
self
.
travis_id
is
not
None
:
...
...
@@ -842,6 +879,17 @@ class CIBuild(models.Model):
return
f
'
{
self
.
repo
.
forge
.
url
}
/
{
self
.
repo
.
namespace
.
slug
}
/
{
self
.
repo
.
slug
}
/pipelines/
{
self
.
build_id
}
'
class
CIJob
(
models
.
Model
):
repo
=
models
.
ForeignKey
(
Repo
,
on_delete
=
models
.
CASCADE
)
passed
=
models
.
NullBooleanField
()
job_id
=
models
.
PositiveIntegerField
()
started
=
models
.
DateTimeField
()
branch
=
models
.
ForeignKey
(
Branch
,
on_delete
=
models
.
CASCADE
)
class
Meta
:
ordering
=
(
'-started'
,
)
class
Tag
(
models
.
Model
):
name
=
models
.
CharField
(
max_length
=
200
)
slug
=
AutoSlugField
(
populate_from
=
'name'
,
slugify
=
slugify_with_dots
)
...
...
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