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 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 new file mode 100644 index 0000000..82cad6f --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,73 @@ +pipeline { + 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('Install Dependencies') { + steps { + 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 { + junit 'src/test-reports/results.xml' + } + } + } + + 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' + } + } + } + } +}