Skip to content

Commit

Permalink
Merge pull request #452 from DeForce/develop
Browse files Browse the repository at this point in the history
Release 0.4.0
  • Loading branch information
DeForce authored Dec 31, 2017
2 parents a91fe87 + 1c7d624 commit aa9e38b
Show file tree
Hide file tree
Showing 74 changed files with 4,698 additions and 2,720 deletions.
182 changes: 104 additions & 78 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,92 @@
import groovy.json.JsonBuilder
import groovy.json.JsonSlurperClassic

env.UPLOAD_DIR = "/mnt/lc"
env.WINDOWS_BINARIES_PATH = "http://repo.intra.czt.lv/lalkachat/"
env.BUILDER_CONTAINER = "deforce/lc-ubuntu-builder"

def UploadPath = "jenkins@czt.lv:/usr/local/nginx/html/czt.lv/lalkachat/"

def stage = { String stageName, Closure body ->
// It's stage that prints its name
stage(stageName) {
echo "Stage: ${stageName}"
body.call()
}
}

def buildThemes() {
// Creates themes.json
sh 'python src/jenkins/get_themes.py'
def ThemesJson = readFile('themes.json')
def ThemesList = new JsonSlurperClassic().parseText(ThemesJson)
echo "${ThemesList}"
for (def Theme : ThemesList) {
sh "/bin/sh src/jenkins/test_theme.sh ${Theme}"
sh "/bin/sh src/jenkins/build_theme.sh ${Theme}"
}
}

def runTests(folder, name, skip) {
sh "python src/jenkins/get_folder_tests.py ${folder} ${name}"
def TestsList
try {
def TestJson = readFile("${name}_tests.json")
TestsList = new JsonSlurperClassic().parseText(TestJson)
}
catch (exc) {
echo "No json file, exiting"
return
}
def TestResults = [:]
for (def Test : TestsList) {
echo "Running ${Test} test"
def result = false
try {
def Test_Name = Test.split('/').last().split("\\.").first()
if(Test.endsWith('.py')) {
sh "set -o pipefail && python ${Test} 2>&1 | tee results/${name}_${Test_Name}_results.txt"
} else {
sh "set -o pipefail && /bin/bash ${Test} 2>&1 | tee results/${name}_${Test_Name}_results.txt"
}
result = true
} catch(exc) {
if(!skip) {
echo "Exception: $exc"
error("Test didn't pass")
}
}
finally {
TestResults[Test] = result
}
}
writeFile(file: "results/${name}_test.txt", text: new JsonBuilder(TestResults).toPrettyString())
}

def buildDockerImage(archName, image, buildName) {
sh "docker build -t ${buildName} -f docker/dockerfiles/${archName}/${image}/Dockerfile ."
}

@NonCPS
static def mapToList(depmap) {
def dlist = []
for (def entry2 in depmap) {
dlist.add(new java.util.AbstractMap.SimpleImmutableEntry(entry2.key, entry2.value))
}
dlist
}

node('docker-host') {
stage('Checkout') {
checkout scm
sh 'mkdir -p results'
sh 'rsync -avz src/jenkins/root/ ./'

// This comment is needed until I refactor Jenkinsfile to support proper error throwing
// def deps = 'asdas/asdasddas/asdasda/asdasd'.split('/').last().split("\\.").first()
}
def stable = true
env.PYTHONPATH = pwd()
try {
def containersToBuild = []
stage('Prepare Docker containers') {
Expand Down Expand Up @@ -56,12 +135,14 @@ node('docker-host') {
try {
stage('Run Chat') {
sh '/bin/sh src/jenkins/run_chat.sh'
sh 'ps aux | grep -v grep | grep main.py'
}
stage('Run Tests') {
stage('Chat Tests') {
runTests('src/jenkins/chat_tests', 'chat', false)
}
stage('Module Tests') {
echo 'Module Tests'
}
}
stage('Lint Tests') {
try {
Expand All @@ -73,35 +154,32 @@ node('docker-host') {
stable = false
}
}
} finally {
} catch(exc) {
echo "${exc}"
throw(exc)
}
finally {
echo "Chat logs"
sh 'cat chat.log'
archive 'results/**'
try {
sh "python src/jenkins/tests_to_xml.py ${container}"
junit 'results/chat_tests.xml'
archive 'results/**'
} catch (exc) {
echo "Got Exception, skipping"
}
}
}
}
}
}
stage('Build') {
if (env.BRANCH_NAME == 'develop' || env.BRANCH_NAME == 'master') {
def ZipName = env.BUILD_TAG.replace('jenkins-', '')
echo ZipName
def container = 'deforce/ubuntu-builder'
sh "cp requires_windows.txt requirements.txt"
def binariesLocation = "http://repo.intra.czt.lv/lalkachat/"
sh "wget -r --cut-dirs=1 -nH -np --reject index.html ${binariesLocation} "
sh "docker run -v \"\$(pwd):/src/\" ${container}"
sh "sh src/jenkins/build_default_themes.sh"
sh "cp -r http/ dist/windows/main/http/"
sh "chmod a+x -R dist/windows/main/"
sh "mv dist/windows/main dist/windows/LalkaChat"
dir('dist/windows/') {
sh "zip -r ${ZipName}.zip LalkaChat"
}
archive "dist/windows/${ZipName}.zip"
sh "chmod 664 dist/windows/${ZipName}.zip"
def UploadPath = "jenkins@czt.lv:/usr/local/nginx/html/czt.lv/lalkachat/"
sh "scp dist/windows/${ZipName}.zip ${UploadPath}"
}
stage('Publish') {
env.ZIP_NAME = env.BUILD_TAG.replace('jenkins-', '')
sh "sh src/jenkins/publish_chat.sh"
sh """
tar -zcvf themes-${BRANCH_NAME.replace('/', '-')}.tar.gz http/
cp ./themes-${BRANCH_NAME.replace('/', '-')}.tar.gz ${env.UPLOAD_DIR}/
""".stripIndent()
}
}
finally {
Expand All @@ -110,61 +188,9 @@ node('docker-host') {
currentBuild.result = 'UNSTABLE'
}
sh 'rm -rf dist/'
sh 'docker rmi -f $(docker images | grep \'^<none>\' | awk \'{print \$3}\') || true'
sh 'docker rm $(docker ps -aq) || true'
sh 'docker rmi -f $(docker images -a | grep \'^<none>\' | awk \'{print \$3}\') || true'
deleteDir()
}
}
}

