.gitlab-ci.yml
508bab90
 image: gitlab.kwant-project.org:5005/kwant/kwant
164f611b
 
 stages:
508bab90
   - build-env
164f611b
   - build
   - test
   - deploy
2226d2c6
   - release
164f611b
 
836179ed
 variables:
   # rsync is used to send documentation to our web servers: we never send any
   # secret information, and using 'ssh-keyscan' causes the CI server's IP to be blacklisted
   IGNORE_HOSTKEY: "ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
 
508bab90
 ## Building Docker environments
 ## Only runs when docker specifications change
 
 .build-env: &build-env
   stage: build-env
23d8df7b
   when: manual
508bab90
   image:
     name: gcr.io/kaniko-project/executor:debug
     entrypoint: [""]
   artifacts:
     untracked: true
     expire_in: 1 hour
   before_script:
8d71370f
     - mkdir -p /kaniko/.docker
     - echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
508bab90
 
 build-env:ubuntu:
   <<: *build-env
   script:
     - /kaniko/executor
       --context $CI_PROJECT_DIR/docker
       --dockerfile $CI_PROJECT_DIR/docker/Dockerfile.ubuntu
       --destination $CI_REGISTRY_IMAGE/ubuntu
 
 build-env:debian:
   <<: *build-env
   script:
     - /kaniko/executor
       --context $CI_PROJECT_DIR/docker
       --dockerfile $CI_PROJECT_DIR/docker/Dockerfile.debian
       --destination $CI_REGISTRY_IMAGE/debian
 
 build-env:conda:
   <<: *build-env
   script:
     - /kaniko/executor
       --context $CI_PROJECT_DIR/docker
       --dockerfile $CI_PROJECT_DIR/docker/Dockerfile.conda
       --destination $CI_REGISTRY_IMAGE/conda
 
 build-env:default:
   <<: *build-env
   script:
     - /kaniko/executor
       --context $CI_PROJECT_DIR/docker
       --dockerfile $CI_PROJECT_DIR/docker/Dockerfile.conda
       --destination $CI_REGISTRY_IMAGE
 
 
 ## Build environment specifications
cdc57cf1
 
f04429f9
 .build: &build
164f611b
   stage: build
   script:
10faf93a
     - echo -e "[DEFAULT]\ndefine_macros = CYTHON_TRACE=1" >build.conf
     - ./setup.py build
     - ./setup.py build_ext -i
164f611b
   artifacts:
     untracked: true
01d8d277
     expire_in: 2 hour
164f611b
 
f04429f9
 
 .stable-env: &stable_env
   before_script:
     - source deactivate
     - source activate kwant-stable
 
 .no-extras-env: &no_extras_env
   before_script:
     - source deactivate
     - source activate kwant-stable-no-extras
 
 # Note that this is 'latest' as of when the image was last built
 .latest-env: &latest_env
   before_script:
     - source deactivate
     - source activate kwant-latest
 
 .bleeding-edge-env: &bleeding_edge_env
   before_script:
     - source deactivate
     - conda env update -f /kwant-latest.yml
     - source activate kwant-latest
 
 .ubuntu-env: &ubuntu_env
508bab90
   image: gitlab.kwant-project.org:5005/kwant/kwant/ubuntu
f04429f9
 
 .debian-env: &debian_env
508bab90
   image: gitlab.kwant-project.org:5005/kwant/kwant/debian
f04429f9
 
 ## Build Jobs
 
 build:ubuntu:
   <<: *build
   <<: *ubuntu_env
 
 build:debian:
   <<: *build
   <<: *debian_env
 
 build:stable:
   <<: *build
   <<: *stable_env
 
 build:no-extras:
   <<: *build
   <<: *no_extras_env
 
 build:latest:
   <<: *build
   <<: *latest_env
 
 build:bleeding-edge:
   <<: *build
   <<: *bleeding_edge_env
   only:
     - schedules
0ef812ea
   allow_failure: true
