Skip to content

Commit aa9e38b

Browse files
authored
Merge pull request #452 from DeForce/develop
Release 0.4.0
2 parents a91fe87 + 1c7d624 commit aa9e38b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+4698
-2720
lines changed

Jenkinsfile

Lines changed: 104 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,92 @@
11
import groovy.json.JsonBuilder
22
import groovy.json.JsonSlurperClassic
33

4+
env.UPLOAD_DIR = "/mnt/lc"
5+
env.WINDOWS_BINARIES_PATH = "http://repo.intra.czt.lv/lalkachat/"
6+
env.BUILDER_CONTAINER = "deforce/lc-ubuntu-builder"
7+
8+
def UploadPath = "jenkins@czt.lv:/usr/local/nginx/html/czt.lv/lalkachat/"
9+
10+
def stage = { String stageName, Closure body ->
11+
// It's stage that prints its name
12+
stage(stageName) {
13+
echo "Stage: ${stageName}"
14+
body.call()
15+
}
16+
}
17+
18+
def buildThemes() {
19+
// Creates themes.json
20+
sh 'python src/jenkins/get_themes.py'
21+
def ThemesJson = readFile('themes.json')
22+
def ThemesList = new JsonSlurperClassic().parseText(ThemesJson)
23+
echo "${ThemesList}"
24+
for (def Theme : ThemesList) {
25+
sh "/bin/sh src/jenkins/test_theme.sh ${Theme}"
26+
sh "/bin/sh src/jenkins/build_theme.sh ${Theme}"
27+
}
28+
}
29+
30+
def runTests(folder, name, skip) {
31+
sh "python src/jenkins/get_folder_tests.py ${folder} ${name}"
32+
def TestsList
33+
try {
34+
def TestJson = readFile("${name}_tests.json")
35+
TestsList = new JsonSlurperClassic().parseText(TestJson)
36+
}
37+
catch (exc) {
38+
echo "No json file, exiting"
39+
return
40+
}
41+
def TestResults = [:]
42+
for (def Test : TestsList) {
43+
echo "Running ${Test} test"
44+
def result = false
45+
try {
46+
def Test_Name = Test.split('/').last().split("\\.").first()
47+
if(Test.endsWith('.py')) {
48+
sh "set -o pipefail && python ${Test} 2>&1 | tee results/${name}_${Test_Name}_results.txt"
49+
} else {
50+
sh "set -o pipefail && /bin/bash ${Test} 2>&1 | tee results/${name}_${Test_Name}_results.txt"
51+
}
52+
result = true
53+
} catch(exc) {
54+
if(!skip) {
55+
echo "Exception: $exc"
56+
error("Test didn't pass")
57+
}
58+
}
59+
finally {
60+
TestResults[Test] = result
61+
}
62+
}
63+
writeFile(file: "results/${name}_test.txt", text: new JsonBuilder(TestResults).toPrettyString())
64+
}
65+
66+
def buildDockerImage(archName, image, buildName) {
67+
sh "docker build -t ${buildName} -f docker/dockerfiles/${archName}/${image}/Dockerfile ."
68+
}
69+
70+
@NonCPS
71+
static def mapToList(depmap) {
72+
def dlist = []
73+
for (def entry2 in depmap) {
74+
dlist.add(new java.util.AbstractMap.SimpleImmutableEntry(entry2.key, entry2.value))
75+
}
76+
dlist
77+
}
78+
479
node('docker-host') {
580
stage('Checkout') {
681
checkout scm
782
sh 'mkdir -p results'
883
sh 'rsync -avz src/jenkins/root/ ./'
84+
85+
// This comment is needed until I refactor Jenkinsfile to support proper error throwing
86+
// def deps = 'asdas/asdasddas/asdasda/asdasd'.split('/').last().split("\\.").first()
987
}
1088
def stable = true
89+
env.PYTHONPATH = pwd()
1190
try {
1291
def containersToBuild = []
1392
stage('Prepare Docker containers') {
@@ -56,12 +135,14 @@ node('docker-host') {
56135
try {
57136
stage('Run Chat') {
58137
sh '/bin/sh src/jenkins/run_chat.sh'
59-
sh 'ps aux | grep -v grep | grep main.py'
60138
}
61139
stage('Run Tests') {
62140
stage('Chat Tests') {
63141
runTests('src/jenkins/chat_tests', 'chat', false)
64142
}
143+
stage('Module Tests') {
144+
echo 'Module Tests'
145+
}
65146
}
66147
stage('Lint Tests') {
67148
try {
@@ -73,35 +154,32 @@ node('docker-host') {
73154
stable = false
74155
}
75156
}
76-
} finally {
157+
} catch(exc) {
158+
echo "${exc}"
159+
throw(exc)
160+
}
161+
finally {
162+
echo "Chat logs"
77163
sh 'cat chat.log'
78-
archive 'results/**'
164+
try {
165+
sh "python src/jenkins/tests_to_xml.py ${container}"
166+
junit 'results/chat_tests.xml'
167+
archive 'results/**'
168+
} catch (exc) {
169+
echo "Got Exception, skipping"
170+
}
79171
}
80172
}
81173
}
82174
}
83175
}
84-
stage('Build') {
85-
if (env.BRANCH_NAME == 'develop' || env.BRANCH_NAME == 'master') {
86-
def ZipName = env.BUILD_TAG.replace('jenkins-', '')
87-
echo ZipName
88-
def container = 'deforce/ubuntu-builder'
89-
sh "cp requires_windows.txt requirements.txt"
90-
def binariesLocation = "http://repo.intra.czt.lv/lalkachat/"
91-
sh "wget -r --cut-dirs=1 -nH -np --reject index.html ${binariesLocation} "
92-
sh "docker run -v \"\$(pwd):/src/\" ${container}"
93-
sh "sh src/jenkins/build_default_themes.sh"
94-
sh "cp -r http/ dist/windows/main/http/"
95-
sh "chmod a+x -R dist/windows/main/"
96-
sh "mv dist/windows/main dist/windows/LalkaChat"
97-
dir('dist/windows/') {
98-
sh "zip -r ${ZipName}.zip LalkaChat"
99-
}
100-
archive "dist/windows/${ZipName}.zip"
101-
sh "chmod 664 dist/windows/${ZipName}.zip"
102-
def UploadPath = "jenkins@czt.lv:/usr/local/nginx/html/czt.lv/lalkachat/"
103-
sh "scp dist/windows/${ZipName}.zip ${UploadPath}"
104-
}
176+
stage('Publish') {
177+
env.ZIP_NAME = env.BUILD_TAG.replace('jenkins-', '')
178+
sh "sh src/jenkins/publish_chat.sh"
179+
sh """
180+
tar -zcvf themes-${BRANCH_NAME.replace('/', '-')}.tar.gz http/
181+
cp ./themes-${BRANCH_NAME.replace('/', '-')}.tar.gz ${env.UPLOAD_DIR}/
182+
""".stripIndent()
105183
}
106184
}
107185
finally {
@@ -110,61 +188,9 @@ node('docker-host') {
110188
currentBuild.result = 'UNSTABLE'
111189
}
112190
sh 'rm -rf dist/'
113-
sh 'docker rmi -f $(docker images | grep \'^<none>\' | awk \'{print \$3}\') || true'
191+
sh 'docker rm $(docker ps -aq) || true'
192+
sh 'docker rmi -f $(docker images -a | grep \'^<none>\' | awk \'{print \$3}\') || true'
114193
deleteDir()
115194
}
116195
}
117196
}
118-
119-
def buildThemes() {
120-
// Creates themes.json
121-
sh 'python src/jenkins/get_themes.py'
122-
def ThemesJson = readFile('themes.json')
123-
def ThemesList = new JsonSlurperClassic().parseText(ThemesJson)
124-
echo "${ThemesList}"
125-
for (def Theme : ThemesList) {
126-
sh "/bin/sh src/jenkins/test_theme.sh ${Theme}"
127-
sh "/bin/sh src/jenkins/build_theme.sh ${Theme}"
128-
}
129-
}
130-
131-
def runTests(folder, name, skip) {
132-
sh "python src/jenkins/get_folder_tests.py ${folder} ${name}"
133-
def TestJson = readFile("${name}_tests.json")
134-
def TestsList = new JsonSlurperClassic().parseText(TestJson)
135-
def TestResults = [:]
136-
for (def Test : TestsList) {
137-
echo "Running ${Test} test"
138-
def result = false
139-
try {
140-
def Test_Name = Test.split('/').last().split("\\.").first()
141-
if(Test.endsWith('.py')) {
142-
sh "set -o pipefail && python ${Test} 2>&1 | tee results/${name}_${Test_Name}_results.txt"
143-
} else {
144-
sh "set -o pipefail && /bin/bash ${Test} 2>&1 | tee results/${name}_${Test_Name}_results.txt"
145-
}
146-
result = true
147-
} catch(exc) {
148-
if(!skip) {
149-
error('Test didn\'t pass')
150-
}
151-
}
152-
finally {
153-
TestResults[Test] = result
154-
}
155-
}
156-
writeFile(file: "results/${name}_test.txt", text: new JsonBuilder(TestResults).toPrettyString())
157-
}
158-
159-
def buildDockerImage(archName, image, buildName) {
160-
sh "docker build -t ${buildName} -f docker/dockerfiles/${archName}/${image}/Dockerfile ."
161-
}
162-
163-
@NonCPS
164-
def mapToList(depmap) {
165-
def dlist = []
166-
for (def entry2 in depmap) {
167-
dlist.add(new java.util.AbstractMap.SimpleImmutableEntry(entry2.key, entry2.value))
168-
}
169-
dlist
170-
}

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ Docker build is available for testing LalkaChat, uses XPRA to display GUI from b
8080
- `docker run -rm --name chat-test -p 8080:8080 -v <PATH_TO_CONFIG>:/usr/lib/python2.7/site-packages/LalkaChat/conf deforce/lalkachat:testing`
8181

