diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index bae4b01..051fa1d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,5 +1,7 @@ stages: - - build_and_run + - test + - pre-release + - release-checks - release image: ${IMAGE} @@ -14,11 +16,32 @@ variables: bash Miniconda3-latest-Linux-x86_64.sh -b -p ./miniconda source ./miniconda/bin/activate conda init - + +# Insist a CHANGELOG entry has been made for tags +.check-changelog: &check-changelog | + TAGVER=${CI_COMMIT_TAG} + MATCHES=$(grep -c "## \[${TAGVER}\]" CHANGELOG.md) + if [[ "${MATCHES}" != "1" ]] then; + echo "Expected one match to '${CI_COMMIT_TAG}' in CHANGELOG, found ${MATCHES}" + exit 1 + else; + echo "Found CHANGELOG.md entry for tag" + fi + +# setup image for pushing to github +.setup-gh-push: &setup-gh-push | + apt-get update -qq && apt-get install -y -qq + git python3-all-dev git-lfs python3-venv + mkdir ~/.ssh/ + cp $LABS_BOT_GH_KEY ~/.ssh/id_rsa && chmod 600 ~/.ssh/id_rsa + echo -e "Host github.com\n\tStrictHostKeyChecking no\n\tHostname ssh.github.com\n\tPort 443\n\n" > ~/.ssh/config + git config --global user.email "epi2melabs@nanoporetech.com" + git config --global user.name "epi2melabs-bot" + conda-run: image: ubuntu:20.04 - stage: build_and_run + stage: test before_script: - apt update && apt install -y wget default-jre - *install-nextflow @@ -35,7 +58,7 @@ conda-run: build-image: - stage: build_and_run + stage: test before_script: - apk add wget openjdk11 bash - *install-nextflow @@ -52,12 +75,15 @@ build-image: --wfversion latest --fastq test_data/reads.fq.gz --out_dir ${OUTPUT} - # push + # push, to ont for later tagging, to dockerhub for release testing - if [[ ${CI_COMMIT_BRANCH} == 'dev' ]]; then SHATAG=${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHORT_SHA}; - echo "Pushing ${SHATAG}"; - docker tag ${TAG} ${SHATAG}; - docker push ${SHATAG}; + HUBTAG="${DOCKERHUB_NAMESPACE}/${CI_PROJECT_NAME}:${CI_COMMIT_SHORT_SHA}"; + for tag in SHATAG HUBTAG; do + echo "Pushing ${tag}"; + docker tag ${TAG} ${tag}; + docker push ${tag}; + done; fi; only: - branches @@ -67,6 +93,30 @@ build-image: - ${CI_PROJECT_NAME} expire_in: 1 day +### +# Push dev branch to github for release testers +release-dev: + stage: pre-release + image: $GH_PUSH_IMAGE + before_script: + - *setup-gh-push + script: + # Merge ont/dev into prerelease + - git remote add ont ${CI_REPOSITORY_URL} || true + - git remote add github git@github.com:epi2me-labs/${CI_PROJECT_NAME}.git || true + - git fetch ont dev + - git fetch github prerelease || echo "No 'prerelease' branch present on github" + - git checkout --track github/prerelease || git checkout prerelease + - git merge ont/dev + # Edit nextflow config to set wfversion + - grep 'wfversion = ".*"' nextflow.config || echo "Failed to replace wfversion" && exit 1 + - git add nextflow.config + - git commit -m "Setting wfversion to:${CI_COMMIT_SHORT_SHA}" + - git push github prerelease + only: + - '/^dev$/' + except: + - tags ### # Retag the image for git tags (releases) @@ -80,17 +130,6 @@ build-image: only: - tags -# To ONT registry -release-int: - stage: release - <<: *pull_tag - script: - - echo ${CI_BUILD_TOKEN} | docker login --username gitlab-ci-token --password-stdin ${CI_REGISTRY} - - RELTAG=${CI_REGISTRY_IMAGE}:${CI_COMMIT_REF_NAME} - - echo "Pushing ${TAG}" - - docker tag ${SHATAG} ${RELTAG} - - docker push ${RELTAG} - # To dockerhub release-hub: stage: release @@ -111,13 +150,7 @@ push-github: stage: release image: $GH_PUSH_IMAGE before_script: - - apt-get update -qq && apt-get install -y -qq - git python3-all-dev git-lfs python3-venv - - mkdir ~/.ssh/ - - cp $LABS_BOT_GH_KEY ~/.ssh/id_rsa && chmod 600 ~/.ssh/id_rsa - - echo -e "Host github.com\n\tStrictHostKeyChecking no\n\tHostname ssh.github.com\n\tPort 443\n\n" > ~/.ssh/config - - git config --global user.email "epi2melabs@nanoporetech.com" - - git config --global user.name "epi2melabs-bot" + - *setup-gh-push script: # Push master and tag to github - git remote add ont ${CI_REPOSITORY_URL} || true