f04429f9
 
 ## Test Jobs
 
14f7021f
 check whitespace style:
f04429f9
   stage: test
17f57352
   script: ./check_whitespace
164f611b
   allow_failure: true
 
 check for dependencies installed:
   stage: test
   script:
     - if [ -d .eggs ]; then echo "$(ls -d .eggs/*/) downloaded by build, update build environment" >&2; fi
   allow_failure: true
 
cdc57cf1
 
f04429f9
 .test: &test
   stage: test
   script:
1da7f5ec
     - py.test -r w --flakes kwant --junitxml=tests.xml --durations=10
f04429f9
   artifacts:
7e7c3d94
     reports:
       junit: tests.xml
f04429f9
 
99963152
 .coverage: &coverage
   stage: test
   script:
     - py.test -r w --cov=kwant --cov-report term --cov-report html --flakes kwant --junitxml=tests.xml --durations=10
   artifacts:
     paths:
       - htmlcov
     reports:
       junit: tests.xml
 
f04429f9
 
 test:stable:
   <<: *test
   <<: *stable_env
   dependencies:
     - build:stable
 
 test:no-extras:
   <<: *test
   <<: *no_extras_env
   dependencies:
     - build:no-extras
 
 test:ubuntu:
   <<: *test
   <<: *ubuntu_env
   dependencies:
     - build:ubuntu
 
 test:debian:
   <<: *test
   <<: *debian_env
   dependencies:
     - build:debian
 
 test:latest:
   <<: *test
   <<: *latest_env
   dependencies:
     - build:latest
 
 test:bleeding-edge:
   <<: *test
   <<: *bleeding_edge_env
   dependencies:
     - build:bleeding-edge
   only:
     - schedules
0ef812ea
   allow_failure: true
f04429f9
 
c7eefacb
 coverage:latest:
   <<: *coverage
   <<: *latest_env
99963152
   dependencies:
     - build:latest
   only:
     - schedules
 
f04429f9
 ## Documentation building
 
164f611b
 build documentation:
f04429f9
   <<: *latest_env
   dependencies:
     - build:latest
164f611b
   stage: test
   script:
50334476
     - make -C doc clean; make -C doc html SPHINXOPTS='-A website_deploy=True -n -W -D jupyter_execute_default_kernel=kwant-latest' SOURCE_LINK_TEMPLATE="$CI_PROJECT_URL"/blob/\$\$r/\$\$f
164f611b
   artifacts:
     paths:
       - doc/build/html/
     expire_in: 1 month
 
4ff5a572
 build PDF documentation:
f04429f9
   <<: *latest_env
   dependencies:
     - build:latest
4ff5a572
   stage: test
   script:
9fc01a7e
     - make -C doc latex SPHINXOPTS='-n -W -D jupyter_execute_default_kernel=kwant-latest'
4ff5a572
     - cd doc/build/latex
     - make all-pdf
   artifacts:
     paths:
       - doc/build/latex/kwant.pdf
     expire_in: 1 month
cdc57cf1
 
164f611b
 check for broken links in doc:
f04429f9
   <<: *latest_env
   dependencies:
     - build:latest
164f611b
   stage: test
   script:
     - make -C doc linkcheck
   allow_failure: true
 
819abe25
 
