Repository navigation
Expand file tree
/
Copy pathJenkinsfile
More file actions
104 lines (103 loc) · 4.7 KB
/
Copy pathJenkinsfile
File metadata and controls
104 lines (103 loc) · 4.7 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
pipeline {
agent any
environment {
GOCACHE = "/tmp/go-cache"
npm_config_cache = "/tmp/npm-cache"
}
options {
buildDiscarder(logRotator(numToKeepStr: "10", artifactNumToKeepStr: "1"))
}
stages {
stage("Setup") {
steps {
git(
url: "git@github.com:mickael-kerjean/filestash",
branch: "master"
)
dir("test") {
git(
url: "git@github.com:mickael-kerjean/filestash-test.git",
credentialsId: "github-com-filestash-test",
branch: "main"
)
}
}
}
stage("Build") {
steps {
script {
docker.image("golang:1.26-trixie").inside() {
sh '''
sed -i 's|plg_image_c|plg_image_golang|' server/plugin/index.go
make init
CGO_ENABLED=0 make build
find ./public \\( -name '*.map' -o -name pdf.sandbox.js -o -path '*/vendor/*.html' -o -path '*/codemirror/demo' -o -path '*/codemirror/doc' -o -path '*/codemirror/src' -o -path '*/codemirror/theme' -o -path '*/codemirror/bin' \\) -prune -exec rm -rf {} +
CGO_ENABLED=0 GOARCH=amd64 go build -trimpath -ldflags="-s -w" --tags fts5 -o dist/release/filestash_linux_amd64.bin cmd/main.go
CGO_ENABLED=0 GOARCH=arm64 go build -trimpath -ldflags="-s -w" --tags fts5 -o dist/release/filestash_linux_arm64.bin cmd/main.go
'''
}
}
}
}
stage("Test") {
steps {
script {
// smoke test
docker.image("golang:1.26-bookworm").inside() {
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
docker.image("node:20").inside() {
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.26-bookworm").inside() {
sh "cp ./test/assets/* /tmp/"
sh "make init"
sh "go generate ./test/unit_go/..."
sh "go get ./..."
sh "CGO_ENABLED=0 go test -count=1 \$(go list ./server/... | grep -v \"server/plugin\" | grep -v \"server/generator\")"
}
// test e2e
docker.image("machines/puppeteer:latest").inside() {
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 {
script {
docker.image("alpine").inside() {
sh '''
wget -q -O /tmp/upx.tar.xz https://github.com/upx/upx/releases/download/v5.2.1/upx-5.2.1-amd64_linux.tar.xz
echo "402162aad30af47e60dbd767fb2e64ca394ace9727ba1f40283641f1d1b91657 /tmp/upx.tar.xz" | sha256sum -c
tar -xJf /tmp/upx.tar.xz -C /tmp
/tmp/upx-5.2.1-amd64_linux/upx --ultra-brute dist/release/*.bin
'''
}
}
withCredentials([sshUserPrivateKey(credentialsId: "app-filestash-hal", keyFileVariable: "KEY", usernameVariable: "USER")]) {
sh 'scp -i "$KEY" dist/release/* "$USER@hal.filestash.app:/mnt/me-kerjean-pages/projects/filestash/downloads/latest/"'
}
sh "docker buildx build --no-cache --platform linux/amd64,linux/arm64 -t machines/filestash:latest --push ./docker/"
}
}
}
post {
always {
cleanWs(disableDeferredWipeout: true, deleteDirs: true)
}
}
}