forked from reimagined/resolve
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
176 lines (156 loc) · 6.28 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
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
pipeline {
agent {
docker {
image 'reimagined/resolve-ci'
args '-u root:root -v /home/resolve/yarn_cache:/yarn_cache -p 5901:5901'
}
}
stages {
stage('Unit tests') {
steps {
script {
sh """
export YARN_CACHE_FOLDER=/yarn_cache
yarn install --dev
yarn lint
yarn test
"""
}
}
}
stage('Publish canary') {
steps {
script {
env.CI_TIMESTAMP = (new Date()).format("MddHHmmss", TimeZone.getTimeZone('UTC'))
if (env.BRANCH_NAME =~ '^v([0-9]+).([0-9]+).([0-9]+)$') {
env.CI_RELEASE_TYPE = 'beta'
} else {
env.CI_RELEASE_TYPE = 'alpha'
}
sh """
export YARN_CACHE_FOLDER=/yarn_cache
git log | head -1 | awk '{ print \$2 }' > /last_commit
echo \$(cat /last_commit)
export CI_CANARY_VERSION=\$(nodejs -e "console.log(JSON.parse(require('fs').readFileSync('./package.json')).version.split('-')[0].split('.').map((ver, idx) => (idx < 2 ? ver : String(+ver + 1) )).join('.'));")-${env.CI_TIMESTAMP}.${env.CI_RELEASE_TYPE}; \
echo \$CI_CANARY_VERSION > /lerna_version; \
yarn oao --version
echo registry=http://${env.NPM_ADDR} > /root/.npmrc; \
echo //${env.NPM_ADDR}/:_authToken=${env.NPM_TOKEN} >> /root/.npmrc; \
echo 'registry "http://${env.NPM_ADDR}"' >> /root/.yarnrc; \
find . -name package.json -type f -print | grep -v node_modules | xargs -I '%' node -e 'require("fs").writeFileSync(process.argv[1], JSON.stringify((() => { const pj = require(process.argv[1]); if(pj.dependencies) Object.keys(pj.dependencies).forEach(key => { if(key.indexOf("resolve-") < 0) return; pj.dependencies[key] = process.env.CI_CANARY_VERSION }); return pj; })(), null, 3))' '%'; \
yarn run publish --no-checks --no-confirm --new-version \$(cat /lerna_version); \
sleep 10
"""
}
}
}
stage('Examples [ todo ] Functional Tests') {
steps {
script {
sh """
export YARN_CACHE_FOLDER=/yarn_cache
/init.sh
cd examples/todo
yarn test:functional --browser=path:/chromium
"""
}
}
}
stage('Examples [ todo-two-levels ] Functional Tests') {
steps {
script {
sh """
export YARN_CACHE_FOLDER=/yarn_cache
/init.sh
cd examples/todo-two-levels
yarn test:functional --browser=path:/chromium
"""
}
}
}
stage('Examples [ top-list ] Functional Tests') {
steps {
script {
sh """
export YARN_CACHE_FOLDER=/yarn_cache
/init.sh
cd examples/top-list
yarn test:functional --browser=path:/chromium
"""
}
}
}
stage('Examples [ hacker-news ] Functional Tests') {
steps {
script {
sh """
export YARN_CACHE_FOLDER=/yarn_cache
/init.sh
cd examples/hacker-news
JWT_SECRET="secret" yarn test:functional --browser=path:/chromium
"""
}
}
}
stage('Create-resolve-app [ hello-world ] Functional Tests') {
steps {
script {
sh """
export YARN_CACHE_FOLDER=/yarn_cache
/init.sh
yarn global add create-resolve-app@\$(cat /lerna_version)
create-resolve-app hello-world -c \$(cat /last_commit)
cd ./hello-world
cat ./package.json
yarn test
yarn test:functional --browser=path:/chromium
"""
}
}
}
stage('Create-resolve-app [ todolist ] Functional Tests') {
steps {
script {
sh """
export YARN_CACHE_FOLDER=/yarn_cache
/init.sh
yarn global add create-resolve-app@\$(cat /lerna_version)
create-resolve-app todolist -e todo -c \$(cat /last_commit)
cd ./todolist
cat ./package.json
yarn test
yarn test:functional --browser=path:/chromium
"""
}
}
}
stage('Create-resolve-app [ twolevelstodo ] Functional Tests') {
steps {
script {
sh """
export YARN_CACHE_FOLDER=/yarn_cache
/init.sh
yarn global add create-resolve-app@\$(cat /lerna_version)
create-resolve-app twolevelstodo -e todo-two-levels -c \$(cat /last_commit)
cd ./todolist
cat ./package.json
yarn test
yarn test:functional --browser=path:/chromium
"""
}
}
}
}
post {
always {
script {
sh 'rm -rf ./*'
}
deleteDir()
}
}
}
// LINKS:
// https://github.com/DevExpress/XAF2/tree/devops/node-testcafe
// https://hub.docker.com/r/reimagined/node-testcafe/
// https://github.com/DevExpress/XAF2/tree/devops/next-lerna-version