blob: 074a060a9ba59936d9a9cb36447e96185fa115ba [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 Nasere7569e02024-02-20 14:33:37 -050048 }
49 }
Mohammed Naser12207172024-02-05 18:49:35 -050050
Mohammed Nasere7569e02024-02-20 14:33:37 -050051 stage('unit') {
Mohammed Naser4c8e0cb2024-02-21 11:51:34 -050052 agent {
53 label 'earthly-2c-4g'
54 }
Mohammed Naser12207172024-02-05 18:49:35 -050055
Mohammed Naser4c8e0cb2024-02-21 11:51:34 -050056 steps {
57 sh 'earthly --output +unit.go'
58 }
Mohammed Naser12207172024-02-05 18:49:35 -050059
Mohammed Naser4c8e0cb2024-02-21 11:51:34 -050060 post {
61 always {
62 junit 'junit-go.xml'
Mohammed Nasere7569e02024-02-20 14:33:37 -050063 }
64 }
65 }
Mohammed Naser12207172024-02-05 18:49:35 -050066
Mohammed Nasere7569e02024-02-20 14:33:37 -050067 stage('build') {
68 parallel {
69 stage('collection') {
70 agent {
71 label 'earthly-2c-4g'
72 }
Mohammed Naser12207172024-02-05 18:49:35 -050073
Mohammed Nasere7569e02024-02-20 14:33:37 -050074 steps {
75 sh 'earthly --output +build.collection'
76 }
Mohammed Naserfdd5cee2024-02-07 23:45:52 -050077
Mohammed Nasere7569e02024-02-20 14:33:37 -050078 post {
79 success {
80 archiveArtifacts artifacts: 'dist/**'
81 }
82 }
83 }
Mohammed Naser12207172024-02-05 18:49:35 -050084
Mohammed Nasere7569e02024-02-20 14:33:37 -050085 stage('images') {
86 agent {
87 label 'earthly'
88 }
Mohammed Naser12207172024-02-05 18:49:35 -050089
Mohammed Nasere7569e02024-02-20 14:33:37 -050090 environment {
91 TEST_REGISTRY = "registry.atmosphere.dev/builds/${env.BRANCH_NAME.toLowerCase()}"
92 PROD_REGISTRY = "ghcr.io/vexxhost/atmosphere"
93 REGISTRY = "${env.BRANCH_NAME == 'main' ? PROD_REGISTRY : TEST_REGISTRY}"
Mohammed Naser1dfea6b2024-02-09 01:04:26 -050094
Mohammed Nasere7569e02024-02-20 14:33:37 -050095 EARTHLY_BUILD_ARGS = "REGISTRY=${REGISTRY}"
96 EARTHLY_PUSH = "true"
97 }
Mohammed Naser1dfea6b2024-02-09 01:04:26 -050098
Mohammed Nasere7569e02024-02-20 14:33:37 -050099 steps {
100 script {
101 if (env.BRANCH_NAME == 'main') {
102 docker.withRegistry('https://ghcr.io', 'github-packages-token') {
103 sh 'earthly --push +images'
104 }
105 } else {
106 docker.withRegistry('https://registry.atmosphere.dev', 'harbor-registry') {
107 sh 'earthly --push +images'
108 }
109 }
110 }
Mohammed Naser12207172024-02-05 18:49:35 -0500111
Mohammed Nasere7569e02024-02-20 14:33:37 -0500112 sh 'earthly --output +pin-images'
113 sh 'earthly +scan-images'
114 stash name: 'src-with-pinned-images', includes: '**'
115 }
116 }
Mohammed Naser12207172024-02-05 18:49:35 -0500117
Mohammed Nasere7569e02024-02-20 14:33:37 -0500118 stage('docs') {
119 agent {
120 label 'earthly-2c-4g'
121 }
Mohammed Naser12207172024-02-05 18:49:35 -0500122
Mohammed Nasere7569e02024-02-20 14:33:37 -0500123 steps {
124 sh 'earthly +mkdocs-build'
125 }
126 }
127 }
128 }
Mohammed Naser12207172024-02-05 18:49:35 -0500129
Mohammed Nasere7569e02024-02-20 14:33:37 -0500130 stage('integration') {
131 matrix {
132 axes {
133 axis {
134 name 'NETWORK_BACKEND'
135 values 'openvswitch', 'ovn'
136 }
137 }
Mohammed Naser12207172024-02-05 18:49:35 -0500138
Mohammed Nasere7569e02024-02-20 14:33:37 -0500139 agent {
140 label 'jammy-16c-64g'
141 }
Mohammed Naser12207172024-02-05 18:49:35 -0500142
Mohammed Nasere7569e02024-02-20 14:33:37 -0500143 environment {
144 ATMOSPHERE_DEBUG = "true"
145 ATMOSPHERE_NETWORK_BACKEND = "${NETWORK_BACKEND}"
Mohammed Naser9fb65912024-02-20 20:52:51 -0500146
147 // NOTE(mnaser): OVN is currently unstable and we don't want it to mark builds as failed.
148 BUILD_RESULT_ON_FAILURE = "${NETWORK_BACKEND == 'ovn' ? 'SUCCESS' : 'FAILURE'}"
149 STAGE_RESULT_ON_FAILURE = "${NETWORK_BACKEND == 'ovn' ? 'UNSTABLE' : 'FAILURE'}"
Mohammed Nasere7569e02024-02-20 14:33:37 -0500150 }
Mohammed Naser12207172024-02-05 18:49:35 -0500151
Mohammed Nasere7569e02024-02-20 14:33:37 -0500152 stages {
153 stage('molecule') {
154 steps {
155 // Checkout code with built/pinned images
156 unstash 'src-with-pinned-images'
Mohammed Naser12207172024-02-05 18:49:35 -0500157
Mohammed Nasere7569e02024-02-20 14:33:37 -0500158 // Install dependencies
159 sh 'sudo apt-get install -y git python3-pip'
160 sh 'sudo pip install poetry'
Mohammed Nasere7569e02024-02-20 14:33:37 -0500161 sh 'sudo poetry install --with dev'
Mohammed Naser9fb65912024-02-20 20:52:51 -0500162
163 catchError(buildResult: "${BUILD_RESULT_ON_FAILURE}", stageResult: "${STAGE_RESULT_ON_FAILURE}") {
164 sh 'sudo --preserve-env=ATMOSPHERE_DEBUG,ATMOSPHERE_NETWORK_BACKEND poetry run molecule test -s aio'
165 }
Mohammed Nasere7569e02024-02-20 14:33:37 -0500166 }
167 }
168 }
Mohammed Naser12207172024-02-05 18:49:35 -0500169
Mohammed Nasere7569e02024-02-20 14:33:37 -0500170 post {
171 always {
172 // Kubernetes logs
173 sh "sudo ./build/fetch-kubernetes-logs.sh logs/${NETWORK_BACKEND}/kubernetes || true"
174 archiveArtifacts artifacts: 'logs/**', allowEmptyArchive: true
Mohammed Naser12207172024-02-05 18:49:35 -0500175
Mohammed Nasere7569e02024-02-20 14:33:37 -0500176 // JUnit results for Tempest
177 sh "sudo ./build/fetch-junit-xml.sh tempest-${NETWORK_BACKEND}.xml || true"
178 junit "tempest-${NETWORK_BACKEND}.xml"
179 }
180 }
181 }
182 }
Mohammed Naser12207172024-02-05 18:49:35 -0500183
Mohammed Nasere7569e02024-02-20 14:33:37 -0500184 // promote images
185 // release?
186 // todo: manual pin commit to main (avoiding loop)
187 }
Mohammed Naser12207172024-02-05 18:49:35 -0500188}