Skip to content
Snippets Groups Projects
.gitlab-ci.yml 7.76 KiB
Newer Older
  - test # this checks the viability of the code
  - documentation-assets # this builds assets to be included in documentation
  - documentation # this processes the documentation
  - test-compat # this runs many additional compatibility tests
  GIT_STRATEGY: clone
  DOCKER_DRIVER: overlay2
  DOCKER_TLS_CERTDIR: ""

#
# Predefined conditions for triggering jobs
#

.global_trigger_check_incoming_code: &global_trigger_check_incoming_code
  rules:
    - if: $CI_PIPELINE_SOURCE == "external_pull_request_event"
.global_trigger_build_doc: &global_trigger_build_doc
    - if: $CI_COMMIT_BRANCH == "develop"
    - if: $CI_COMMIT_TAG =~ /^v/
.global_trigger_full_tests: &global_trigger_full_tests
Laurent Heirendt's avatar
Laurent Heirendt committed
  rules:
    - if: $CI_COMMIT_BRANCH == "develop"
    - if: $CI_COMMIT_BRANCH == "master"
    - if: $CI_COMMIT_TAG =~ /^v/
.global_trigger_compat_tests: &global_trigger_compat_tests
  rules:
    - if: $CI_COMMIT_BRANCH == "master"

#
# Test environment & platform settings
#

.global_env_julia15: &global_env_julia15
Laurent Heirendt's avatar
Laurent Heirendt committed
  variables:
    JULIA_VER: "v1.5.3"

.global_env_julia16: &global_env_julia16
Laurent Heirendt's avatar
Laurent Heirendt committed
  variables:
    JULIA_VER: "v1.6.0"

.global_env_linux: &global_env_linux
Laurent Heirendt's avatar
Laurent Heirendt committed
  tags:
    - $ARTENOLIS_SOFT_PATH/julia/$JULIA_VER/bin/julia --inline=yes --check-bounds=yes --color=yes --project=@. -e 'import Pkg; Pkg.test(; coverage = true)'
.global_env_win: &global_env_win
  script:
    - $global:LASTEXITCODE = 0 # Note the global prefix.
    - Invoke-Expression $Env:ARTENOLIS_SOFT_PATH"\julia\"$Env:JULIA_VER"\bin\julia" --inline=yes --check-bounds=yes --color=yes --project=@. -e 'import Pkg; Pkg.test(; coverage = true)'
    - exit $LASTEXITCODE

.global_env_win8: &global_env_win8
Laurent Heirendt's avatar
Laurent Heirendt committed
  tags:
    - windows8
Laurent Heirendt's avatar
Laurent Heirendt committed

.global_env_win10: &global_env_win10
Laurent Heirendt's avatar
Laurent Heirendt committed
  tags:
    - windows10
Laurent Heirendt's avatar
Laurent Heirendt committed

.global_env_mac: &global_env_mac
Laurent Heirendt's avatar
Laurent Heirendt committed
  tags:
    - mac
Laurent Heirendt's avatar
Laurent Heirendt committed
  script:
    - $ARTENOLIS_SOFT_PATH/julia/$JULIA_VER/Contents/Resources/julia/bin/julia --inline=yes --check-bounds=yes --color=yes --project=@. -e 'import Pkg; Pkg.test(; coverage = true)'
#
# TESTS
#
# The "basic" required test that gets triggered for the basic testing, runs in
# any available docker and current julia
#

docker:julia1.6:
  stage: test
  image: $CI_REGISTRY/r3/docker/julia-custom
  script:
    - julia --check-bounds=yes --inline=yes --project=@. -e "import Pkg; Pkg.test(; coverage = true)"
  after_script:
    - julia --project=test/coverage test/coverage/coverage-summary.jl
  <<: *global_trigger_check_incoming_code

#
# The required compatibility test to pass on branches&tags before the docs get
# built & deployed
#

linux:julia1.5:
  stage: test
  <<: *global_trigger_full_tests
  <<: *global_env_julia15
  <<: *global_env_linux

linux:julia1.6:
  stage: test
  <<: *global_trigger_full_tests
  <<: *global_env_julia16
  <<: *global_env_linux

#
# Additional platform&environment compatibility tests
#

windows8:julia1.5:
  stage: test-compat
  <<: *global_trigger_compat_tests
  <<: *global_env_julia15
  <<: *global_env_win8

windows8:julia1.6:
  stage: test-compat
  <<: *global_trigger_compat_tests
  <<: *global_env_julia16
  <<: *global_env_win8

windows10:julia1.5:
  stage: test-compat
  <<: *global_trigger_compat_tests
  <<: *global_env_julia15
  <<: *global_env_win10

windows10:julia1.6:
  stage: test-compat
  <<: *global_trigger_compat_tests
  <<: *global_env_julia16
  <<: *global_env_win10

mac:julia1.5:
  stage: test-compat
  <<: *global_trigger_compat_tests
  <<: *global_env_julia15
  <<: *global_env_mac

mac:julia1.6:
  stage: test-compat
  <<: *global_trigger_compat_tests
  <<: *global_env_julia16
  <<: *global_env_mac

#
# CODE FORMAT CHECKER
Laurent Heirendt's avatar
Laurent Heirendt committed

format:
  image: docker:19.03.13
  tags:
    - privileged
  services:
    - name: docker:19.03.13-dind
      command: ["--tls=false", "--mtu=1458", "--registry-mirror", "https://docker-registry.lcsb.uni.lu"]
  before_script:
    - docker login -u $CI_USER_NAME -p $GITLAB_ACCESS_TOKEN $CI_REGISTRY