99963152
 ## Upload coverage reports and dev documentation
 
 upload coverage:
   stage: deploy
   only:
     - schedules
   dependencies:
     - coverage:latest
   environment:
     name: coverage/$CI_BUILD_REF_NAME
     url: https://kwant-project.org/coverage/$CI_BUILD_REF_SLUG
     on_stop: remove_coverage
   before_script:
     - mkdir -p ~/.ssh
     - echo $MASTER_WEBSITE_KEY | base64 -d > ~/.ssh/id_rsa && chmod 600 ~/.ssh/id_rsa
   script:
     - mv htmlcov $CI_BUILD_REF_SLUG
     - rsync -rlv -e "$IGNORE_HOSTKEY" --delete --relative $CI_BUILD_REF_SLUG kwant@kwant-project.org:coverage/
   after_script:
     - rm -rf ~/.ssh
 
 
 remove_coverage:
   stage: deploy
   only:
     - branches@kwant/kwant
   when: manual
   environment:
     name: coverage/$CI_BUILD_REF_NAME
     action: stop
   before_script:
     - mkdir -p ~/.ssh
     - echo $MASTER_WEBSITE_KEY | base64 -d > ~/.ssh/id_rsa && chmod 600 ~/.ssh/id_rsa
   script:
     - mkdir empty/
     - rsync -rlv -e "$IGNORE_HOSTKEY" --delete empty/ kwant@kwant-project.org:coverage/$CI_BUILD_REF_SLUG
   after_script:
     - rm -rf ~/.ssh
adce1705
 
 
164f611b
 upload documentation to the test server:
   stage: deploy
417b887d
   environment:
     name: docs review/$CI_BUILD_REF_NAME
     url: https://test.kwant-project.org/doc/$CI_BUILD_REF_SLUG
     on_stop: remove_docs
164f611b
   only:
     - branches@kwant/kwant
417b887d
   before_script:
836179ed
     - mkdir -p ~/.ssh
417b887d
     - echo $TEST_WEBSITE_KEY | base64 -d > ~/.ssh/id_rsa && chmod 600 ~/.ssh/id_rsa
164f611b
   script:
836179ed
     - rsync -rlv -e "$IGNORE_HOSTKEY" --delete doc/build/html/* kwant@kwant-project.org:doc/$CI_BUILD_REF_SLUG
417b887d
   after_script:
     - rm -rf ~/.ssh
 
 
 remove_docs:
   stage: deploy
   when: manual
adce1705
   only:
     - branches@kwant/kwant
417b887d
   environment:
     name: docs review/$CI_BUILD_REF_NAME
     action: stop
   before_script:
836179ed
     - mkdir -p ~/.ssh
164f611b
     - echo $TEST_WEBSITE_KEY | base64 -d > ~/.ssh/id_rsa && chmod 600 ~/.ssh/id_rsa
417b887d
   script:
     - mkdir empty
836179ed
     - rsync -arv -e "$IGNORE_HOSTKEY" --delete empty/ kwant@kwant-project.org:doc/$CI_BUILD_REF_SLUG/
417b887d
   after_script:
164f611b
     - rm -rf ~/.ssh
 
417b887d
 
164f611b
 upload dev version docs:
   stage: deploy
417b887d
   environment:
     name: production
     url: https://kwant-project.org/doc/dev
164f611b
   only:
     - master@kwant/kwant
417b887d
   before_script:
836179ed
     - mkdir -p ~/.ssh
164f611b
     - echo $MASTER_WEBSITE_KEY | base64 -d > ~/.ssh/id_rsa && chmod 600 ~/.ssh/id_rsa
417b887d
   script:
836179ed
     - rsync -rlv -e "$IGNORE_HOSTKEY" --delete doc/build/html/* kwant@kwant-project.org:doc/dev
417b887d
   after_script:
164f611b
     - rm -rf ~/.ssh
 
f04429f9
 
 ## Build documentation for tagged releases
cdc57cf1
 
2226d2c6
 .tagged-version: &tagged_version
     only:
        - /^v[0-9]+\.[0-9]+.[0-9]+$/@kwant/kwant
 
 gather release artifacts:
   <<: *tagged_version
   stage: release
417b887d
   script:
2226d2c6
     - ./setup.py sdist
     - mkdir docs
     - mv doc/build/latex/kwant.pdf docs/kwant-doc-${CI_COMMIT_TAG//v}.pdf
     - mv doc/build/html docs/html
     - zip -r docs/kwant-doc-${CI_COMMIT_TAG//v}.zip docs/html
   artifacts:
     paths:
       - docs
       - dist