Commit e5180f15 authored by Cresson Remi's avatar Cresson Remi
Browse files

Merge branch 'update_otbtf_version' into 'master'

ADD: use otbtf 3.2.1 in unit tests

See merge request !4
1 merge request!4ADD: use otbtf 3.2.1 in unit tests
Pipeline #36504 passed with stages
in 6 minutes and 33 seconds
Showing with 33 additions and 13 deletions
+33 -13
workflow: workflow:
rules: rules:
- if: $CI_MERGE_REQUEST_ID # Execute jobs in merge request context - if: $CI_MERGE_REQUEST_ID || $CI_COMMIT_REF_NAME =~ /master/ # Execute jobs in merge request context, or commit in master branch
- if: $CI_COMMIT_BRANCH == 'master' # Execute jobs when a new commit is pushed to master branch
stages: stages:
- Docker build - Docker build
- Static Analysis - Static Analysis
- Tests - Tests
- Ship
Build the docker image: .dind_base:
stage: Docker build
allow_failure: false
tags: [dind] tags: [dind]
image: docker/compose:1.29.2 image: docker/compose:1.29.2
variables: variables:
...@@ -24,6 +23,13 @@ Build the docker image: ...@@ -24,6 +23,13 @@ Build the docker image:
# we use $CI_REGISTRY_PASSWORD here which is a special variable provided by GitLab # we use $CI_REGISTRY_PASSWORD here which is a special variable provided by GitLab
# https://docs.gitlab.com/ce/ci/variables/predefined_variables.html # https://docs.gitlab.com/ce/ci/variables/predefined_variables.html
- echo -n $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY - echo -n $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY
Build the docker image:
stage: Docker build
allow_failure: false
extends: .dind_base
except:
- master
script: script:
- docker info - docker info
- > - >
...@@ -36,11 +42,9 @@ Build the docker image: ...@@ -36,11 +42,9 @@ Build the docker image:
--label "org.opencontainers.image.revision=$CI_COMMIT_SHA" --label "org.opencontainers.image.revision=$CI_COMMIT_SHA"
--label "org.opencontainers.image.version=$CI_COMMIT_REF_NAME" --label "org.opencontainers.image.version=$CI_COMMIT_REF_NAME"
--tag $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME --tag $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME
--build-arg "BASE_IMAGE=gitlab-registry.irstea.fr/remi.cresson/otbtf/otbtf3.0:cpu-basic-dev" --build-arg "BASE_IMAGE=gitlab-registry.irstea.fr/remi.cresson/otbtf/3.2.1:cpu-basic-dev"
. .
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME - docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME
- docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME $CI_REGISTRY_IMAGE:latest
- docker push $CI_REGISTRY_IMAGE:latest
.static_analysis_base: .static_analysis_base:
image: $CI_REGISTRY_IMAGE:latest image: $CI_REGISTRY_IMAGE:latest
...@@ -50,7 +54,7 @@ Build the docker image: ...@@ -50,7 +54,7 @@ Build the docker image:
flake8: flake8:
extends: .static_analysis_base extends: .static_analysis_base
script: script:
- sudo apt update && sudo apt install -y flake8 && python -m flake8 --max-line-length=120 $PWD/decloud - sudo apt update && sudo apt install -y flake8 && python -m flake8 -ignore=E402 --max-line-length=120 $PWD/decloud
pylint: pylint:
extends: .static_analysis_base extends: .static_analysis_base
...@@ -125,3 +129,13 @@ train_from_tfrecords: ...@@ -125,3 +129,13 @@ train_from_tfrecords:
script: script:
- pytest -o log_cli=true --log-cli-level=INFO --junitxml=report_train_from_tfrecords.xml tests/train_from_tfrecords_unittest.py - pytest -o log_cli=true --log-cli-level=INFO --junitxml=report_train_from_tfrecords.xml tests/train_from_tfrecords_unittest.py
deploy:
stage: Ship
only:
- master
extends: .dind_base
script:
- echo "Shipping!"
- docker pull $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME
- docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME $CI_REGISTRY_IMAGE:latest
- docker push $CI_REGISTRY_IMAGE:latest
...@@ -41,10 +41,16 @@ def get_commit_hash(): ...@@ -41,10 +41,16 @@ def get_commit_hash():
""" Return the git hash of the repository """ """ Return the git hash of the repository """
repo = git.Repo(os.path.dirname(os.path.realpath(__file__)), search_parent_directories=True) repo = git.Repo(os.path.dirname(os.path.realpath(__file__)), search_parent_directories=True)
commit_hash = "nohash"
try: try:
commit_hash = repo.active_branch.name + "_" + repo.head.object.hexsha[0:5] commit_hash = repo.head.object.hexsha[0:5]
except TypeError: except (ValueError, TypeError) as e:
commit_hash = 'DETACHED_' + repo.head.object.hexsha[0:5] print(f"Unable to get commit hash! {e}")
try:
commit_hash = repo.active_branch.name + "_" + commit_hash
except (ValueError, TypeError) as e:
print(f"Unable to get branch name! {e}")
return commit_hash return commit_hash
...@@ -55,7 +61,7 @@ def get_directories(root): ...@@ -55,7 +61,7 @@ def get_directories(root):
:param root: root directory :param root: root directory
:return: list of directories :return: list of directories
""" """
return [pathify(root) + item for item in os.listdir(root)] return [os.path.join(root, item) for item in os.listdir(root)]
def get_files(directory, ext=None): def get_files(directory, ext=None):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment