Skip to content
Snippets Groups Projects
.gitlab-ci.yml 2.58 KiB
Newer Older
before_script:
Jan Caron's avatar
Jan Caron committed
    # Install requirements for empyre:
    - conda env create -q # -q: quiet/ no progressbar, because it spams the log!
Jan Caron's avatar
Jan Caron committed
    - conda init bash
    - source ~/.bashrc
    - conda activate empyre
    - conda info --envs
Jan Caron's avatar
Jan Caron committed
    # Install jutil via deploy token access:  # TODO: still needed?
    #- pip install git+https://empyre:"$JUTIL_DEPLOY_TOKEN"@jugit.fz-juelich.de/j.ungermann/jutil.git
Jan Caron's avatar
Jan Caron committed
stages:
    - test
Jan Caron's avatar
Jan Caron committed
    - deploy
Jan Caron's avatar
Jan Caron committed
test_style:
    stage: test
Jan Caron's avatar
Jan Caron committed
    image: continuumio/miniconda3:latest
Jan Caron's avatar
Jan Caron committed
    script:
        # -m: only run tests marked with "flake8"
Jan Caron's avatar
Jan Caron committed
        - pyroma .  # Checks setup.py for cheese!
Jan Caron's avatar
Jan Caron committed
        - python setup.py test --addopts "--flake8 -m flake8"
Jan Caron's avatar
Jan Caron committed
test_function:
    stage: test
Jan Caron's avatar
Jan Caron committed
    image: continuumio/miniconda3:latest
    script:
        # Execute all tests and also check coverage with --cov:
        - python setup.py test --addopts "--cov"
Jan Caron's avatar
Jan Caron committed
    artifacts:
        paths:
            - .coverage
        expire_in: 1 week
Jan Caron's avatar
Jan Caron committed
test_docs:
    stage: test
Jan Caron's avatar
Jan Caron committed
    image: continuumio/miniconda3:latest
Jan Caron's avatar
Jan Caron committed
    script:
Jan Caron's avatar
Jan Caron committed
        # -f: Force overwriting of any existing generated files.
        # -e: Put documentation for each module on its own page.
        # -o: Directory to place the output files. If it does not exist, it is created.
        # last parameter: module path
        - sphinx-apidoc -f -e -o docs/api src/empyre
        # Build the documentation from 'docs' and put into 'build/sphinx':
        - sphinx-build docs build/sphinx
Jan Caron's avatar
Jan Caron committed
    artifacts:
        paths:
            - build/sphinx
        expire_in: 1 week
test_install:
    stage: test
    image: continuumio/miniconda3:latest
    script:
        - pip install .[all]

Jan Caron's avatar
Jan Caron committed
pages:
    stage: deploy
    image: busybox
    before_script: []  # before_script not needed here!
    script:
        - mkdir public
        - cp -r build/sphinx/* public/
        # -r: recursive, also copies subfolders!
    artifacts:
        paths:
            - public
    rules:
       - if:  '$CI_COMMIT_BRANCH == "master" || $CI_COMMIT_TAG =~ /^\d+\.\d+(\.\d+)?$/'
Jan Caron's avatar
Jan Caron committed

pypi:
    stage: deploy
    image: continuumio/miniconda3:latest
    before_script: []
    script:
        - pip install twine
        - python setup.py sdist bdist_wheel
Jan Caron's avatar
Jan Caron committed
        - twine upload -u __token__ -p $PYPI_ACCESS_TOKEN dist/*  # -u user -p password upload_source
Jan Caron's avatar
Jan Caron committed
    rules:  # similar to only/except, but newer!
        # Job is executed if branch is master AND if a tag is building which matches the regular expression!
        # ONLY executes if commit to master has a tag, ^:start, $:end, valid example: "1.2.3", no "-dev" at the end!
        - if: '$CI_COMMIT_TAG =~ /^\d+\.\d+(\.\d+)?$/'