blob: 6228f11131d3360e1ce16bcc84654a67ed46ff2a [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 {
Mohammed Naser66343ec2024-03-14 23:09:11 -040091 TEST_REGISTRY = "registry.atmosphere.dev/builds/${env.BRANCH_NAME.toLowerCase()}"
Mohammed Nasere7569e02024-02-20 14:33:37 -050092 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 // promote images
131 // release?
132 // todo: manual pin commit to main (avoiding loop)
133 }
Mohammed Naser12207172024-02-05 18:49:35 -0500134}