Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
utility
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
bioroboticslab
biotracker
utility
Commits
4a9d8bb8
Commit
4a9d8bb8
authored
5 years ago
by
calrama
Browse files
Options
Downloads
Patches
Plain Diff
Update ci/cd
parent
b5146e3d
No related branches found
No related tags found
No related merge requests found
Pipeline
#18643
failed
5 years ago
Stage: build
Stage: package
Stage: deploy
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
.gitlab-ci.py
+161
-0
161 additions, 0 deletions
.gitlab-ci.py
.gitlab-ci.yml
+37
-54
37 additions, 54 deletions
.gitlab-ci.yml
with
198 additions
and
54 deletions
.gitlab-ci.py
0 → 100755
+
161
−
0
View file @
4a9d8bb8
#! /usr/bin/env python3
import
tarfile
import
shutil
import
ssl
from
os
import
environ
as
env
,
symlink
from
platform
import
system
from
subprocess
import
check_call
,
check_output
,
DEVNULL
from
argparse
import
ArgumentParser
from
io
import
BytesIO
from
urllib.request
import
Request
,
urlopen
from
urllib.parse
import
quote
,
urlencode
from
zipfile
import
ZipFile
from
pathlib
import
Path
def
define
(
key
:
str
,
value
:
str
):
return
[
'
-D
'
,
f
'
{
key
}
=
{
value
}
'
]
def
define_env
(
name
:
str
):
return
define
(
name
,
env
[
name
])
if
name
in
env
else
[]
def
fetch_artifacts
(
project
,
reference
,
job
):
gitlab_host
=
'
https://git.imp.fu-berlin.de
'
project
=
quote
(
project
,
safe
=
""
)
reference
=
quote
(
reference
,
safe
=
""
)
params
=
urlencode
([(
"
job
"
,
job
)],
doseq
=
True
)
url
=
f
'
{
gitlab_host
}
/api/v4/projects/
{
project
}
/jobs/artifacts/
{
reference
}
/download?
{
params
}
'
headers
=
{
'
JOB-TOKEN
'
:
env
[
'
CI_JOB_TOKEN
'
]}
return
ZipFile
(
BytesIO
(
urlopen
(
Request
(
url
,
headers
=
headers
),
context
=
ssl
.
_create_unverified_context
()).
read
()
)
)
def
extract_cmake_package
(
artifacts
,
name
):
for
filename
in
artifacts
.
namelist
():
if
Path
(
filename
).
match
(
f
'
{
name
}
-*.tar.xz
'
):
with
tarfile
.
open
(
fileobj
=
BytesIO
(
artifacts
.
read
(
filename
)))
as
f
:
f
.
extractall
(
'
vendor
'
)
shutil
.
move
(
next
(
Path
(
'
vendor
'
).
glob
(
f
'
{
name
}
-*/
'
)),
f
'
vendor/
{
name
}
'
)
def
enable_cmake_package_discovery
(
name
):
if
system
()
==
'
Windows
'
:
check_call
(
[
'
powershell
'
,
'
&
'
,
'
cmd.exe
'
,
'
/c
'
,
'
mklink
'
,
'
/J
'
,
f
'"
C:/Program Files/
{
name
}
"'
,
f
'"
$(resolve-path vendor/
{
name
}
)
"'
],
stdout
=
DEVNULL
)
elif
system
()
==
'
Linux
'
:
symlink
(
Path
(
f
'
vendor/
{
name
}
'
).
resolve
(),
f
'
/usr/local/
{
name
}
'
)
else
:
assert
False
def
integrate_cmake_package
(
artifacts
,
name
):
extract_cmake_package
(
artifacts
,
name
)
enable_cmake_package_discovery
(
name
)
if
system
()
==
'
Windows
'
:
def
setup_msvc
():
msvc_path
=
'
C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/Common7/Tools
'
lines
=
check_output
(
[
'
cmd
'
,
'
/c
'
,
'
VsDevCmd.bat
'
,
'
-arch=amd64
'
,
f
'
-vcvars_ver=
{
env
[
"
VCVARS_VER
"
]
}
'
,
'
&
'
,
'
set
'
],
cwd
=
msvc_path
).
decode
(
'
utf-8
'
).
splitlines
()
for
line
in
lines
:
split
=
line
.
split
(
'
=
'
)
if
len
(
split
)
!=
2
:
continue
key
,
value
=
split
if
key
in
env
and
env
[
key
]
==
value
:
continue
env
[
key
]
=
value
def
prepare
(
args
):
for
name
,
project
,
reference
,
job
in
args
.
dependencies
:
with
fetch_artifacts
(
project
,
reference
,
job
)
as
artifacts
:
integrate_cmake_package
(
artifacts
,
name
)
def
build
(
args
):
if
system
()
==
'
Windows
'
:
setup_msvc
()
command
=
[
'
cmake
'
]
command
+=
[
'
-S
'
,
'
.
'
]
command
+=
[
'
-B
'
,
'
build
'
]
command
+=
[
'
-G
'
,
'
Ninja
'
]
command
+=
define_env
(
'
CMAKE_BUILD_TYPE
'
)
command
+=
define
(
'
CMAKE_SUPPRESS_REGENERATION
'
,
'
ON
'
)
command
+=
define
(
'
CMAKE_SKIP_PACKAGE_ALL_DEPENDENCY
'
,
'
ON
'
)
if
system
()
==
'
Windows
'
:
command
+=
define
(
'
CMAKE_TOOLCHAIN_FILE
'
,
env
[
'
VCPKG_DIR
'
]
+
'
/scripts/buildsystems/vcpkg.cmake
'
)
command
+=
define
(
'
VCPKG_TARGET_TRIPLET
'
,
env
[
'
VCPKG_TRIPLET
'
])
check_call
(
command
)
command
=
[
'
ninja
'
,
'
-C
'
,
'
build
'
]
check_call
(
command
)
def
package
(
args
):
command
=
[
'
ninja
'
,
'
-C
'
,
'
build
'
,
'
package
'
]
check_call
(
command
)
if
__name__
==
'
__main__
'
:
parser
=
ArgumentParser
()
subparsers
=
parser
.
add_subparsers
()
prepare_parser
=
subparsers
.
add_parser
(
'
prepare
'
)
prepare_parser
.
set_defaults
(
task
=
prepare
)
prepare_parser
.
add_argument
(
'
--dependency
'
,
dest
=
'
dependencies
'
,
nargs
=
4
,
action
=
'
append
'
,
metavar
=
(
'
PACKAGE
'
,
'
PROJECT
'
,
'
REFERENCE
'
,
'
JOB
'
)
)
build_parser
=
subparsers
.
add_parser
(
'
build
'
)
build_parser
.
set_defaults
(
task
=
build
)
package_parser
=
subparsers
.
add_parser
(
'
package
'
)
package_parser
.
set_defaults
(
task
=
package
)
args
=
parser
.
parse_args
()
args
.
task
(
args
)
This diff is collapsed.
Click to expand it.
.gitlab-ci.yml
+
37
−
54
View file @
4a9d8bb8
...
...
@@ -3,13 +3,14 @@ stages:
-
package
-
deploy
.ubuntu-18.04
:
tags
:
[
linux
,
docker
]
image
:
git.imp.fu-berlin.de:5000/bioroboticslab/robofish/docker:devel-ubuntu18.04
.windows
:
tags
:
[
windows
,
docker
]
image
:
git.imp.fu-berlin.de:5000/bioroboticslab/robofish/docker:devel-windows
.windows
-1809
:
tags
:
[
windows
-1809
,
docker
]
image
:
git.imp.fu-berlin.de:5000/bioroboticslab/robofish/docker:devel-windows
1809
.gcc8
:
&gcc8
...
...
@@ -17,65 +18,50 @@ stages:
CXX
:
g++-8
.msvc15.9
:
&msvc15_9
VSDevEnv -arch=amd64 -vcvars_ver="14.16"
.debug
:
&debug
CMAKE_BUILD_TYPE
:
Debug
VCVARS_VER
:
'
14.16'
.release
:
&release
CMAKE_BUILD_TYPE
:
Release
.debug
:
&debug
CMAKE_BUILD_TYPE
:
Debug
.build ubuntu-18.04
:
extends
:
.ubuntu-18.04
stage
:
build
artifacts
:
paths
:
-
build
expire_in
:
1 day
script
:
-
cmake -Bbuild -H. -DCMAKE_BUILD_TYPE="$CMAKE_BUILD_TYPE" -G Ninja -DCMAKE_SUPPRESS_REGENERATION=ON -DCMAKE_SKIP_PACKAGE_ALL_DEPENDENCY=ON
-
ninja -C build
.build windows
:
extends
:
.windows
.build
:
&build
stage
:
build
artifacts
:
paths
:
-
build
expire_in
:
1 day
script
:
-
cmake -Bbuild "-H." -DCMAKE_BUILD_TYPE="$CMAKE_BUILD_TYPE" -G Ninja -DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_DIR/scripts/buildsystems/vcpkg.cmake" -DVCPKG_TARGET_TRIPLET="$env:VCPKG_TRIPLET" -DCMAKE_SUPPRESS_REGENERATION=ON -DCMAKE_SKIP_PACKAGE_ALL_DEPENDENCY=ON
-
ninja -C build
script
:
./.gitlab-ci.py build
build ubuntu-18.04
:
extends
:
.build ubuntu-18.04
extends
:
.ubuntu-18.04
<<
:
*build
variables
:
<<
:
[
*gcc8
,
*release
]
before_script
:
-
. /etc/profile.d/robofish.sh
-
gitlab-fetch-artifacts bioroboticslab%2Fbiotracker%2Finterfaces master package%20ubuntu-18.04
-
cmake-integrate-package biotracker-interfaces
-
./.gitlab-ci.py prepare
--dependency robofish-interfaces bioroboticslab/robofish/interfaces master 'package ubuntu-18.04'
build windows
:
extends
:
.build windows
build windows-1809
:
extends
:
.windows-1809
<<
:
*build
variables
:
<<
:
[
*release
]
<<
:
[
*msvc15_9
,
*release
]
before_script
:
-
. $Profile
-
*msvc15_9
-
GitLab-Fetch-Artifacts bioroboticslab%2Fbiotracker%2Finterfaces master package%20windows
-
CMake-Integrate-Package biotracker-interfaces
-
./.gitlab-ci.py prepare
--dependency robofish-interfaces bioroboticslab/robofish/interfaces master 'package windows-1809'
build windows[debug]
:
extends
:
.build windows
build windows-1809[debug]
:
extends
:
.windows-1809
<<
:
*build
variables
:
<<
:
[
*debug
]
<<
:
[
*msvc15_9
,
*debug
]
before_script
:
-
. $Profile
-
*msvc15_9
-
GitLab-Fetch-Artifacts bioroboticslab%2Fbiotracker%2Finterfaces master package%20windows%5bdebug%5d
-
CMake-Integrate-Package biotracker-interfaces
-
./.gitlab-ci.py prepare
--dependency robofish-interfaces bioroboticslab/robofish/interfaces master 'package windows-1809[debug]'
.package
:
&package
stage
:
package
...
...
@@ -83,8 +69,7 @@ build windows[debug]:
paths
:
-
build/*.tar.xz
expire_in
:
1 week
script
:
-
ninja -C build package
script
:
./.gitlab-ci.py package
package ubuntu-18.04
:
extends
:
.ubuntu-18.04
...
...
@@ -92,22 +77,20 @@ package ubuntu-18.04:
-
build ubuntu-18.04
<<
:
*package
package windows
:
extends
:
.windows
package windows
-1809
:
extends
:
.windows
-1809
dependencies
:
-
build windows
-
build windows
-1809
<<
:
*package
package windows[debug]
:
extends
:
.windows
package windows
-1809
[debug]
:
extends
:
.windows
-1809
dependencies
:
-
build windows[debug]
-
build windows
-1809
[debug]
<<
:
*package
trigger dependents
:
extends
:
.ubuntu-18.04
stage
:
deploy
script
:
-
. /etc/profile.d/robofish.sh
-
gitlab-trigger-pipeline bioroboticslab%2Fbiotracker%2Fbiotracker $CI_JOB_TOKEN master
trigger robofish/robo_control
:
stage
:
deploy
trigger
:
project
:
bioroboticslab/biotracker/biotracker
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