-
Notifications
You must be signed in to change notification settings - Fork 789
/
Jenkinsfile
111 lines (107 loc) · 4.6 KB
/
Jenkinsfile
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
pipeline {
agent any
options {
buildDiscarder(logRotator(numToKeepStr: "10", artifactNumToKeepStr: "1"))
}
stages {
stage("Setup") {
steps {
git(
url: "[email protected]:mickael-kerjean/filestash",
branch: "master"
)
dir("test") {
git(
url: "[email protected]:mickael-kerjean/filestash-test.git",
credentialsId: "github-com-filestash-test",
branch: "main"
)
}
}
}
stage("Build") {
steps {
script {
docker.image("node:14").inside("--user=root") {
sh "apt update -y && apt install -y brotli"
sh "npm install"
sh "make build_frontend"
}
docker.image("golang:1.23-bookworm").inside("--user=root") {
// prepare: todo - statically compile plg_image_c so we don't have to do this to pass the e2e tests
sh "sed -i 's|plg_image_c|plg_image_golang|' server/plugin/index.go"
// build
sh "go get ./..."
sh "go generate -x ./server/..."
sh "CGO_ENABLED=0 go build -o dist/filestash cmd/main.go"
}
}
}
}
stage("Test") {
steps {
script {
// smoke test
docker.image("golang:1.23-bookworm").inside("--user=root") {
sh 'timeout 5 ./dist/filestash > access.log || code=$?; if [ $code -ne 124 ]; then exit $code; fi'
sh "cat access.log"
sh "cat access.log | grep -q \"\\[http\\] starting\""
sh "cat access.log | grep -q \"listening\""
sh "cat access.log | grep -vz \"ERR\""
}
// test frontend old
docker.image("node:14").inside("--user=root") {
sh "cd ./test/unit_js && npm install"
sh "cd ./test/unit_js && npm test"
}
// test frontend new
docker.image("node:20").inside("--user=root") {
sh "cd public && npm install"
// sh "cd public && npm run lint"
sh "cd public && npm run check"
// sh "cd public && npm run test"
}
// test backend
docker.image("golang:1.23-bookworm").inside("--user=root") {
sh "cp ./test/assets/* /tmp/"
sh "go generate ./test/unit_go/..."
sh "go get ./..."
sh "go test -count=1 \$(go list ./server/... | grep -v \"server/plugin\" | grep -v \"server/generator\")"
}
// test e2e
docker.image("machines/puppeteer:latest").inside("--user=root") {
sh "cd ./test/e2e && npm install"
sh "chmod +x ./dist/filestash"
sh "./dist/filestash > /dev/null &"
sh "cd ./test/e2e && node servers/webdav.js > /dev/null &"
// sh "cd ./test/e2e && npm test"
}
}
}
}
stage("Release") {
steps {
// amd64
sh "docker build --no-cache -t machines/filestash:latest-amd64 ./docker/"
sh "docker push machines/filestash:latest-amd64"
// // arm
// sh "docker buildx build --platform linux/arm64 -t machines/filestash:latest-arm64 ./docker/"
// create final image
sh "docker manifest rm machines/filestash:latest || true"
// sh "docker manifest create machines/filestash:latest --amend machines/filestash:latest-amd64 --amend machines/filestash:latest-arm64v8"
sh "docker manifest create machines/filestash:latest --amend machines/filestash:latest-amd64"
sh "docker manifest push machines/filestash:latest"
}
}
stage("Deploy") {
steps {
sh "kubectl rollout restart deployment app-filestash-demo -n filestash"
}
}
}
post {
always {
cleanWs()
}
}
}