Skip to content

Commit

Permalink
Update to v20.2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
devs-mycroft committed Apr 23, 2020
2 parents d4bbe33 + 4d45933 commit ba07843
Show file tree
Hide file tree
Showing 77 changed files with 1,796 additions and 367 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -24,6 +24,7 @@ doc/_build/
.installed
.mypy_cache
.vscode
.theia
.venv/

# Created by unit tests
Expand Down
209 changes: 209 additions & 0 deletions Jenkinsfile
@@ -0,0 +1,209 @@
pipeline {
agent any
options {
// Running builds concurrently could cause a race condition with
// building the Docker image.
disableConcurrentBuilds()
buildDiscarder(logRotator(numToKeepStr: '5'))
lock resource: 'VoightKampff'
}
stages {
// Run the build in the against the dev branch to check for compile errors
stage('Run Integration Tests') {
when {
anyOf {
branch 'dev'
branch 'master'
changeRequest target: 'dev'
}
}
environment {
// Some branches have a "/" in their name (e.g. feature/new-and-cool)
// Some commands, such as those tha deal with directories, don't
// play nice with this naming convention. Define an alias for the
// branch name that can be used in these scenarios.
BRANCH_ALIAS = sh(
script: 'echo $BRANCH_NAME | sed -e "s#/#-#g"',
returnStdout: true
).trim()
}
steps {
echo 'Building Mark I Voight-Kampff Docker Image'
sh 'cp test/Dockerfile.test Dockerfile'
sh 'docker build \
--target voight_kampff_builder \
--build-arg platform=mycroft_mark_1 \
-t voight-kampff-mark-1:${BRANCH_ALIAS} .'
echo 'Running Mark I Voight-Kampff Test Suite'
timeout(time: 60, unit: 'MINUTES')
{
sh 'docker run \
-v "$HOME/voight-kampff/identity:/root/.mycroft/identity" \
-v "$HOME/voight-kampff/:/root/allure" \
voight-kampff-mark-1:${BRANCH_ALIAS} \
-f allure_behave.formatter:AllureFormatter \
-o /root/allure/allure-result --tags ~@xfail'
}
}
post {
always {
echo 'Report Test Results'
echo 'Changing ownership...'
sh 'docker run \
-v "$HOME/voight-kampff/:/root/allure" \
--entrypoint=/bin/bash \
voight-kampff-mark-1:${BRANCH_ALIAS} \
-x -c "chown $(id -u $USER):$(id -g $USER) \
-R /root/allure/"'

echo 'Transferring...'
sh 'rm -rf allure-result/*'
sh 'mv $HOME/voight-kampff/allure-result allure-result'
script {
allure([
includeProperties: false,
jdk: '',
properties: [],
reportBuildPolicy: 'ALWAYS',
results: [[path: 'allure-result']]
])
}
unarchive mapping:['allure-report.zip': 'allure-report.zip']
sh (
label: 'Publish Report to Web Server',
script: '''scp allure-report.zip root@157.245.127.234:~;
ssh root@157.245.127.234 "unzip -o ~/allure-report.zip";
ssh root@157.245.127.234 "rm -rf /var/www/voight-kampff/core/${BRANCH_ALIAS}";
ssh root@157.245.127.234 "mv allure-report /var/www/voight-kampff/core/${BRANCH_ALIAS}"
'''
)
echo 'Report Published'
}
failure {
script {
// Create comment for Pull Requests
if (env.CHANGE_ID) {
echo 'Sending PR comment'
pullRequest.comment('Voight Kampff Integration Test Failed ([Results](https://reports.mycroft.ai/core/' + env.BRANCH_ALIAS + '))')
}
}
// Send failure email containing a link to the Jenkins build
// the results report and the console log messages to Mycroft
// developers, the developers of the pull request and the
// developers that caused the build to fail.
echo 'Sending Failure Email'
emailext (
attachLog: true,
subject: "FAILED - Core Integration Tests - Build ${BRANCH_NAME} #${BUILD_NUMBER}",
body: """
<p>
One or more integration tests failed. Use the
resources below to identify the issue and fix
the failing tests.
</p>
<br>
<p>
<a href='${BUILD_URL}'>
Jenkins Build Details
</a>
&nbsp(Requires account on Mycroft's Jenkins instance)
</p>
<br>
<p>
<a href='https://reports.mycroft.ai/core/${BRANCH_ALIAS}'>
Report of Test Results
</a>
</p>
<br>
<p>Console log is attached.</p>""",
replyTo: 'devops@mycroft.ai',
to: 'dev@mycroft.ai',
recipientProviders: [
[$class: 'RequesterRecipientProvider'],
[$class:'CulpritsRecipientProvider'],
[$class:'DevelopersRecipientProvider']
]
)
}
success {
script {
if (env.CHANGE_ID) {
echo 'Sending PR comment'
pullRequest.comment('Voight Kampff Integration Test Succeeded ([Results](https://reports.mycroft.ai/core/' + env.BRANCH_ALIAS + '))')
}
}
// Send success email containing a link to the Jenkins build
// and the results report to Mycroft developers, the developers
// of the pull request and the developers that caused the
// last failed build.
echo 'Sending Success Email'
emailext (
subject: "SUCCESS - Core Integration Tests - Build ${BRANCH_NAME} #${BUILD_NUMBER}",
body: """
<p>
All integration tests passed. No further action required.
</p>
<br>
<p>
<a href='${BUILD_URL}'>
Jenkins Build Details
</a>
&nbsp(Requires account on Mycroft's Jenkins instance)
</p>
<br>
<p>
<a href='https://reports.mycroft.ai/core/${BRANCH_ALIAS}'>
Report of Test Results
</a>
</p>""",
replyTo: 'devops@mycroft.ai',
to: 'dev@mycroft.ai',
recipientProviders: [
[$class: 'RequesterRecipientProvider'],
[$class:'CulpritsRecipientProvider'],
[$class:'DevelopersRecipientProvider']
]
)
}
}
}
// Build a voight_kampff image for major releases. This will be used
// by the mycroft-skills repository to test skill changes. Skills are
// tested against major releases to determine if they play nicely with
// the breaking changes included in said release.
stage('Build Major Release Image') {
when {
tag "release/v*.*.0"
}
environment {
// Tag name is usually formatted like "20.2.0" whereas skill
// branch names are usually "20.02". Reformat the tag name
// to the skill branch format so this image will be easy to find
// in the mycroft-skill repository.
SKILL_BRANCH = sh(
script: 'echo $TAG_NAME | sed -e "s/v//g" -e "s/[.]0//g" -e "s/[.]/.0/g"',
returnStdout: true
).trim()
}
steps {
echo 'Building ${TAG_NAME} Docker Image for Skill Testing'
sh 'cp test/Dockerfile.test Dockerfile'
sh 'docker build \
--target voight_kampff_builder \
--build-arg platform=mycroft_mark_1 \
-t voight-kampff-mark-1:${SKILL_BRANCH} .'
}
}
}
post {
cleanup {
sh(
label: 'Docker Container and Image Cleanup',
script: '''
docker container prune --force;
docker image prune --force;
'''
)
}
}
}
28 changes: 23 additions & 5 deletions README.md
Expand Up @@ -84,14 +84,32 @@ When the configuration loader starts, it looks in these locations in this order,

