blob: 1ec8dbf5e631dd99b9491b0146b53e3f5d428f92 [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('markdownlint') {
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.markdownlint'
40 }
Mohammed Naser12207172024-02-05 18:49:35 -050041
Mohammed Nasere7569e02024-02-20 14:33:37 -050042 post {
43 always {
44 junit testResults: 'junit.xml', allowEmptyResults: true
45 }
46 }
47 }
Mohammed Naser12207172024-02-05 18:49:35 -050048
Mohammed Nasere7569e02024-02-20 14:33:37 -050049 stage('image-manifest') {
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 +lint.image-manifest'
56 }
57 }
58 }
59 }
Mohammed Naser12207172024-02-05 18:49:35 -050060
Mohammed Nasere7569e02024-02-20 14:33:37 -050061 stage('unit') {
62 parallel {
63 stage('go') {
64 agent {
65 label 'earthly-2c-4g'
66 }
Mohammed Naser12207172024-02-05 18:49:35 -050067
Mohammed Nasere7569e02024-02-20 14:33:37 -050068 steps {
69 sh 'earthly --output +unit.go'
70 }
Mohammed Naser12207172024-02-05 18:49:35 -050071
Mohammed Nasere7569e02024-02-20 14:33:37 -050072 post {
73 always {
74 junit 'junit-go.xml'
75 }
76 }
77 }
78 }
79 }
Mohammed Naser12207172024-02-05 18:49:35 -050080
Mohammed Nasere7569e02024-02-20 14:33:37 -050081 stage('build') {
82 parallel {
83 stage('collection') {
84 agent {
85 label 'earthly-2c-4g'
86 }
Mohammed Naser12207172024-02-05 18:49:35 -050087
Mohammed Nasere7569e02024-02-20 14:33:37 -050088 steps {
89 sh 'earthly --output +build.collection'
90 }
Mohammed Naserfdd5cee2024-02-07 23:45:52 -050091
Mohammed Nasere7569e02024-02-20 14:33:37 -050092 post {
93 success {
94 archiveArtifacts artifacts: 'dist/**'
95 }
96 }
97 }
Mohammed Naser12207172024-02-05 18:49:35 -050098
Mohammed Nasere7569e02024-02-20 14:33:37 -050099 stage('images') {
100 agent {
101 label 'earthly'
102 }
Mohammed Naser12207172024-02-05 18:49:35 -0500103
Mohammed Nasere7569e02024-02-20 14:33:37 -0500104 environment {
105 TEST_REGISTRY = "registry.atmosphere.dev/builds/${env.BRANCH_NAME.toLowerCase()}"
106 PROD_REGISTRY = "ghcr.io/vexxhost/atmosphere"
107 REGISTRY = "${env.BRANCH_NAME == 'main' ? PROD_REGISTRY : TEST_REGISTRY}"
Mohammed Naser1dfea6b2024-02-09 01:04:26 -0500108
Mohammed Nasere7569e02024-02-20 14:33:37 -0500109 EARTHLY_BUILD_ARGS = "REGISTRY=${REGISTRY}"
110 EARTHLY_PUSH = "true"
111 }
Mohammed Naser1dfea6b2024-02-09 01:04:26 -0500112
Mohammed Nasere7569e02024-02-20 14:33:37 -0500113 steps {
114 script {
115 if (env.BRANCH_NAME == 'main') {
116 docker.withRegistry('https://ghcr.io', 'github-packages-token') {
117 sh 'earthly --push +images'
118 }
119 } else {
120 docker.withRegistry('https://registry.atmosphere.dev', 'harbor-registry') {
121 sh 'earthly --push +images'
122 }
123 }
124 }
Mohammed Naser12207172024-02-05 18:49:35 -0500125
Mohammed Nasere7569e02024-02-20 14:33:37 -0500126 sh 'earthly --output +pin-images'
127 sh 'earthly +scan-images'
128 stash name: 'src-with-pinned-images', includes: '**'
129 }
130 }
Mohammed Naser12207172024-02-05 18:49:35 -0500131
Mohammed Nasere7569e02024-02-20 14:33:37 -0500132 stage('docs') {
133 agent {
134 label 'earthly-2c-4g'
135 }
Mohammed Naser12207172024-02-05 18:49:35 -0500136
Mohammed Nasere7569e02024-02-20 14:33:37 -0500137 steps {
138 sh 'earthly +mkdocs-build'
139 }
140 }
141 }
142 }
Mohammed Naser12207172024-02-05 18:49:35 -0500143
Mohammed Nasere7569e02024-02-20 14:33:37 -0500144 stage('integration') {
145 matrix {
146 axes {
147 axis {
148 name 'NETWORK_BACKEND'
149 values 'openvswitch', 'ovn'
150 }
151 }
Mohammed Naser12207172024-02-05 18:49:35 -0500152
Mohammed Nasere7569e02024-02-20 14:33:37 -0500153 agent {
154 label 'jammy-16c-64g'
155 }
Mohammed Naser12207172024-02-05 18:49:35 -0500156
Mohammed Nasere7569e02024-02-20 14:33:37 -0500157 environment {
158 ATMOSPHERE_DEBUG = "true"
159 ATMOSPHERE_NETWORK_BACKEND = "${NETWORK_BACKEND}"
Mohammed Naser9fb65912024-02-20 20:52:51 -0500160
161 // NOTE(mnaser): OVN is currently unstable and we don't want it to mark builds as failed.
162 BUILD_RESULT_ON_FAILURE = "${NETWORK_BACKEND == 'ovn' ? 'SUCCESS' : 'FAILURE'}"
163 STAGE_RESULT_ON_FAILURE = "${NETWORK_BACKEND == 'ovn' ? 'UNSTABLE' : 'FAILURE'}"
Mohammed Nasere7569e02024-02-20 14:33:37 -0500164 }
Mohammed Naser12207172024-02-05 18:49:35 -0500165
Mohammed Nasere7569e02024-02-20 14:33:37 -0500166 stages {
167 stage('molecule') {
168 steps {
169 // Checkout code with built/pinned images
170 unstash 'src-with-pinned-images'
Mohammed Naser12207172024-02-05 18:49:35 -0500171
Mohammed Nasere7569e02024-02-20 14:33:37 -0500172 // Install dependencies
173 sh 'sudo apt-get install -y git python3-pip'
174 sh 'sudo pip install poetry'
Mohammed Nasere7569e02024-02-20 14:33:37 -0500175 sh 'sudo poetry install --with dev'
Mohammed Naser9fb65912024-02-20 20:52:51 -0500176
177 catchError(buildResult: "${BUILD_RESULT_ON_FAILURE}", stageResult: "${STAGE_RESULT_ON_FAILURE}") {
178 sh 'sudo --preserve-env=ATMOSPHERE_DEBUG,ATMOSPHERE_NETWORK_BACKEND poetry run molecule test -s aio'
179 }
Mohammed Nasere7569e02024-02-20 14:33:37 -0500180 }
181 }
182 }
Mohammed Naser12207172024-02-05 18:49:35 -0500183
Mohammed Nasere7569e02024-02-20 14:33:37 -0500184 post {
185 always {
186 // Kubernetes logs
187 sh "sudo ./build/fetch-kubernetes-logs.sh logs/${NETWORK_BACKEND}/kubernetes || true"
188 archiveArtifacts artifacts: 'logs/**', allowEmptyArchive: true
Mohammed Naser12207172024-02-05 18:49:35 -0500189
Mohammed Nasere7569e02024-02-20 14:33:37 -0500190 // JUnit results for Tempest
191 sh "sudo ./build/fetch-junit-xml.sh tempest-${NETWORK_BACKEND}.xml || true"
192 junit "tempest-${NETWORK_BACKEND}.xml"
193 }
194 }
195 }
196 }
Mohammed Naser12207172024-02-05 18:49:35 -0500197
Mohammed Nasere7569e02024-02-20 14:33:37 -0500198 // promote images
199 // release?
200 // todo: manual pin commit to main (avoiding loop)
201 }
Mohammed Naser12207172024-02-05 18:49:35 -0500202}