-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfileGH-new
More file actions
190 lines (186 loc) · 5.21 KB
/
Copy pathJenkinsfileGH-new
File metadata and controls
190 lines (186 loc) · 5.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
@Library('attic')_
pipeline {
agent {
kubernetes {
inheritFrom 'kaniko'
yamlFile 'agent.pod.yaml'
defaultContainer 'leptodon-build'
yamlMergeStrategy merge()
}
}
options {
buildDiscarder(logRotator(numToKeepStr: '3'))
}
environment {
CONFIGURE_GIT = sh(
returnStdout: true,
script: 'git config --global safe.directory "*"'
).trim()
VERSION = sh(
returnStdout: true,
script: 'tomlq --raw-output ".workspace.package.version" Cargo.toml'
).trim()
NIX_PATH = 'nixpkgs=channel:nixos-unstable'
NS = 'openanalytics'
REGISTRY = 'registry.openanalytics.eu'
IMAGE = 'leptodon-demo'
NO_COLOR = 'true'
}
stages {
stage('Prepare Environment') {
steps {
script {
if (env.BRANCH_NAME == 'develop') {
env.TAG = "${env.VERSION}-SNAPSHOT"
} else {
env.TAG = "${env.VERSION}"
}
echo "TAG is set to ${env.TAG}"
}
sh "chown -R root:root ."
}
}
stage('Attic login & watch') {
steps {
loginAndWatch('oa-leptodon')
}
}
stage('Compile deps') {
steps {
parallel(
cargoArtifacts: {
sh "nix build .#cargoArtifacts"
},
cargoWasmArtifacts: {
sh "nix build .#cargoWasmArtifacts"
}
)
}
}
stage('Run Tests') {
parallel {
stage('Unit Tests') {
steps {
sh "nix build .#nextest -o nextest-result"
sh "ls -Hal nextest-result"
withChecks('Unit Tests') {
sh "cp nextest-result/junit.xml ${env.WORKSPACE}"
junit "junit.xml"
}
}
}
stage('Integration Tests') {
environment {
LEPTOS_SITE_ADDR="0.0.0.0:3000"
}
steps {
sh "nix build .#overview-site -o overview-site-result"
sh """
./overview-site-result/bin/overview-site &
echo "Up and running";
cd overview/end2end;
nix develop -c npm install;
CI=1 nix develop -c npx playwright test;
# Kills whatever this script spawned
kill \$! && echo "killed server";
"""
withChecks('Integration Tests') {
junit "overview/end2end/reports/test-report-e2e.xml"
}
}
}
stage('Build Demo') {
steps {
sh """
nix build .#demo-site-image -o demo-image
"""
}
}
}
}
stage('Publish Demo') {
steps {
// Skopeo policy
sh """
mkdir -p /etc/containers
echo '{"default":[{"type":"insecureAcceptAnything"}],"transports":{"docker-daemon":{"":[{"type":"insecureAcceptAnything"}]}}}' > /etc/containers/policy.json
"""
sh """
du -sh /nix/store
nix develop --command skopeo --tmpdir /tmp copy \
--authfile /root/.docker/config.json \
docker-archive:demo-image \
docker://${REGISTRY}/${NS}/${IMAGE}:latest
nix develop --command skopeo --tmpdir /tmp copy \
--authfile /root/.docker/config.json \
docker://${REGISTRY}/${NS}/${IMAGE}:latest \
docker://${REGISTRY}/${NS}/${IMAGE}:$VERSION
du -sh /nix/store
"""
}
}
stage('Packaging') {
when {
expression { env.VERSION && !env.VERSION.contains("dev") }
}
stages {
stage('Package leptodon-proc-macros') {
steps {
sh """
nix develop --command cargo package -p leptodon-proc-macros;
"""
}
post {
success {
sh "cp target/package/*.crate ${env.WORKSPACE}"
archiveArtifacts artifacts: '*.crate', fingerprint: true
}
}
}
stage('Publish leptodon-proc-macros') {
when {
branch 'main'
}
environment {
CARGO_REGISTRY_TOKEN = credentials('cratesio-oajenkins')
}
steps {
sh "nix develop --command cargo make publish-leptodon-proc-macros-if-missing"
}
}
stage('Package Leptodon') {
when {
// Avoid failures on develop when bumping the proc-macros crate version
branch 'main'
}
steps {
retry(3) {
// Pray crates.io finds the newly published crate version after 15s.
sh """
sleep 5;
nix develop --command cargo package -p leptodon;
"""
}
}
post {
success {
sh "cp target/package/*.crate ${env.WORKSPACE}"
archiveArtifacts artifacts: '*.crate', fingerprint: true
}
}
}
stage('Publish Leptodon Crate') {
when {
branch 'main'
}
environment {
CARGO_REGISTRY_TOKEN = credentials('cratesio-oajenkins')
}
steps {
sh "nix develop --command cargo make publish-leptodon-if-missing"
}
}
}
}
}
}