def buildThemes() {
// Creates themes.json
sh 'python src/jenkins/get_themes.py'
def ThemesJson = readFile('themes.json')
def ThemesList = new JsonSlurperClassic().parseText(ThemesJson)
echo "${ThemesList}"
for (def Theme : ThemesList) {
sh "/bin/sh src/jenkins/test_theme.sh ${Theme}"
sh "/bin/sh src/jenkins/build_theme.sh ${Theme}"
}
}

def runTests(folder, name, skip) {
sh "python src/jenkins/get_folder_tests.py ${folder} ${name}"
def TestJson = readFile("${name}_tests.json")
def TestsList = new JsonSlurperClassic().parseText(TestJson)
def TestResults = [:]
for (def Test : TestsList) {
echo "Running ${Test} test"
def result = false
try {
def Test_Name = Test.split('/').last().split("\\.").first()
if(Test.endsWith('.py')) {
sh "set -o pipefail && python ${Test} 2>&1 | tee results/${name}_${Test_Name}_results.txt"
} else {
sh "set -o pipefail && /bin/bash ${Test} 2>&1 | tee results/${name}_${Test_Name}_results.txt"
}
result = true
} catch(exc) {
if(!skip) {
error('Test didn\'t pass')
}
}
finally {
TestResults[Test] = result
}
}
writeFile(file: "results/${name}_test.txt", text: new JsonBuilder(TestResults).toPrettyString())
}

def buildDockerImage(archName, image, buildName) {
sh "docker build -t ${buildName} -f docker/dockerfiles/${archName}/${image}/Dockerfile ."
}

@NonCPS
def mapToList(depmap) {
def dlist = []
for (def entry2 in depmap) {
dlist.add(new java.util.AbstractMap.SimpleImmutableEntry(entry2.key, entry2.value))
}
dlist
}
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Docker build is available for testing LalkaChat, uses XPRA to display GUI from b
- `docker run -rm --name chat-test -p 8080:8080 -v <PATH_TO_CONFIG>:/usr/lib/python2.7/site-packages/LalkaChat/conf deforce/lalkachat:testing`

## Special Thanks:
ftpud - for fixing IE compatibility (Old problem with IE Browser)
JAre - for being awesome with his docker stuff
ichursin - for deep knowledge in JavaScript and helping me with code
l0stparadis3 - for helping and testing in Linux environment
ftpud - for fixing IE compatibility (Old problem with IE Browser)
JAre - for being awesome with his docker stuff
[ichursin](https://github.com/ichursin) - for deep knowledge in JavaScript and helping me with code
l0stparadis3 - for helping and testing in Linux environment
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ MAINTAINER CzT/DeForce <vlad@czt.lv>

# Deps for testing
RUN apk --update add curl bash nodejs-npm rsync
RUN pip install git-lint pep8 pylint
RUN pip install git-lint pep8 pylint junit-xml
RUN npm install -g csslint
4 changes: 2 additions & 2 deletions docker/dockerfiles/fedora/build-deps/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
FROM fedora
FROM fedora:25

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

# Dependancies for LalkaChat
# Dependencies for LalkaChat
COPY requires_linux.txt /root/
RUN dnf -y install wxPython
RUN pip install -r /root/requires_linux.txt
2 changes: 1 addition & 1 deletion docker/dockerfiles/fedora/testing/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ FROM deforce/lc-fedora-build-deps

# Dependancies for Testing
RUN dnf -y install nodejs
RUN pip install git-lint pep8 pylint
RUN pip install git-lint pep8 pylint junit-xml
RUN npm install -g csslint
3 changes: 1 addition & 2 deletions docker/dockerfiles/ubuntu/builder/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ RUN apt-get install -y xvfb
RUN wget -qO /root/wxpython.exe http://downloads.sourceforge.net/wxpython/wxPython3.0-win32-3.0.2.0-py27.exe
RUN (Xvfb :1 -screen 0 800x600x24&) && \
sleep 3 && \
DISPLAY=:1 wine /root/wxpython.exe /SP- /VERYSILENT && \
rm -rf /tmp/.wine-*
DISPLAY=:1 wine /root/wxpython.exe /SP- /VERYSILENT
Loading

0 comments on commit aa9e38b

Please sign in to comment.