blob: ad05b275f0ff34cbab793c61f0b5f64c10e30076 [file] [log] [blame]
Mohammed Naser12207172024-02-05 18:49:35 -05001pipeline {
2 agent none
3
4 options {
5 disableConcurrentBuilds(abortPrevious: true);
6 }
7
8 // TODO: periodic multi-node jobs
9
10 environment {
11 TEST_REGISTRY = "registry.atmosphere.dev:5000/${env.BRANCH_NAME.toLowerCase()}"
12 PROD_REGISTRY = "ghcr.io/vexxhost/atmosphere"
13 REGISTRY = "${env.BRANCH_NAME == 'main' ? PROD_REGISTRY : TEST_REGISTRY}"
14
15 EARTHLY_CI = 'true'
16 EARTHLY_BUILD_ARGS = "REGISTRY=${REGISTRY}"
17 }
18
19 stages {
20 stage('lint') {
21 parallel {
22 stage('ansible-lint') {
23 agent {
Mohammed Naserfdd5cee2024-02-07 23:45:52 -050024 label 'earthly'
Mohammed Naser12207172024-02-05 18:49:35 -050025 }
26
27 steps {
Mohammed Naserfdd5cee2024-02-07 23:45:52 -050028 script {
29 docker.withRegistry('https://registry.hub.docker.com', 'docker-token') {
30 sh 'earthly --output +lint.ansible-lint'
31 }
32 }
Mohammed Naser12207172024-02-05 18:49:35 -050033 }
34
35 post {
36 always {
37 junit testResults: 'ansible-lint.xml', allowEmptyResults: true
38 }
39 }
40 }
41
42 stage('helm') {
43 agent {
Mohammed Naserfdd5cee2024-02-07 23:45:52 -050044 label 'earthly'
Mohammed Naser12207172024-02-05 18:49:35 -050045 }
46
47 steps {
Mohammed Naserfdd5cee2024-02-07 23:45:52 -050048 script {
49 docker.withRegistry('https://registry.hub.docker.com', 'docker-token') {
50 sh 'earthly --output +lint.helm'
51 }
52 }
Mohammed Naser12207172024-02-05 18:49:35 -050053 }
54
55 post {
56 always {
57 junit testResults: 'output/junit-helm-*.xml', allowEmptyResults: true
58 }
59 }
60 }
61
62 stage('markdownlint') {
63 agent {
Mohammed Naserfdd5cee2024-02-07 23:45:52 -050064 label 'earthly'
Mohammed Naser12207172024-02-05 18:49:35 -050065 }
66
67 steps {
Mohammed Naserfdd5cee2024-02-07 23:45:52 -050068 script {
69 docker.withRegistry('https://registry.hub.docker.com', 'docker-token') {
70 sh 'earthly --output +lint.markdownlint'
71 }
72 }
Mohammed Naser12207172024-02-05 18:49:35 -050073 }
74
75 post {
76 always {
77 junit testResults: 'junit.xml', allowEmptyResults: true
78 }
79 }
80 }
81
82 stage('image-manifest') {
83 agent {
Mohammed Naserfdd5cee2024-02-07 23:45:52 -050084 label 'earthly'
Mohammed Naser12207172024-02-05 18:49:35 -050085 }
86
87 steps {
Mohammed Naserfdd5cee2024-02-07 23:45:52 -050088 script {
89 docker.withRegistry('https://registry.hub.docker.com', 'docker-token') {
90 sh 'earthly +lint.image-manifest'
91 }
92 }
Mohammed Naser12207172024-02-05 18:49:35 -050093 }
94 }
95 }
96 }
97
98 stage('unit') {
99 parallel {
100 stage('go') {
101 agent {
Mohammed Naserfdd5cee2024-02-07 23:45:52 -0500102 label 'earthly'
Mohammed Naser12207172024-02-05 18:49:35 -0500103 }
104
105 steps {
Mohammed Naserfdd5cee2024-02-07 23:45:52 -0500106 script {
107 docker.withRegistry('https://registry.hub.docker.com', 'docker-token') {
108 sh 'earthly --output +unit.go'
109 }
110 }
Mohammed Naser12207172024-02-05 18:49:35 -0500111 }
112
113 post {
114 always {
115 junit 'junit-go.xml'
116 }
117 }
118 }
119 }
120 }
121
122 stage('build') {
123 parallel {
124 stage('collection') {
125 agent {
Mohammed Naserfdd5cee2024-02-07 23:45:52 -0500126 label 'earthly'
Mohammed Naser12207172024-02-05 18:49:35 -0500127 }
128
129 steps {
Mohammed Naserfdd5cee2024-02-07 23:45:52 -0500130 script {
131 docker.withRegistry('https://registry.hub.docker.com', 'docker-token') {
132 sh 'earthly --output +build.collection'
133 }
134 }
135 }
136
137 post {
138 success {
139 archiveArtifacts artifacts: 'dist/**'
140 }
Mohammed Naser12207172024-02-05 18:49:35 -0500141 }
142 }
143
144 stage('images') {
145 agent {
146 label 'earthly'
147 }
148
149 steps {
150 script {
Mohammed Naserfdd5cee2024-02-07 23:45:52 -0500151 docker.withRegistry('https://registry.hub.docker.com', 'docker-token') {
152 if (env.BRANCH_NAME == 'main') {
153 docker.withRegistry('https://ghcr.io', 'github-packages-token') {
154 sh 'earthly --push +images'
155 }
156 } else {
157 sh 'earthly --push +images'
158 }
Mohammed Naser12207172024-02-05 18:49:35 -0500159 }
160 }
161
162 sh 'earthly --output +pin-images'
163 sh 'earthly +scan-images'
164 stash name: 'src-with-pinned-images', includes: '**'
165 }
166 }
167
168 stage('docs') {
169 agent {
Mohammed Naserfdd5cee2024-02-07 23:45:52 -0500170 label 'earthly'
Mohammed Naser12207172024-02-05 18:49:35 -0500171 }
172
173 steps {
Mohammed Naserfdd5cee2024-02-07 23:45:52 -0500174 script {
175 docker.withRegistry('https://registry.hub.docker.com', 'docker-token') {
176 sh 'earthly +mkdocs-build'
177 }
178 }
Mohammed Naser12207172024-02-05 18:49:35 -0500179 }
180 }
181 }
182 }
183
184 stage('integration') {
185 matrix {
186 axes {
187 axis {
188 name 'NETWORK_BACKEND'
189 values 'openvswitch', 'ovn'
190 }
191 }
192
193 agent {
194 label 'jammy-16c-64g'
195 }
196
197 environment {
198 ATMOSPHERE_DEBUG = "true"
199 ATMOSPHERE_NETWORK_BACKEND = "${NETWORK_BACKEND}"
200 }
201
202 stages {
203 stage('molecule') {
204 steps {
205 // Checkout code with built/pinned images
206 unstash 'src-with-pinned-images'
207
208 // Install dependencies
209 sh 'sudo apt-get install -y git python3-pip'
210 sh 'sudo pip install poetry'
211
212 // Run tests
213 sh 'sudo poetry install --with dev'
214 sh 'sudo --preserve-env=ATMOSPHERE_DEBUG,ATMOSPHERE_NETWORK_BACKEND poetry run molecule test -s aio'
215 }
216 }
217 }
218
219 post {
220 always {
221 // Kubernetes logs
222 sh "sudo ./build/fetch-kubernetes-logs.sh logs/${NETWORK_BACKEND}/kubernetes || true"
223 archiveArtifacts artifacts: 'logs/**', allowEmptyArchive: true
224
225 // JUnit results for Tempest
226 sh "sudo ./build/fetch-junit-xml.sh tempest-${NETWORK_BACKEND}.xml || true"
227 junit "tempest-${NETWORK_BACKEND}.xml"
228 }
229 }
230 }
231 }
232
233 // promote images
234 // release?
235 // todo: manual pin commit to main (avoiding loop)
236 }
237}