Skip to content
Snippets Groups Projects
.gitlab-ci.yml 10.2 KiB
Newer Older
  - test # this checks the viability of the code
  - assets # this builds assets to be included in documentation and distribution binaries
  - documentation # this processes the documentation
  - test-compat # this runs many additional compatibility tests
  GIT_STRATEGY: clone
  DOCKER_DRIVER: overlay2
  DOCKER_TLS_CERTDIR: ""
Miroslav Kratochvil's avatar
Miroslav Kratochvil committed
  APPTAINER_DOCKER_TAG: "v3.9.4"
Miroslav Kratochvil's avatar
Miroslav Kratochvil committed
  DOCKER_HUB_TAG: "lcsbbiocore/cobrexa.jl"
  DOCKER_GHCR_TAG: "ghcr.io/lcsb-biocore/docker/cobrexa.jl"
Miroslav Kratochvil's avatar
Miroslav Kratochvil committed
  APPTAINER_GHCR_TAG: "lcsb-biocore/apptainer/cobrexa.jl"

#
# Predefined conditions for triggering jobs
#

.global_trigger_pull_request: &global_trigger_pull_request
    - if: $CI_COMMIT_BRANCH == "develop"
      when: never
    - if: $CI_COMMIT_BRANCH == "master"
      when: never
    - if: $CI_PIPELINE_SOURCE == "external_pull_request_event"
.global_trigger_build_doc: &global_trigger_build_doc
    - if: $CI_EXTERNAL_PULL_REQUEST_TARGET_BRANCH_NAME == "master" && $CI_EXTERNAL_PULL_REQUEST_SOURCE_BRANCH_NAME == "develop"
    - if: $CI_PIPELINE_SOURCE == "external_pull_request_event"
      when: never
    - if: $CI_COMMIT_BRANCH == "develop"
    - if: $CI_COMMIT_BRANCH == "master"
    - 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"
    - if: $CI_EXTERNAL_PULL_REQUEST_TARGET_BRANCH_NAME == "master"
.global_trigger_test_containers: &global_trigger_test_containers
  rules:
    - if: $CI_PIPELINE_SOURCE == "external_pull_request_event"
      when: never
    - if: $CI_COMMIT_BRANCH == "develop"

.global_trigger_release_containers: &global_trigger_release_containers
  rules:
    - if: $CI_COMMIT_TAG =~ /^v/

#
# Test environment & platform settings
#

.global_dind: &global_dind
  image: docker:20.10.12
  tags:
    - privileged
  services:
    - name: docker:20.10.12-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

.global_julia17: &global_julia17
Laurent Heirendt's avatar
Laurent Heirendt committed
  variables:
    JULIA_VER: "v1.7.0"
Laurent Heirendt's avatar
Laurent Heirendt committed

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

.global_env_linux: &global_env_linux
    - $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)'
Miroslav Kratochvil's avatar
Miroslav Kratochvil committed
.global_build_apptainer: &global_build_apptainer
Miroslav Kratochvil's avatar
Miroslav Kratochvil committed
    name: "quay.io/singularity/singularity:$APPTAINER_DOCKER_TAG"
    # the image entrypoint is the singularity binary by default
    entrypoint: ["/bin/sh", "-c"]
#
# TESTS
#
# The "basic" required test that gets triggered for the basic testing, runs in
# any available docker and current julia
#

docker:julia1.7:
  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_pull_request

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

linux:julia1.7:
  <<: *global_trigger_full_tests
  <<: *global_julia17
  <<: *global_env_linux

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

#
# Additional platform&environment compatibility tests
#

windows8:julia1.7:
  <<: *global_trigger_compat_tests
  <<: *global_julia17
windows10:julia1.7:
  <<: *global_trigger_compat_tests
  <<: *global_julia17
  <<: *global_env_win10
mac:julia1.7:
  <<: *global_trigger_compat_tests
  <<: *global_julia17
  <<: *global_env_mac
windows8:julia1.6:
  <<: *global_trigger_compat_tests
  <<: *global_julia16
  <<: *global_env_win8
windows10:julia1.6:
  <<: *global_trigger_compat_tests
  <<: *global_julia16
  <<: *global_env_win10

