blob: 6fc204a242dcfa86e81df323832ff4ad4806871f [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 {
Mohammed Naser12207172024-02-05 18:49:35 -050011 EARTHLY_CI = 'true'
Mohammed Naser12207172024-02-05 18:49:35 -050012 }
13
14 stages {
15 stage('lint') {
16 parallel {
17 stage('ansible-lint') {
18 agent {
Mohammed Naserfdd5cee2024-02-07 23:45:52 -050019 label 'earthly'
Mohammed Naser12207172024-02-05 18:49:35 -050020 }
21
22 steps {
Mohammed Naser1dfea6b2024-02-09 01:04:26 -050023 sh 'earthly --output +lint.ansible-lint'
Mohammed Naser12207172024-02-05 18:49:35 -050024 }
25
26 post {
27 always {
28 junit testResults: 'ansible-lint.xml', allowEmptyResults: true
29 }
30 }
31 }
32
33 stage('helm') {
34 agent {
Mohammed Naserfdd5cee2024-02-07 23:45:52 -050035 label 'earthly'
Mohammed Naser12207172024-02-05 18:49:35 -050036 }
37
38 steps {
Mohammed Naser1dfea6b2024-02-09 01:04:26 -050039 sh 'earthly --output +lint.helm'
Mohammed Naser12207172024-02-05 18:49:35 -050040 }
41
42 post {
43 always {
44 junit testResults: 'output/junit-helm-*.xml', allowEmptyResults: true
45 }
46 }
47 }
48
49 stage('markdownlint') {
50 agent {
Mohammed Naserfdd5cee2024-02-07 23:45:52 -050051 label 'earthly'
Mohammed Naser12207172024-02-05 18:49:35 -050052 }
53
54 steps {
Mohammed Naser1dfea6b2024-02-09 01:04:26 -050055 sh 'earthly --output +lint.markdownlint'
Mohammed Naser12207172024-02-05 18:49:35 -050056 }
57
58 post {
59 always {
60 junit testResults: 'junit.xml', allowEmptyResults: true
61 }
62 }
63 }
64
65 stage('image-manifest') {
66 agent {
Mohammed Naserfdd5cee2024-02-07 23:45:52 -050067 label 'earthly'
Mohammed Naser12207172024-02-05 18:49:35 -050068 }
69
70 steps {
Mohammed Naser1dfea6b2024-02-09 01:04:26 -050071 sh 'earthly +lint.image-manifest'
Mohammed Naser12207172024-02-05 18:49:35 -050072 }
73 }
74 }
75 }
76
77 stage('unit') {
78 parallel {
79 stage('go') {
80 agent {
Mohammed Naserfdd5cee2024-02-07 23:45:52 -050081 label 'earthly'
Mohammed Naser12207172024-02-05 18:49:35 -050082 }
83
84 steps {
Mohammed Naser1dfea6b2024-02-09 01:04:26 -050085 sh 'earthly --output +unit.go'
Mohammed Naser12207172024-02-05 18:49:35 -050086 }
87
88 post {
89 always {
90 junit 'junit-go.xml'
91 }
92 }
93 }
94 }
95 }
96
97 stage('build') {
98 parallel {
99 stage('collection') {
100 agent {
Mohammed Naserfdd5cee2024-02-07 23:45:52 -0500101 label 'earthly'
Mohammed Naser12207172024-02-05 18:49:35 -0500102 }
103
104 steps {
Mohammed Naser1dfea6b2024-02-09 01:04:26 -0500105 sh 'earthly --output +build.collection'
Mohammed Naserfdd5cee2024-02-07 23:45:52 -0500106 }
107
108 post {
109 success {
110 archiveArtifacts artifacts: 'dist/**'
111 }
Mohammed Naser12207172024-02-05 18:49:35 -0500112 }
113 }
114
115 stage('images') {
116 agent {
117 label 'earthly'
118 }
119
Mohammed Naser1dfea6b2024-02-09 01:04:26 -0500120 environment {
121 TEST_REGISTRY = "registry.atmosphere.dev/builds/${env.BRANCH_NAME.toLowerCase()}"
122 PROD_REGISTRY = "ghcr.io/vexxhost/atmosphere"
123 REGISTRY = "${env.BRANCH_NAME == 'main' ? PROD_REGISTRY : TEST_REGISTRY}"
124
125 EARTHLY_BUILD_ARGS = "REGISTRY=${REGISTRY}"
126 EARTHLY_PUSH = "true"
127 }
128
Mohammed Naser12207172024-02-05 18:49:35 -0500129 steps {
130 script {
Mohammed Naser1dfea6b2024-02-09 01:04:26 -0500131 if (env.BRANCH_NAME == 'main') {
132 docker.withRegistry('https://ghcr.io', 'github-packages-token') {
133 sh 'earthly --push +images'
134 }
135 } else {
136 docker.withRegistry('https://registry.atmosphere.dev', 'harbor-registry') {
137 sh 'earthly --push +images'
138 }
Mohammed Naser12207172024-02-05 18:49:35 -0500139 }
140 }
141
142 sh 'earthly --output +pin-images'
143 sh 'earthly +scan-images'
144 stash name: 'src-with-pinned-images', includes: '**'
145 }
146 }
147
148 stage('docs') {
149 agent {
Mohammed Naserfdd5cee2024-02-07 23:45:52 -0500150 label 'earthly'
Mohammed Naser12207172024-02-05 18:49:35 -0500151 }
152
153 steps {
Mohammed Naser1dfea6b2024-02-09 01:04:26 -0500154 sh 'earthly +mkdocs-build'
Mohammed Naser12207172024-02-05 18:49:35 -0500155 }
156 }
157 }
158 }
159
160 stage('integration') {
161 matrix {
162 axes {
163 axis {
164 name 'NETWORK_BACKEND'
165 values 'openvswitch', 'ovn'
166 }
167 }
168
169 agent {
170 label 'jammy-16c-64g'
171 }
172
173 environment {
174 ATMOSPHERE_DEBUG = "true"
175 ATMOSPHERE_NETWORK_BACKEND = "${NETWORK_BACKEND}"
176 }
177
178 stages {
179 stage('molecule') {
180 steps {
181 // Checkout code with built/pinned images
182 unstash 'src-with-pinned-images'
183
184 // Install dependencies
185 sh 'sudo apt-get install -y git python3-pip'
186 sh 'sudo pip install poetry'
187
188 // Run tests
189 sh 'sudo poetry install --with dev'
190 sh 'sudo --preserve-env=ATMOSPHERE_DEBUG,ATMOSPHERE_NETWORK_BACKEND poetry run molecule test -s aio'
191 }
192 }
193 }
194
195 post {
196 always {
197 // Kubernetes logs
198 sh "sudo ./build/fetch-kubernetes-logs.sh logs/${NETWORK_BACKEND}/kubernetes || true"
199 archiveArtifacts artifacts: 'logs/**', allowEmptyArchive: true
200
201 // JUnit results for Tempest
202 sh "sudo ./build/fetch-junit-xml.sh tempest-${NETWORK_BACKEND}.xml || true"
203 junit "tempest-${NETWORK_BACKEND}.xml"
204 }
205 }
206 }
207 }
208
209 // promote images
210 // release?
211 // todo: manual pin commit to main (avoiding loop)
212 }
213}