Skip to content
Snippets Groups Projects
Forked from lscsoft / bayeswave
16 commits behind the upstream repository.
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
.gitlab-ci.yml 6.20 KiB
# CI/CD workflow for bayeswave
# 1. Build a container with conda env dependences.  Scheduled builds produce
# the "latest" image; tags produce a tagged version of the dependencies at the
# time of that tag.
# 2. Build the bayeswave package from source in the conda env image and docs pages
# 3. Test major executables
# 4. Build & push the bayeswave runtime container from BayesWave source on top of the
# conda env dependencies.
# 5. Push documentation for tagged commits only
#
# TODO: build the env image only for master
# TODO: use the upstream for the env image

variables:
  BRANCH: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME
  COMMIT: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
  TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG
  UPSTREAM_REGISTRY: containers.ligo.org/lscsoft/bayeswave
  CONDA_ENV_IMAGE: conda-env
  BUILD_DIR: test-install
  BUILD_TARGET: $CI_PROJECT_DIR/$BUILD_DIR
  TEST_OUTPUT: test-output

stages:
  - docker
  - build
  - test
  - deploy

.docker_template: &docker_deploy
  image: docker
  before_script:
    - echo "Logging in"
    - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
  script:
    - if [ -z $CI_COMMIT_TAG ]; then IMAGE_TAG="latest"; else IMAGE_TAG="$CI_COMMIT_TAG"; fi
    - if [ -z $IMAGE_NAME ]; then IMAGE="$CI_REGISTRY_IMAGE:$IMAGE_TAG"; else IMAGE="$CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG" ; fi
    - echo "Building image - $IMAGE"
    - docker build --no-cache
        --build-arg CI_COMMIT_SHA=${CI_COMMIT_SHA}
        --build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')
        --build-arg BUILD_IMAGE=$UPSTREAM_REGISTRY/$CONDA_ENV_IMAGE:$IMAGE_TAG
        -t $IMAGE --file $DOCKERFILE .
    - docker push $IMAGE

# Build the conda environment dependencies
conda-env:
  stage: docker
  <<: *docker_deploy
  variables:
    IMAGE_NAME: $CONDA_ENV_IMAGE
    DOCKERFILE: .conda-env.Dockerfile
  only:
    refs:
      - tags
      - master@lscsoft/bayeswave

# FIXME:  reconcile with above - SHORT TERM HACK (seriously - this could break paperwork)
# Build the conda environment dependencies
conda-env-manual:
  stage: docker
  <<: *docker_deploy
  variables:
    IMAGE_NAME: $CONDA_ENV_IMAGE
    DOCKERFILE: .conda-env.Dockerfile
  when: manual

# -------------------------------------------------------
# BUILD