From 06a36fda67bb4f2abc4ffa63ea338150a12ec7d3 Mon Sep 17 00:00:00 2001 From: Suwako Moriya Date: Sat, 25 Apr 2020 16:56:52 +0200 Subject: [PATCH 1/5] Add Jenkinsfile --- Jenkinsfile | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..5179147 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,22 @@ +pipeline { + agent none + stages { + stage('Test') { + agent { + docker { + image 'python:3.7' + } + } + steps { + sh "pip install pipenv" + sh "pipenv sync" + sh 'pipenv run pytest -p no:warnings --junit-xml test-reports/results.xml' + } + post { + always { + junit 'test-reports/results.xml' + } + } + } + } +} From 99180e085299a763baf1aa1a84f8466fe5ccf98b Mon Sep 17 00:00:00 2001 From: Suwako Moriya Date: Sat, 25 Apr 2020 18:03:31 +0200 Subject: [PATCH 2/5] Playing around with Jenkins --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 5179147..fbbdfa2 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -8,7 +8,7 @@ pipeline { } } steps { - sh "pip install pipenv" + sh "pip install --user pipenv" sh "pipenv sync" sh 'pipenv run pytest -p no:warnings --junit-xml test-reports/results.xml' } From 25b004dcd7729f9c6bc34a080fff165cf98fc62c Mon Sep 17 00:00:00 2001 From: Suwako Moriya Date: Sun, 26 Apr 2020 00:01:34 +0200 Subject: [PATCH 3/5] Fix Jenkinsfile --- Jenkinsfile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index fbbdfa2..3dba59f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -4,17 +4,17 @@ pipeline { stage('Test') { agent { docker { - image 'python:3.7' + image 'python:3.8' } } steps { - sh "pip install --user pipenv" - sh "pipenv sync" - sh 'pipenv run pytest -p no:warnings --junit-xml test-reports/results.xml' + sh "pip install --no-cache-dir -t python pipenv" + sh "PYTHONPATH=\$(pwd)/python PIPENV_VENV_IN_PROJECT=true python/bin/pipenv sync --sequential --dev" + sh "export PYTHONPATH=\$(pwd)/python && cd src && PIPENV_VENV_IN_PROJECT=true \${PYTHONPATH}/bin/pipenv run pytest -p no:warnings --junit-xml test-reports/results.xml" } post { always { - junit 'test-reports/results.xml' + junit 'src/test-reports/results.xml' } } } From b1bc769bc9bb3ac20060ea83cec0d36985d2b6f5 Mon Sep 17 00:00:00 2001 From: Victor Bonnelle Date: Sun, 26 Apr 2020 20:58:03 +0200 Subject: [PATCH 4/5] Ajout de /datas au .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index d2c50bc..bbcdfc5 100644 --- a/.gitignore +++ b/.gitignore @@ -76,3 +76,4 @@ data/* /doc/build /src/datas/ /src/doctest_config.toml +/datas From 2249e30a9a501a35431b5a9d8e9a333820a95dcf Mon Sep 17 00:00:00 2001 From: Suwako Moriya Date: Mon, 27 Apr 2020 08:46:06 +0200 Subject: [PATCH 5/5] Added Doc Deployment --- Dockerfile | 9 +++++++ Jenkinsfile | 71 +++++++++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 70 insertions(+), 10 deletions(-) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..42acd50 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,9 @@ +FROM python:3.8 + +RUN apt-get update && apt-get install -y\ + rsync \ + openssh-client + +RUN pip install pipenv + +CMD ["/bin/bash"] diff --git a/Jenkinsfile b/Jenkinsfile index 3dba59f..82cad6f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,16 +1,27 @@ pipeline { - agent none + agent { + dockerfile { + args '-u root -v $HOME/docker_volumes/.cache/:/root/.cache/' + } + } + environment { + SPHINXOPTS = '-w sphinx-build.log' + DEPLOY_HOST = 'docs@moriya.zapto.org' + DEPLOY_PATH = 'www/docs/bot-base/' + } + stages { - stage('Test') { - agent { - docker { - image 'python:3.8' - } - } + stage('Install Dependencies') { steps { - sh "pip install --no-cache-dir -t python pipenv" - sh "PYTHONPATH=\$(pwd)/python PIPENV_VENV_IN_PROJECT=true python/bin/pipenv sync --sequential --dev" - sh "export PYTHONPATH=\$(pwd)/python && cd src && PIPENV_VENV_IN_PROJECT=true \${PYTHONPATH}/bin/pipenv run pytest -p no:warnings --junit-xml test-reports/results.xml" + sh 'pipenv sync --verbose --sequential --dev' + } + } + + stage('Run Tests') { + steps { + sh '''export PYTHONPATH=$(pwd)/python + cd src + pipenv run pytest -p no:warnings --junit-xml test-reports/results.xml''' } post { always { @@ -18,5 +29,45 @@ pipeline { } } } + + stage('Build Documentation') { + steps { + sh '''export PYTHONPATH=$(pwd)/python + cd doc + rm -f sphinx-build.log + pipenv run make html''' + } + post { + failure { + sh 'cat doc/sphinx-build.log' + } + } + } + + stage('Deploy Documentation') { + when { + anyOf { + branch 'stable' + branch 'master' + } + } + steps { + sshagent(credentials: ['1cf72f47-b70c-4f90-a958-020956099d19']) { + sh '''cd doc + rm -f rsync.log + echo ${DEPLOY_HOST}:${DEPLOY_PATH}${GIT_BRANCH#*/}/ >> debug.log + ssh -o StrictHostKeyChecking=no -o BatchMode=yes ${DEPLOY_HOST} mkdir -p ${DEPLOY_PATH}{GIT_BRANCH#*/}/ + rsync -aze 'ssh -o StrictHostKeyChecking=no -o BatchMode=yes' \ + --log-file=rsync.log \ + --delete \ + ./build/html/ ${DEPLOY_HOST}:${DEPLOY_PATH}${GIT_BRANCH#*/}/''' + } + } + post { + failure { + sh 'cat doc/debug.log doc/rsync.log' + } + } + } } }