blob: 0e05dc2613b55d003aa68460abcf6f74b322c55b [file] [log] [blame]
Mohammed Naser12207172024-02-05 18:49:35 -05001pipeline {
Mohammed Nasere7569e02024-02-20 14:33:37 -05002 agent none
Mohammed Naser12207172024-02-05 18:49:35 -05003
Mohammed Nasere7569e02024-02-20 14:33:37 -05004 options {
5 disableConcurrentBuilds(abortPrevious: true);
6 }
Mohammed Naser12207172024-02-05 18:49:35 -05007
Mohammed Nasere7569e02024-02-20 14:33:37 -05008 // TODO: periodic multi-node jobs
Mohammed Naser12207172024-02-05 18:49:35 -05009
Mohammed Nasere7569e02024-02-20 14:33:37 -050010 environment {
11 EARTHLY_CI = 'true'
12 }
Mohammed Naser12207172024-02-05 18:49:35 -050013
Mohammed Nasere7569e02024-02-20 14:33:37 -050014 stages {
15 stage('lint') {
16 parallel {
17 stage('ansible-lint') {
18 agent {
19 label 'earthly-2c-4g'
20 }
Mohammed Naser12207172024-02-05 18:49:35 -050021
Mohammed Nasere7569e02024-02-20 14:33:37 -050022 steps {
23 sh 'earthly --output +lint.ansible-lint'
24 }
Mohammed Naser12207172024-02-05 18:49:35 -050025
Mohammed Nasere7569e02024-02-20 14:33:37 -050026 post {
27 always {
28 junit testResults: 'ansible-lint.xml', allowEmptyResults: true
29 }
30 }
31 }
Mohammed Naser12207172024-02-05 18:49:35 -050032
Mohammed Nasere7569e02024-02-20 14:33:37 -050033 stage('helm') {
34 agent {
35 label 'earthly-2c-4g'
36 }
Mohammed Naser12207172024-02-05 18:49:35 -050037
Mohammed Nasere7569e02024-02-20 14:33:37 -050038 steps {
39 sh 'earthly --output +lint.helm'
40 }
Mohammed Naser12207172024-02-05 18:49:35 -050041
Mohammed Nasere7569e02024-02-20 14:33:37 -050042 post {
43 always {
44 junit testResults: 'output/junit-helm-*.xml', allowEmptyResults: true
45 }
46 }
47 }
Mohammed Naser12207172024-02-05 18:49:35 -050048
Mohammed Nasere7569e02024-02-20 14:33:37 -050049 stage('markdownlint') {
50 agent {
51 label 'earthly-2c-4g'
52 }
Mohammed Naser12207172024-02-05 18:49:35 -050053
Mohammed Nasere7569e02024-02-20 14:33:37 -050054 steps {
55 sh 'earthly --output +lint.markdownlint'
56 }
Mohammed Naser12207172024-02-05 18:49:35 -050057
Mohammed Nasere7569e02024-02-20 14:33:37 -050058 post {
59 always {
60 junit testResults: 'junit.xml', allowEmptyResults: true
61 }
62 }
63 }
Mohammed Naser12207172024-02-05 18:49:35 -050064
Mohammed Nasere7569e02024-02-20 14:33:37 -050065 stage('image-manifest') {
66 agent {
67 label 'earthly-2c-4g'
68 }
Mohammed Naser12207172024-02-05 18:49:35 -050069
Mohammed Nasere7569e02024-02-20 14:33:37 -050070 steps {
71 sh 'earthly +lint.image-manifest'
72 }
73 }
74 }
75 }
Mohammed Naser12207172024-02-05 18:49:35 -050076
Mohammed Nasere7569e02024-02-20 14:33:37 -050077 stage('unit') {
78 parallel {
79 stage('go') {
80 agent {
81 label 'earthly-2c-4g'
82 }
Mohammed Naser12207172024-02-05 18:49:35 -050083
Mohammed Nasere7569e02024-02-20 14:33:37 -050084 steps {
85 sh 'earthly --output +unit.go'
86 }
Mohammed Naser12207172024-02-05 18:49:35 -050087
Mohammed Nasere7569e02024-02-20 14:33:37 -050088 post {
89 always {
90 junit 'junit-go.xml'
91 }
92 }
93 }
94 }
95 }
Mohammed Naser12207172024-02-05 18:49:35 -050096
Mohammed Nasere7569e02024-02-20 14:33:37 -050097 stage('build') {
98 parallel {
99 stage('collection') {
100 agent {
101 label 'earthly-2c-4g'
102 }
Mohammed Naser12207172024-02-05 18:49:35 -0500103
Mohammed Nasere7569e02024-02-20 14:33:37 -0500104 steps {
105 sh 'earthly --output +build.collection'
106 }
Mohammed Naserfdd5cee2024-02-07 23:45:52 -0500107
Mohammed Nasere7569e02024-02-20 14:33:37 -0500108 post {
109 success {
110 archiveArtifacts artifacts: 'dist/**'
111 }
112 }
113 }
Mohammed Naser12207172024-02-05 18:49:35 -0500114
Mohammed Nasere7569e02024-02-20 14:33:37 -0500115 stage('images') {
116 agent {
117 label 'earthly'
118 }
Mohammed Naser12207172024-02-05 18:49:35 -0500119
Mohammed Nasere7569e02024-02-20 14:33:37 -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}"
Mohammed Naser1dfea6b2024-02-09 01:04:26 -0500124
Mohammed Nasere7569e02024-02-20 14:33:37 -0500125 EARTHLY_BUILD_ARGS = "REGISTRY=${REGISTRY}"
126 EARTHLY_PUSH = "true"
127 }
Mohammed Naser1dfea6b2024-02-09 01:04:26 -0500128
Mohammed Nasere7569e02024-02-20 14:33:37 -0500129 steps {
130 script {
131 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 }
139 }
140 }
Mohammed Naser12207172024-02-05 18:49:35 -0500141
Mohammed Nasere7569e02024-02-20 14:33:37 -0500142 sh 'earthly --output +pin-images'
143 sh 'earthly +scan-images'
144 stash name: 'src-with-pinned-images', includes: '**'
145 }
146 }
Mohammed Naser12207172024-02-05 18:49:35 -0500147
Mohammed Nasere7569e02024-02-20 14:33:37 -0500148 stage('docs') {
149 agent {
150 label 'earthly-2c-4g'
151 }
Mohammed Naser12207172024-02-05 18:49:35 -0500152
Mohammed Nasere7569e02024-02-20 14:33:37 -0500153 steps {
154 sh 'earthly +mkdocs-build'
155 }
156 }
157 }
158 }
Mohammed Naser12207172024-02-05 18:49:35 -0500159
Mohammed Nasere7569e02024-02-20 14:33:37 -0500160 stage('integration') {
161 matrix {
162 axes {
163 axis {
164 name 'NETWORK_BACKEND'
165 values 'openvswitch', 'ovn'
166 }
167 }
Mohammed Naser12207172024-02-05 18:49:35 -0500168
Mohammed Nasere7569e02024-02-20 14:33:37 -0500169 agent {
170 label 'jammy-16c-64g'
171 }
Mohammed Naser12207172024-02-05 18:49:35 -0500172
Mohammed Nasere7569e02024-02-20 14:33:37 -0500173 environment {
174 ATMOSPHERE_DEBUG = "true"
175 ATMOSPHERE_NETWORK_BACKEND = "${NETWORK_BACKEND}"
Mohammed Naser9fb65912024-02-20 20:52:51 -0500176
177 // NOTE(mnaser): OVN is currently unstable and we don't want it to mark builds as failed.
178 BUILD_RESULT_ON_FAILURE = "${NETWORK_BACKEND == 'ovn' ? 'SUCCESS' : 'FAILURE'}"
179 STAGE_RESULT_ON_FAILURE = "${NETWORK_BACKEND == 'ovn' ? 'UNSTABLE' : 'FAILURE'}"
Mohammed Nasere7569e02024-02-20 14:33:37 -0500180 }
Mohammed Naser12207172024-02-05 18:49:35 -0500181
Mohammed Nasere7569e02024-02-20 14:33:37 -0500182 stages {
183 stage('molecule') {
184 steps {
185 // Checkout code with built/pinned images
186 unstash 'src-with-pinned-images'
Mohammed Naser12207172024-02-05 18:49:35 -0500187
Mohammed Nasere7569e02024-02-20 14:33:37 -0500188 // Install dependencies
189 sh 'sudo apt-get install -y git python3-pip'
190 sh 'sudo pip install poetry'
Mohammed Nasere7569e02024-02-20 14:33:37 -0500191 sh 'sudo poetry install --with dev'
Mohammed Naser9fb65912024-02-20 20:52:51 -0500192
193 catchError(buildResult: "${BUILD_RESULT_ON_FAILURE}", stageResult: "${STAGE_RESULT_ON_FAILURE}") {
194 sh 'sudo --preserve-env=ATMOSPHERE_DEBUG,ATMOSPHERE_NETWORK_BACKEND poetry run molecule test -s aio'
195 }
Mohammed Nasere7569e02024-02-20 14:33:37 -0500196 }
197 }
198 }
Mohammed Naser12207172024-02-05 18:49:35 -0500199
Mohammed Nasere7569e02024-02-20 14:33:37 -0500200 post {
201 always {
202 // Kubernetes logs
203 sh "sudo ./build/fetch-kubernetes-logs.sh logs/${NETWORK_BACKEND}/kubernetes || true"
204 archiveArtifacts artifacts: 'logs/**', allowEmptyArchive: true
Mohammed Naser12207172024-02-05 18:49:35 -0500205
Mohammed Nasere7569e02024-02-20 14:33:37 -0500206 // JUnit results for Tempest
207 sh "sudo ./build/fetch-junit-xml.sh tempest-${NETWORK_BACKEND}.xml || true"
208 junit "tempest-${NETWORK_BACKEND}.xml"
209 }
210 }
211 }
212 }
Mohammed Naser12207172024-02-05 18:49:35 -0500213
Mohammed Nasere7569e02024-02-20 14:33:37 -0500214 // promote images
215 // release?
216 // todo: manual pin commit to main (avoiding loop)
217 }
Mohammed Naser12207172024-02-05 18:49:35 -0500218}