## Using Mycroft Without Home

If you do not wish to use the Mycroft Home service, you may insert your own API keys into the configuration files listed below in <b>configuration</b>.
If you do not wish to use the Mycroft Home service, before starting Mycroft for the first time, create `$HOME/.mycroft/mycroft.conf` with the following contents:

The place to insert the API key looks like the following:
```
{
"skills": {
"blacklisted_skills": [
"mycroft-configuration.mycroftai",
"mycroft-pairing.mycroftai"
]
}
}
```

Mycroft will then be unable to perform speech-to-text conversion, so you'll need to set that up as well, using one of the [STT engines Mycroft supports](https://mycroft-ai.gitbook.io/docs/using-mycroft-ai/customizations/stt-engine).

`[WeatherSkill]`
`api_key = ""`
You may insert your own API keys into the configuration files listed above in <b>Configuration</b>. For example, to insert the API key for the Weather skill, create a new JSON key in the configuration file like so:

Put a relevant key inside the quotes and mycroft-core should begin to use the key immediately.
```
{
// other configuration settings...
//
"WeatherSkill": {
"api_key": "<insert your API key here>"
}
}
```

## API Key Services

Expand Down
5 changes: 4 additions & 1 deletion bin/mycroft-skill-testrunner
Expand Up @@ -23,6 +23,9 @@ source "$DIR/../venv-activate.sh" -q
# Invoke the individual skill tester
if [ "$#" -eq 0 ] ; then
python -m test.integrationtests.skills.runner .
elif [ "$1" = "vktest" ] ; then
shift
python -m test.integrationtests.voight_kampff "$@"
else
python -m test.integrationtests.skills.runner $@
fi
fi
2 changes: 1 addition & 1 deletion dev_setup.sh
Expand Up @@ -274,7 +274,7 @@ fi" > ~/.profile_mycroft
# Add PEP8 pre-commit hook
sleep 0.5
echo '
(Devloper) Do you want to automatically check code-style when submitting code.
(Developer) Do you want to automatically check code-style when submitting code.
If unsure answer yes.
'
if get_YN ; then
Expand Down
51 changes: 37 additions & 14 deletions mycroft/client/enclosure/__main__.py
Expand Up @@ -12,44 +12,67 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
import sys
"""Entrypoint for enclosure service.
This provides any "enclosure" specific functionality, for example GUI or
control over the Mark-1 Faceplate.
"""
from mycroft.configuration import LocalConf, SYSTEM_CONFIG
from mycroft.util.log import LOG
from mycroft.messagebus.client import MessageBusClient
from mycroft.configuration import Configuration, LocalConf, SYSTEM_CONFIG
from mycroft.util import (create_daemon, wait_for_exit_signal,
reset_sigint_handler)


