-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #452 from DeForce/develop
Release 0.4.0
- Loading branch information
Showing
74 changed files
with
4,698 additions
and
2,720 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = "[email protected]:/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') { | ||
|
@@ -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 { | ||
|
@@ -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 = "[email protected]:/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 { | ||
|
@@ -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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,5 +4,5 @@ MAINTAINER CzT/DeForce <[email protected]> | |
|
||
# 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 |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.