From d27aaf8127fa052240f31dc32b7a066c21fbe08a Mon Sep 17 00:00:00 2001 From: Gensollen Date: Tue, 4 Jun 2024 10:27:19 +0200 Subject: [PATCH] [CI] Move build and deploy to GitHub Actions (#47) --- .github/workflows/build_and_deploy.yml | 45 +++++++++++++ .jenkins/Jenkinsfile | 87 -------------------------- Makefile | 9 +-- 3 files changed, 47 insertions(+), 94 deletions(-) create mode 100644 .github/workflows/build_and_deploy.yml delete mode 100644 .jenkins/Jenkinsfile diff --git a/.github/workflows/build_and_deploy.yml b/.github/workflows/build_and_deploy.yml new file mode 100644 index 0000000..b2d1e85 --- /dev/null +++ b/.github/workflows/build_and_deploy.yml @@ -0,0 +1,45 @@ +name: Build and Deloy Handbook + +on: + push: + branches: ["main"] + pull_request: + branches: ["main"] + +permissions: + contents: read + +concurrency: + group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}' + cancel-in-progress: true + +env: + POETRY_VERSION: '1.6.1' + PYTHON_VERSION: '3.10' + +jobs: + build-and-deploy: + runs-on: + - self-hosted + - Linux + - gpu + steps: + - uses: actions/checkout@v4 + - uses: snok/install-poetry@v1 + with: + version: ${{ env.POETRY_VERSION }} + virtualenvs-create: false + - name: Build documentation + run: | + source ~/miniconda3/etc/profile.d/conda.sh + conda env update -n clinicadl_handbook -f environment.yml + conda activate clinicadl_handbook + make install + make build.notebooks + make build.book + sed -i 's+github/aramis-lab/clinicadl_handbook/blob/main/jupyter-book/notebooks+github/aramis-lab/clinicadl_handbook/blob/main/notebooks+g' ./jupyter-book/_build/html/notebooks/*.html + - name: Deploy documentation + run: | + ls jupyter-book/_build/html + scp -r jupyter-book/_build/html aramislab:/srv/local/clinicadl/tutoriel/2023/ + diff --git a/.jenkins/Jenkinsfile b/.jenkins/Jenkinsfile deleted file mode 100644 index 93f0098..0000000 --- a/.jenkins/Jenkinsfile +++ /dev/null @@ -1,87 +0,0 @@ -#!/usr/bin/env groovy - -// Continuous Integration script to build mkdocs in Docker -// Author: mauricio.diaz@inria.fr - -pipeline { - agent none - stages { - stage('Build the docs') { - agent { - dockerfile { - filename 'Dockerfile' - reuseNode true - } - } - environment { - CONDA_HOME = '/opt/conda' - PATH = "/opt/conda/bin:/opt/conda/condabin:$PATH" - } - steps { - echo 'My branch name is ${BRANCH_NAME}' - sh 'echo "My branch name is ${BRANCH_NAME}"' - sh 'echo "Agent name: ${NODE_NAME}"' - sh 'pwd' - sh '$MAMBA_EXE info' - sh 'printenv' - //sh '. /usr/local/bin/_activate_current_env.sh' - sh '''#!/bin/bash - source /usr/local/bin/_activate_current_env.sh - poetry about - poetry install - make build.notebooks - make build.book - sed -i 's+github/aramis-lab/clinicadl_handbook/blob/main/jupyter-book/notebooks+github/aramis-lab/clinicadl_handbook/blob/main/notebooks+g' ./jupyter-book/_build/html/notebooks/*.html - ''' - stash(name: 'doc_html', includes: 'jupyter-book/_build/html/**') - } - } - stage('Deploy') { - parallel { - stage('Deploy site') { - agent { label 'gpu' } - when { - branch 'main' - } - steps { - echo 'Deploying in webserver...' - unstash(name: 'doc_html') - sshPublisher( - publishers: [ - sshPublisherDesc( - configName: 'web', - transfers: [ - sshTransfer( - cleanRemote: false, - excludes: '', - execCommand: '', - execTimeout: 120000, - flatten: false, - makeEmptyDirs: false, - noDefaultExcludes: false, - patternSeparator: '[, ]+', - remoteDirectory: 'clinicadl/tutoriel/2023', - remoteDirectorySDF: false, - removePrefix: 'jupyter-book/_build', - sourceFiles: 'jupyter-book/_build/html/**') - ], - usePromotionTimestamp: false, - useWorkspaceInPromotion: false, - verbose: false) - ] - ) - echo 'Finish uploading artifacts' - } - } - } - } - } -// post { -// failure { -// mail to: 'clinicadl-ci@inria.fr', -// subject: "This build of the welcome guide has failed: ${currentBuild.fullDisplayName}", -// body: "Something is wrong with the build of the welcome guide ${env.BUILD_URL}" -// } -// } -} - diff --git a/Makefile b/Makefile index baed034..ac1ee4a 100644 --- a/Makefile +++ b/Makefile @@ -11,18 +11,13 @@ help: Makefile @echo "Commands to use ClinicaDL Makefile:" @sed -n 's/^##//p' $< -## env : Bootstrap an environment -.PHONY: env -env: env.dev - ## env.conda : Create a Conda environment .PHONY: env.conda env.conda: @$(CONDA) env create -f environment.yml -p $(CONDA_ENV) -## env.dev : Install with Poetry -.PHONY: env.dev -env.dev: +.PHONY: install +install: @$(POETRY) install ## build.notebooks : Build notebooks from source using jupytext