-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
111 lines (102 loc) · 3.37 KB
/
Copy pathJenkinsfile
File metadata and controls
111 lines (102 loc) · 3.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
pipeline {
agent { label 'worker' }
options {
timeout(time: 30, unit: 'MINUTES')
}
environment {
REPO_NAME = sh(returnStdout: true, script: 'basename `git remote get-url origin` .git').trim()
VERSION = sh(returnStdout: true, script: 'uv version --short').trim()
LATEST_AUTHOR = sh(returnStdout: true, script: 'git show -s --pretty=%an').trim()
LATEST_COMMIT_ID = sh(returnStdout: true, script: 'git describe --tags --long --always').trim()
SNAPSHOT_BRANCH_REGEX = /(^main$)/
RELEASE_REGEX = /^([0-9]+(\.[0-9]+)*)(-(RC|beta-|alpha-)[0-9]+)?$/
RELEASE_DEPLOY = false
SNAPSHOT_DEPLOY = false
}
stages {
stage('Install project') {
steps {
script {
echo REPO_NAME
echo LATEST_AUTHOR
echo LATEST_COMMIT_ID
echo env.BRANCH_NAME
echo env.BUILD_NUMBER
echo env.TAG_NAME
if (!(VERSION ==~ RELEASE_REGEX || VERSION ==~ /.*-SNAPSHOT$/)) {
echo 'Version:'
echo VERSION
error 'The version declaration is invalid. It is neither a release nor a snapshot.'
}
}
script {
sh 'uv sync --locked --no-editable'
}
}
post {
failure {
rocket_buildfail()
}
}
}
stage('Static analysis') {
environment {
VIRTUAL_ENV="${WORKSPACE}/.venv"
PATH="${VIRTUAL_ENV}/bin:${PATH}"
}
steps {
script {
sh 'ruff format --check --diff .'
sh 'ruff check .'
sh 'ty check .'
}
}
post {
failure {
rocket_testfail()
}
}
}
stage('Test') {
environment {
VIRTUAL_ENV="${WORKSPACE}/.venv"
PATH="${VIRTUAL_ENV}/bin:${PATH}"
}
steps {
script {
// run pytest
sh 'pytest --cov=ohsome_filter_to_sql --cov-report=xml --maxfail=1 tests'
sh 'pytest --markdown-docs -m markdown-docs README.md'
sh 'uv run --python 3.11 pytest --maxfail=1 tests'
}
recordCoverage(tools: [[parser: 'COBERTURA', pattern: 'coverage.xml']])
}
post {
failure {
rocket_testfail()
}
}
}
stage('Build and Deploy Package') {
when {
expression {
return VERSION ==~ RELEASE_REGEX && env.TAG_NAME ==~ RELEASE_REGEX
}
}
steps {
script {
sh 'uv build'
withCredentials([string(credentialsId: 'PyPI-API-Token', variable: 'UV_PUBLISH_TOKEN')]) {
sh 'uv publish'
}
}
}
}
stage('Wrapping Up') {
steps {
encourage()
status_change()
}
}
}
}