def main():
# Read the system configuration
system_config = LocalConf(SYSTEM_CONFIG)
platform = system_config.get("enclosure", {}).get("platform")
def create_enclosure(platform):
"""Create an enclosure based on the provided platform string.
Arguments:
platform (str): platform name string
Returns:
Enclosure object
"""
if platform == "mycroft_mark_1":
LOG.debug("Creating Mark I Enclosure")
LOG.info("Creating Mark I Enclosure")
from mycroft.client.enclosure.mark1 import EnclosureMark1
enclosure = EnclosureMark1()
elif platform == "mycroft_mark_2":
LOG.debug("Creating Mark II Enclosure")
LOG.info("Creating Mark II Enclosure")
from mycroft.client.enclosure.mark2 import EnclosureMark2
enclosure = EnclosureMark2()
else:
LOG.debug("Creating generic enclosure, platform='{}'".format(platform))
LOG.info("Creating generic enclosure, platform='{}'".format(platform))

# TODO: Mechanism to load from elsewhere. E.g. read a script path from
# the mycroft.conf, then load/launch that script.
from mycroft.client.enclosure.generic import EnclosureGeneric
enclosure = EnclosureGeneric()

return enclosure


def main():
"""Launch one of the available enclosure implementations.
This depends on the configured platform and can currently either be
mycroft_mark_1 or mycroft_mark_2, if unconfigured a generic enclosure with
only the GUI bus will be started.
"""
# Read the system configuration
system_config = LocalConf(SYSTEM_CONFIG)
platform = system_config.get("enclosure", {}).get("platform")

enclosure = create_enclosure(platform)
if enclosure:
try:
LOG.debug("Enclosure started!")
enclosure.run()
reset_sigint_handler()
create_daemon(enclosure.run)
wait_for_exit_signal()
except Exception as e:
print(e)
finally:
sys.exit()
else:
LOG.debug("No enclosure available for this hardware, running headless")
LOG.info("No enclosure available for this hardware, running headless")


if __name__ == "__main__":
Expand Down

0 comments on commit ba07843

Please sign in to comment.