Laurent Heirendt's avatar
Laurent Heirendt committed
  script:
    - |
      docker run -v "$PWD":/project $CI_REGISTRY/r3/docker/julia-custom julia -e 'using JuliaFormatter; format("/project", verbose=true);'
    - |
      if [ `docker run -i -v "$PWD":/git alpine/git status -s | wc -l` -ne 0 ] ; then
        GITHUB_COMMENT=":red_square: &nbsp;Commit ${CI_COMMIT_SHORT_SHA} requires formatting!\
      "$'\n\n'"Required formatting changes summary:\
      "$'\n```\n'"`docker run -i -v \"$PWD\":/git alpine/git diff --stat`"$'\n```'
        GITHUB_COMMENT=":green_circle: &nbsp;Commit ${CI_COMMIT_SHORT_SHA} is formatted properly."
    - |
      export GITHUB_TOKEN="${GITHUB_ACCESS_TOKEN_FORMATTER}"
      export GITHUB_OWNER="lcsb-biocore"
      export GITHUB_REPO="cobrexa.jl"
      export GITHUB_COMMENT_TYPE=pr
      export GITHUB_PR_ISSUE_NUMBER="${CI_EXTERNAL_PULL_REQUEST_IID}"
      export GITHUB_COMMENT_FORMAT=""
      export GITHUB_COMMENT
Laurent Heirendt's avatar
Laurent Heirendt committed
    - |
      docker run -i --rm \
            -e GITHUB_TOKEN \
            -e GITHUB_OWNER \
            -e GITHUB_REPO \
            -e GITHUB_COMMENT_TYPE \
            -e GITHUB_PR_ISSUE_NUMBER \
            -e GITHUB_COMMENT_FORMAT \
            -e GITHUB_COMMENT \
            cloudposse/github-commenter
  <<: *global_trigger_check_incoming_code
# DOCUMENTATION ASSETS
#
# This builds the development history gif using gource.
documentation-assets:gource:
  stage: documentation-assets
  needs: [] # allow faster start
  image: docker:19.03.13
  tags:
    - privileged
Laurent Heirendt's avatar
Laurent Heirendt committed
  services:
    - name: docker:19.03.13-dind
Laurent Heirendt's avatar
Laurent Heirendt committed
      command: ["--tls=false", "--mtu=1458", "--registry-mirror", "https://docker-registry.lcsb.uni.lu"]
  before_script:
    - docker login -u $CI_USER_NAME -p $GITLAB_ACCESS_TOKEN $CI_REGISTRY
Laurent Heirendt's avatar
Laurent Heirendt committed
  script:
    - docker run -v "$PWD":/visualization $CI_REGISTRY/r3/docker/gource
  artifacts:
  <<: *global_trigger_build_doc
# DOCUMENTATION TESTS
#
# In pull requests, triggered after the tests succeed to avoid unnecessary
# double failure.  In normal branch testing, these get triggered with normal
# tests (the error should be visible ASAP). We avoid a separate stage to keep
# the pipeline parallelizable.
Laurent Heirendt's avatar
Laurent Heirendt committed

.global_doctests: &global_doctests
Laurent Heirendt's avatar
Laurent Heirendt committed
  image: $CI_REGISTRY/r3/docker/julia-custom
  script:
    - julia --project=@. -e 'import Pkg; Pkg.instantiate();'
    - julia --project=@. --color=yes test/doctests.jl

# this gets triggered on pull requests after the tests (to avoid unnecessary
# double failure if the tests fail already)
doc-tests-pr:julia1.6:
  stage: documentation
  <<: *global_doctests
  <<: *global_trigger_check_incoming_code

# this gets triggered in comprehensive tests
doc-tests:julia1.6:
  stage: test
  <<: *global_doctests
  <<: *global_trigger_full_tests
Laurent Heirendt's avatar
Laurent Heirendt committed

# DOCUMENTATION
Laurent Heirendt's avatar
Laurent Heirendt committed

pages:
  stage: documentation
  dependencies:
    - documentation-assets:gource
      # Note: This dependency is also implied by the stage ordering, but let's
      # be sure. As of Nov 2021, the assets are not used directly, but referred
      # to externally from the docs.
Laurent Heirendt's avatar
Laurent Heirendt committed
  image: $CI_REGISTRY/r3/docker/julia-custom
  script:
    # resolve and build packages from the docs/Project.toml file
    - julia --project=docs -e 'using Pkg; Pkg.resolve(); Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate();'
    # deploy doc (the without git history)
Laurent Heirendt's avatar
Laurent Heirendt committed
    - julia --project=docs --color=yes docs/make.jl

    # move to the directory picked up by Gitlab pages (with git history)
    - mv docs/build public
Laurent Heirendt's avatar
Laurent Heirendt committed
  artifacts:
    paths:
      - public
  <<: *global_trigger_build_doc
# EXTERNAL REPOSITORIES
#
# This trigger the test pipeline in external repo as defined by gitlab
# variables.
  image: curlimages/curl
  tags:
    - privileged
    - curl --silent --output /dev/null -X POST -F token=$EXTERNAL_REPO_TOKEN -F ref=$EXTERNAL_REPO_BRANCH $EXTERNAL_REPO
  <<: *global_trigger_full_tests