Skip to content
Snippets Groups Projects
.gitlab-ci.yml 3.76 KiB
Newer Older
stages:
 - install
 - test
Enrique Garcia's avatar
Enrique Garcia committed
 - build_containers
 - zenodo

.junit_template: &junit_definition
    artifacts:
      reports:
        junit: "junit*.xml"


  stage: install
  script:
    - apt-get -y update
    - eossr-codemeta2zenodo --help
    - eossr-codemeta2zenodo --input_codemeta_file ./codemeta.json
    - cat .zenodo.json
  only:
    - branches

    stage: test
    script:
      - apt-get -y update
      - pip install pytest pytest-cov
Vuillaume's avatar
Vuillaume committed
      - pip install -e .
      - pytest eossr/
        --junitxml=junit_py37.xml
        --color=yes
        --verbose
        --cov=eossr
        --cov-report=xml
        --cov-report=term
        --capture=no
      - apt update --yes && apt install --yes pandoc
      - pip install -U -r docs/doc_requirements.txt
      - sphinx-build docs _public
    artifacts:
      when: always
      paths:
        - junit_py37.xml
      reports:
        junit: junit_py37.xml
test_ci_eossr:
  stage: test
  trigger: escape2020/wp3/test_eossr

Enrique Garcia's avatar
Enrique Garcia committed
build_docker:
    stage: build_containers
    image: docker:19.03.12
    services:
        - docker:19.03.12-dind
    before_script:
        - cat /etc/os-release  # "Alpine Linux v3.12"
vuillaut's avatar
vuillaut committed
        - apk add --no-cache git
Enrique Garcia's avatar
Enrique Garcia committed
        - export LAST_RELEASE=`git ls-remote --tags --refs --sort="v:refname" $CI_PROJECT_URL.git | tail -n1 | sed 's/.*\///'`
        - echo $LAST_RELEASE
    script:
        - cd Docker
        - echo "$CI_REGISTRY_PASSWORD" | docker login -u "$CI_REGISTRY_USER" "$CI_REGISTRY" --password-stdin
Enrique Garcia's avatar
Enrique Garcia committed
        - docker build -t $CI_REGISTRY_IMAGE:$LAST_RELEASE .
        - docker push $CI_REGISTRY_IMAGE:$LAST_RELEASE
Vuillaume's avatar
Vuillaume committed
        - docker tag $CI_REGISTRY_IMAGE:$LAST_RELEASE $CI_REGISTRY_IMAGE:latest
        - docker push $CI_REGISTRY_IMAGE:latest
Enrique Garcia's avatar
Enrique Garcia committed
        # Save docker image into a tar file to be uploaded in next stage
        - docker save -o Docker_${CI_PROJECT_NAME}_$LAST_RELEASE.tar $CI_REGISTRY_IMAGE:$LAST_RELEASE
        - cd .. && mkdir -p container_build && cp Docker/*.tar container_build
        - ls container_build
Enrique Garcia's avatar
Enrique Garcia committed
    artifacts:
      paths:
        - container_build/Docker_*.tar
Enrique Garcia's avatar
Enrique Garcia committed
    only:
        - tags

build_docker_main:
    stage: build_containers
    image: docker:19.03.12
    services:
        - docker:19.03.12-dind
    before_script:
        - cat /etc/os-release  # "Alpine Linux v3.12"
    script:
        - echo "$CI_REGISTRY_PASSWORD" | docker login -u "$CI_REGISTRY_USER" "$CI_REGISTRY" --password-stdin
        - docker build -t $CI_REGISTRY_IMAGE:dev Docker
        - docker push $CI_REGISTRY_IMAGE:dev
    only:
        - master


deploy_zenodo:
  stage: zenodo
Vuillaume's avatar
Vuillaume committed
  image: gitlab-registry.in2p3.fr/escape2020/wp3/eossr:latest
Enrique Garcia's avatar
Enrique Garcia committed
  dependencies:
    - build_docker
  before_script:
    - eossr-check-connection-zenodo --token $ZENODO_TOKEN --sandbox False -p $CI_PROJECT_DIR
    - mkdir -p /zenodo_build && cp container_build/* /zenodo_build
    - rm -rf container_build
  script:
    - gitlab_prepare_upload_zenodo.sh $CI_PROJECT_NAME $CI_PROJECT_DIR /zenodo_build
    - ls /zenodo_build

    - eossr-upload-repository -t $ZENODO_TOKEN -s False -i /zenodo_build -id $ZENODO_RECORD_ID
vuillaut's avatar
vuillaut committed
    stage: deploy_pages
    image: ubuntu:latest
    script:
vuillaut's avatar
vuillaut committed
      - apt update --yes && apt install --yes pandoc pip git
      - git fetch --all --tags
Vuillaume's avatar
Vuillaume committed
      - git checkout $CI_COMMIT_REF_NAME
vuillaut's avatar
vuillaut committed
      - pip install -U -r docs/doc_requirements.txt
      - pip install .
      - sphinx-multiversion docs _public
      - mv _public public  # make sure we overwrite public dir
Vuillaume's avatar
Vuillaume committed
      - cp -r $CI_COMMIT_REF_NAME/* .
      - for t in `git tag`; do echo $t; sed -i -e "s~../$t/index.html~$t/index.html~" "index.html" ; done
      - cd -
vuillaut's avatar
vuillaut committed
    artifacts:
      paths:
        - public
    only:
      - master