8282
## Special Thanks:
83-
ftpud - for fixing IE compatibility (Old problem with IE Browser)
84-
JAre - for being awesome with his docker stuff
85-
ichursin - for deep knowledge in JavaScript and helping me with code
86-
l0stparadis3 - for helping and testing in Linux environment
83+
ftpud - for fixing IE compatibility (Old problem with IE Browser)
84+
JAre - for being awesome with his docker stuff
85+
[ichursin](https://github.com/ichursin) - for deep knowledge in JavaScript and helping me with code
86+
l0stparadis3 - for helping and testing in Linux environment
File renamed without changes.
File renamed without changes.

docker/dockerfiles/alpine/testing/Dockerfile renamed to docker/dockerfiles/_alpine/testing/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ MAINTAINER CzT/DeForce <vlad@czt.lv>
44

55
# Deps for testing
66
RUN apk --update add curl bash nodejs-npm rsync
7-
RUN pip install git-lint pep8 pylint
7+
RUN pip install git-lint pep8 pylint junit-xml
88
RUN npm install -g csslint
File renamed without changes.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
FROM fedora
1+
FROM fedora:25
22

33
# Misc packages
44
RUN dnf -y install pwgen tar psmisc procps findutils iputils net-tools wget logrotate zip findutils git
55

6-
# Dependancies for LalkaChat
6+
# Dependencies for LalkaChat
77
COPY requires_linux.txt /root/
88
RUN dnf -y install wxPython
99
RUN pip install -r /root/requires_linux.txt

docker/dockerfiles/fedora/testing/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ FROM deforce/lc-fedora-build-deps
22

33
# Dependancies for Testing
44
RUN dnf -y install nodejs
5-
RUN pip install git-lint pep8 pylint
5+
RUN pip install git-lint pep8 pylint junit-xml
66
RUN npm install -g csslint

docker/dockerfiles/ubuntu/builder/Dockerfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,4 @@ RUN apt-get install -y xvfb
66
RUN wget -qO /root/wxpython.exe http://downloads.sourceforge.net/wxpython/wxPython3.0-win32-3.0.2.0-py27.exe
77
RUN (Xvfb :1 -screen 0 800x600x24&) && \
88
sleep 3 && \
9-
DISPLAY=:1 wine /root/wxpython.exe /SP- /VERYSILENT && \
10-
rm -rf /tmp/.wine-*
9+
DISPLAY=:1 wine /root/wxpython.exe /SP- /VERYSILENT

0 commit comments

Comments
 (0)