From d842bbfe847ef7adea42097c4c571a03a18af729 Mon Sep 17 00:00:00 2001 From: Alex Kanitz <alexander.kanitz@unibas.ch> Date: Sun, 10 Jul 2022 13:21:07 +0000 Subject: [PATCH] ci: add Conda tests and refactor --- .gitlab-ci.yml | 65 +++++++++++++++++++++++++++++++++++++------------ environment.yml | 1 + 2 files changed, 50 insertions(+), 16 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 51ca7c9..d8329a8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -6,27 +6,60 @@ workflow: rules: - if: $CI_PIPELINE_SOURCE == "push" -test: - rules: - - if: $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH +stages: + - build + - test + - publish + +build_conda: + stage: build + script: + - mamba env create --force -f environment.yml + - echo $CONDA_DEFAULT_ENV + +build_docker: + stage: build + before_script: + - export IMAGE="${DOCKER_ORG}/${DOCKER_REPO}" + - export BUILD_TAG="build" + - echo "IMAGE=$IMAGE" >> build.env + - echo "BUILD_TAG=$BUILD_TAG" >> build.env + script: + - docker build -t ${IMAGE}:${BUILD_TAG} . + artifacts: + reports: + dotenv: build.env + +test_conda: + stage: test + needs: + job: build_conda + before_script: + - conda activate ascii-alignment-pileup + script: + - tests/test.sh + +test_docker: + stage: test + needs: + - job: build_docker + artifacts: true script: - - export IMAGE="${DOCKER_ORG}/${DOCKER_REPO}:latest" - - docker build -t $IMAGE . - - docker run --rm $IMAGE tests/test.sh + - docker run --rm ${IMAGE}:${BUILD_TAG} tests/test.sh -test_and_publish: +publish_docker: + stage: publish rules: - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH - script: + needs: + - job: build_docker + artifacts: true + - job: test_docker + before_script: - export VERSION=$(grep 'version <-' ascii_alignment_pileup.R | cut -f2 -d'"') - - export IMAGE="${DOCKER_ORG}/${DOCKER_REPO}" - - | - docker build \ - -t ${IMAGE}:${VERSION} \ - --build-arg version=$VERSION \ - . - - docker run --rm ${IMAGE}:${VERSION} tests/test.sh + script: - echo "${DOCKER_TOKEN}" | docker login -u "${DOCKER_USER}" --password-stdin - - docker tag ${IMAGE}:${VERSION} ${IMAGE}:latest + - docker tag ${IMAGE}:${BUILD_TAG} ${IMAGE}:${VERSION} + - docker tag ${IMAGE}:${BUILD_TAG} ${IMAGE}:latest - docker push ${IMAGE}:${VERSION} - docker push ${IMAGE}:latest diff --git a/environment.yml b/environment.yml index 3452990..cc5c4d6 100644 --- a/environment.yml +++ b/environment.yml @@ -1,6 +1,7 @@ name: ascii-alignment-pileup channels: - bioconda + - conda-forge dependencies: - r-optparse=1.7.1 - bioconductor-rtracklayer=1.54.0 -- GitLab