aboutsummaryrefslogtreecommitdiff
path: root/Jenkinsfile
diff options
context:
space:
mode:
authorMax Nanis2026-09-13 19:03:55 +0000
committerMax Nanis2026-09-13 19:03:55 +0000
commit8fbe8d439b418796932aaa88297e006c714e4d13 (patch)
tree6c800476edc1e771fc570b559d483df8d59d4324 /Jenkinsfile
parent12f6fee851b68e86af658dfa17e4a0daed457dd1 (diff)
parent2c94f248d2438071a918fa9a30bf114ef9aa29b4 (diff)
downloadamt-jb-8fbe8d439b418796932aaa88297e006c714e4d13.tar.gz
amt-jb-8fbe8d439b418796932aaa88297e006c714e4d13.zip
Merges pull request #3
Off of Amazon!!!
Diffstat (limited to 'Jenkinsfile')
-rw-r--r--Jenkinsfile124
1 files changed, 55 insertions, 69 deletions
diff --git a/Jenkinsfile b/Jenkinsfile
index eb53bfd..5f63edc 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -1,7 +1,3 @@
-/* This is intended to test the dev & master branches of the gr-api project,
- where the tests are entirely self contained
-*/
-
pipeline {
agent any
@@ -10,95 +6,85 @@ pipeline {
pollSCM('H */3 * * *')
}
+ options {
+ skipDefaultCheckout()
+ }
+
environment {
DATA_SRC = "${env.WORKSPACE}/mnt/"
-
- AMT_JB_CARER_VENV = "${env.WORKSPACE}/amt-jb-carer-venv"
- AMT_JB_VENV = "${env.WORKSPACE}/amt-jb-venv"
+ VENV = "${env.WORKSPACE}/amt-jb-venv"
}
stages {
- stage('Setup DB') {
- steps {
- script {
- env.DB_NAME = 'unittest-amt-jb-' + UUID.randomUUID().toString().replace('-', '').take(12)
- env.AMT_JB_DB = "postgres://${env.DB_USER}:${env.DB_PASSWORD}@${env.DB_POSTGRESQL_HOST}/${env.DB_NAME}"
- echo "Using database: ${env.DB_NAME}"
- }
-
- sh """
- PGPASSWORD=${env.DB_PASSWORD} psql -h ${env.DB_POSTGRESQL_HOST} -U ${env.DB_USER} -d postgres <<EOF
- CREATE DATABASE "${env.DB_NAME}" WITH TEMPLATE = template0 ENCODING = 'UTF8';
- EOF
- """
- }
- }
-
- stage('env') {
- steps {
- withCredentials([file(
- credentialsId: 'amt-jb-app-env',
- variable: 'ENV_FILE_PATH')]) {
- sh "cp \$ENV_FILE_PATH ${WORKSPACE}/.env.test"
- }
- }
- }
-
- stage('setup:amt-jb-carer') {
+ stage('Checkout') {
steps {
checkout scmGit(
- branches: [[name: 'master']],
+ branches: [[name: "*/${env.BRANCH_NAME}"]],
extensions: [ cloneOption(shallow: true) ],
userRemoteConfigs: [
- [credentialsId: 'abdeb570-b708-44f3-b857-8a6b06ed9822',
+ [credentialsId: 'abdeb570-b708-44f3-b857-8a6b06ed9822',
url: 'ssh://code.g-r-l.com:6611/panels/amt-jb']
],
)
-
- dir('carer/') {
- sh 'python3.13 -m venv $AMT_JB_CARER_VENV'
- sh '$AMT_JB_CARER_VENV/bin/pip install -U setuptools wheel pip'
- sh '$AMT_JB_CARER_VENV/bin/pip install -r requirements.txt'
- sh '$AMT_JB_CARER_VENV/bin/python3.13 manage.py migrate --settings=carer.settings.unittest'
- }
+ stash name: 'source', useDefaultExcludes: false
}
}
- /* Okay, finally we can setup the virtual environment for the actual
- project itself. gr-api FastAPI doesn't manage any of it's own
- database so it doesn't need to do any migrations or anything.
- */
- stage('setup:amt-jb') {
- steps {
- sh 'python3.13 -m venv $AMT_JB_VENV'
- sh '$AMT_JB_VENV/bin/pip install -U setuptools wheel pip'
- withCredentials([sshUserPrivateKey(
- credentialsId: 'abdeb570-b708-44f3-b857-8a6b06ed9822',
- keyFileVariable: 'SSH_PRIVATE_KEY')]) {
- sh """
- eval \$(ssh-agent) && ssh-add ${SSH_PRIVATE_KEY} && \
- ${AMT_JB_VENV}/bin/pip install -r requirements.txt
- """
+ stage('Python Versions') {
+ matrix {
+ axes {
+ axis {
+ name 'VER'
+ values 'python3.14'
}
- }
- }
+ }
- stage('tests') {
- steps {
- sh '$AMT_JB_VENV/bin/pytest -v tests'
+ stages {
+ stage('Setup') {
+ steps {
+ dir("amt-jb-${VER}") {
+ deleteDir()
+ unstash 'source'
+
+ withCredentials([file(
+ credentialsId: '5cfa9a3a-3c26-499d-832f-0916d524fe05',
+ variable: 'ENV_TEST_FILE')]) {
+ sh 'cp $ENV_TEST_FILE .env.test'
+ }
+
+ sh "/usr/local/bin/${VER} -m venv ${VENV}-${VER}"
+ withCredentials([sshUserPrivateKey(
+ credentialsId: 'abdeb570-b708-44f3-b857-8a6b06ed9822',
+ keyFileVariable: 'SSH_PRIVATE_KEY')]) {
+ sh """
+ eval \$(ssh-agent) && ssh-add ${SSH_PRIVATE_KEY} && \
+ ${VENV}-${VER}/bin/pip install -r requirements.txt
+ ${VENV}-${VER}/bin/pip install django
+ """
+ }
+ }
+ }
+ }
+
+ stage('tests') {
+ steps {
+ dir("amt-jb-${VER}") {
+ sh "${VENV}-${VER}/bin/pytest tests/test_postgres.py -vs"
+ sh "${VENV}-${VER}/bin/pytest tests/models -vs"
+ sh "${VENV}-${VER}/bin/pytest tests/managers -vs"
+ sh "${VENV}-${VER}/bin/pytest tests/http -vs"
+ }
+ }
+ }
+ }
}
}
}
+
post {
always {
echo 'One way or another, I have finished'
deleteDir() /* clean up our workspace */
-
- sh """
- PGPASSWORD=${env.DB_PASSWORD} psql -h ${env.DB_POSTGRESQL_HOST} -U ${env.DB_USER} -d postgres <<EOF
- DROP DATABASE "${env.DB_NAME}";
- EOF
- """
}
}
}