mac:julia1.6:
  stage: test-compat
  <<: *global_trigger_compat_tests
  <<: *global_julia16
# CODE FORMAT CHECKER
Laurent Heirendt's avatar
Laurent Heirendt committed

format:
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_pull_request
# This builds the development history gif using gource, and some containers.
  needs: [] # allow faster start
Laurent Heirendt's avatar
Laurent Heirendt committed
  script:
    - docker run -v "$PWD":/visualization $CI_REGISTRY/r3/docker/gource
  artifacts:
Miroslav Kratochvil's avatar
Miroslav Kratochvil committed
    expire_in: 1 year
  <<: *global_trigger_build_doc
  stage: assets
  script: |
    alias apptainer=singularity
    apptainer build cobrexa-test.sif cobrexa.def
  <<: *global_trigger_test_containers
  stage: assets
Miroslav Kratochvil's avatar
Miroslav Kratochvil committed
      # build the container
      alias apptainer=singularity
      apptainer build cobrexa.sif cobrexa.def
    - |
Miroslav Kratochvil's avatar
Miroslav Kratochvil committed
      # push to GHCR
      alias apptainer=singularity
      export SINGULARITY_DOCKER_USERNAME="$GITHUB_ACCESS_USERNAME"
      export SINGULARITY_DOCKER_PASSWORD="$GITHUB_ACCESS_TOKEN"
Miroslav Kratochvil's avatar
Miroslav Kratochvil committed
      apptainer push cobrexa.sif "oras://ghcr.io/$APPTAINER_GHCR_TAG:latest"
      apptainer push cobrexa.sif "oras://ghcr.io/$APPTAINER_GHCR_TAG:$CI_COMMIT_TAG"
  <<: *global_trigger_release_containers
Miroslav Kratochvil's avatar
Miroslav Kratochvil committed
docker-test:
Miroslav Kratochvil's avatar
Miroslav Kratochvil committed
  script:
Miroslav Kratochvil's avatar
Miroslav Kratochvil committed
    - docker build -t "$DOCKER_HUB_TAG:testing" .
  <<: *global_dind
  <<: *global_trigger_test_containers

docker-release:
  script:
Miroslav Kratochvil's avatar
Miroslav Kratochvil committed
    - docker build -t "$DOCKER_HUB_TAG:latest" .
      # alias and push to docker hub
    - docker tag "$DOCKER_HUB_TAG:latest" "$DOCKER_HUB_TAG:$CI_COMMIT_TAG"
    - echo "$DOCKER_IO_ACCESS_TOKEN" | docker login --username "$DOCKER_IO_USER" --password-stdin
Miroslav Kratochvil's avatar
Miroslav Kratochvil committed
    - docker push "$DOCKER_HUB_TAG:latest"
    - docker push "$DOCKER_HUB_TAG:$CI_COMMIT_TAG"
      # make 2 extra aliases and push to GHCR
    - docker tag "$DOCKER_HUB_TAG:latest" "$DOCKER_GHCR_TAG:latest"
    - docker tag "$DOCKER_HUB_TAG:latest" "$DOCKER_GHCR_TAG:$CI_COMMIT_TAG"
    - echo "$GITHUB_ACCESS_TOKEN" | docker login ghcr.io --username "$GITHUB_ACCESS_USERNAME" --password-stdin
    - docker push "$DOCKER_GHCR_TAG:latest"
    - docker push "$DOCKER_GHCR_TAG:$CI_COMMIT_TAG"
Miroslav Kratochvil's avatar
Miroslav Kratochvil committed
  <<: *global_dind
  <<: *global_trigger_release_containers
# 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
doc-tests-pr:julia1.7:
  stage: documentation
  <<: *global_doctests
  <<: *global_trigger_pull_request
doc-tests:julia1.7:
  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:
      # 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();'
    # build and deploy docs (this doesn't upload the gource animation asset)
Laurent Heirendt's avatar
Laurent Heirendt committed
    - julia --project=docs --color=yes docs/make.jl
    # move to the directory to be picked up by Gitlab pages (with assets)
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.
  stage: test-compat
  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