Skip to content

Commit

Permalink
modernize (#5)
Browse files Browse the repository at this point in the history
* modernize

* modernize

* bump workflows

* ignore setuptools vulnerability

---------

Co-authored-by: emphasize <[email protected]>
  • Loading branch information
JarbasAl and emphasize authored May 30, 2023
1 parent 1520934 commit 8beccb1
Show file tree
Hide file tree
Showing 12 changed files with 299 additions and 58 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/auto_translate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Auto translate
on:
push:
branches:
- dev
paths:
- 'locale/en-us/**'
- 'dialog/en-us/**'
- 'vocab/en-us/**'
workflow_dispatch:

jobs:
autotranslate:
if: "! contains(toJSON(github.event.commits.*.message), 'autotranslate')"
env:
API_KEY: ${{secrets.DL_API_KEY}}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: dev
fetch-depth: 0 # otherwise, there would be errors pushing refs to the destination repository.
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: 3.8
- name: Install Translate Tools
run: |
python -m pip install ovos-translate-plugin-deepl ovos-utils
- name: Auto Translate
run: |
python scripts/translate.py
- name: Commit to dev
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Increment Version
branch: dev
11 changes: 6 additions & 5 deletions .github/workflows/build_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ jobs:
strategy:
max-parallel: 2
matrix:
python-version: [ 3.7, 3.8, 3.9, "3.10" ]
python-version: [ 3.7, 3.8, 3.9, "3.10", "3.11" ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v1
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install Build Tools
Expand All @@ -37,8 +37,9 @@ jobs:
- name: Install skill
run: |
pip install .
- uses: pypa/[email protected].0
- uses: pypa/[email protected].7
with:
# Ignore setuptools vulnerability we can't do much about
ignore-vulns: |
GHSA-r9hx-vwmv-q579
GHSA-r9hx-vwmv-q579
PYSEC-2022-43012
12 changes: 6 additions & 6 deletions .github/workflows/install_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ jobs:
plugin_tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v1
uses: actions/setup-python@v4
with:
python-version: 3.8
- name: Install test dependencies
Expand All @@ -40,9 +40,9 @@ jobs:
osm_tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v1
uses: actions/setup-python@v4
with:
python-version: 3.8
- name: Install ovos dependencies
Expand All @@ -57,9 +57,9 @@ jobs:
msm_tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v1
uses: actions/setup-python@v4
with:
python-version: 3.8
- name: Install msm
Expand Down
55 changes: 55 additions & 0 deletions .github/workflows/propose_translation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Propose Translation
on:
workflow_dispatch:
inputs:
language:
type: choice
description: Language to translate
options:
- de-de
- ca-es
- es-es
- cs-cz
- fr-fr
- it-it
- da-dk
- nl-nl
- hu-hu
- pl-pl
- pt-pt
- ru-ru
- sv-fi
- sv-se
- tr-tr

jobs:
Propose_translation:
env:
TARGET_LANG: ${{ inputs.language }}
API_KEY: ${{ secrets.DL_API_KEY }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.ref_name }}
fetch-depth: 0 # otherwise, there would be errors pushing refs to the destination repository.
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: 3.8
- name: Install Translate Tools
run: |
python -m pip install ovos-translate-plugin-deepl ovos-utils
- name: Run Translate Script
run: python scripts/translate.py
- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: autotranslate
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
title: Proposed ${{ inputs.language }} Translations
body: Translations for review
labels: translation
branch: staging/translation_${{ inputs.language }}
reviewers: emphasize
8 changes: 5 additions & 3 deletions .github/workflows/publish_alpha.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ jobs:
build_and_publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
ref: dev
fetch-depth: 0 # otherwise, there would be errors pushing refs to the destination repository.
- name: Setup Python
uses: actions/setup-python@v1
uses: actions/setup-python@v4
with:
python-version: 3.8
- name: Install Build Tools
Expand All @@ -49,7 +49,9 @@ jobs:
commit_message: Increment Version
branch: dev
- name: version
run: echo "::set-output name=version::$(python setup.py --version)"
run: |
VERSION="$(python setup.py --version)"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
id: version
- name: Create Release
id: create_release
Expand Down
10 changes: 7 additions & 3 deletions .github/workflows/publish_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ jobs:
branch: master
force: true
- name: version
run: echo "::set-output name=version::$(python setup.py --version)"
run: |
VERSION="$(python setup.py --version)"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
id: version
- name: Create Release
id: create_release
Expand All @@ -60,9 +62,11 @@ jobs:
run: |
python setup.py bdist_wheel
- name: Prepare next Build version
run: echo "::set-output name=version::$(python setup.py --version)"
run: |
VERSION="$(python setup.py --version)"
echo "bumped_version=$VERSION" >> "$GITHUB_OUTPUT"
id: alpha
- name: Increment Version ${{ steps.alpha.outputs.version }}Alpha0
- name: Increment Version ${{ steps.alpha.outputs.bumped_version }}Alpha0
run: |
VER=$(python setup.py --version)
python scripts/bump_build.py
Expand Down
10 changes: 7 additions & 3 deletions .github/workflows/publish_major.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ jobs:
branch: master
force: true
- name: version
run: echo "::set-output name=version::$(python setup.py --version)"
run: |
VERSION="$(python setup.py --version)"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
id: version
- name: Create Release
id: create_release
Expand All @@ -60,9 +62,11 @@ jobs:
run: |
python setup.py bdist_wheel
- name: Prepare next Major version
run: echo "::set-output name=version::$(python setup.py --version)"
run: |
VERSION="$(python setup.py --version)"
echo "bumped_version=$VERSION" >> "$GITHUB_OUTPUT"
id: alpha
- name: Increment Version ${{ steps.alpha.outputs.version }}Alpha0
- name: Increment Version ${{ steps.alpha.outputs.bumped_version }}Alpha0
run: |
VER=$(python setup.py --version)
python scripts/bump_major.py
Expand Down
10 changes: 7 additions & 3 deletions .github/workflows/publish_minor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ jobs:
branch: master
force: true
- name: version
run: echo "::set-output name=version::$(python setup.py --version)"
run: |
VERSION="$(python setup.py --version)"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
id: version
- name: Create Release
id: create_release
Expand All @@ -60,9 +62,11 @@ jobs:
run: |
python setup.py bdist_wheel
- name: Prepare next Minor version
run: echo "::set-output name=version::$(python setup.py --version)"
run: |
VERSION="$(python setup.py --version)"
echo "bumped_version=$VERSION" >> "$GITHUB_OUTPUT"
id: alpha
- name: Increment Version ${{ steps.alpha.outputs.version }}Alpha0
- name: Increment Version ${{ steps.alpha.outputs.bumped_version }}Alpha0
run: |
VER=$(python setup.py --version)
python scripts/bump_minor.py
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Capture unrecognized _Utterances_

## About
Mycroft doesn't know how to do or answer everything (yet). This _fallback_ is how Mycroft lets you know that, unfortunately, it can't help with what you said.
OpenVoiceOS doesn't know how to do or answer everything (yet). This _fallback_ is how the assistant lets you know that, unfortunately, it can't help with what you said.


## Category
Expand Down
11 changes: 3 additions & 8 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from mycroft.skills.core import FallbackSkill
from ovos_workshop.skills.fallback import FallbackSkill
from ovos_utils import classproperty
from ovos_utils.process_utils import RuntimeRequirements
from ovos_workshop.decorators import fallback_handler


class UnknownSkill(FallbackSkill):
Expand All @@ -31,9 +32,7 @@ def runtime_requirements(self):
no_network_fallback=True,
no_gui_fallback=True)

def initialize(self):
self.register_fallback(self.handle_fallback, 100)

@fallback_handler(priority=100)
def handle_fallback(self, message):
utterance = message.data['utterance'].lower()

Expand All @@ -50,7 +49,3 @@ def handle_fallback(self, message):
else:
self.speak_dialog('unknown')
return True


def create_skill():
return UnknownSkill()
34 changes: 8 additions & 26 deletions scripts/prepare_skillstore.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
from ovos_skills_manager import SkillEntry
from os.path import exists, join, dirname
from shutil import rmtree
import os
from os import makedirs
import json
from ovos_utils.bracket_expansion import expand_parentheses, expand_options
import os
from os.path import exists, join, dirname

from ovos_skills_manager import SkillEntry
from ovos_utils.bracket_expansion import expand_options

branch = "dev"
repo = "skill-ovos-homescreen"
repo = "skill-ovos-fallback-unknown"
author = "OpenVoiceOS"

url = f"https://github.com/{author}/{repo}@{branch}"
Expand All @@ -18,13 +16,9 @@
skill_folder = f"{tmp_skills}/{skill.uuid}"

base_dir = dirname(dirname(__file__))
desktop_dir = join(base_dir, "res", "desktop")
android_ui = join(base_dir, "ui", "+android")
makedirs(desktop_dir, exist_ok=True)

readme = join(base_dir, "README.md")
jsonf = join(desktop_dir, "skill.json")
desktopf = join(desktop_dir, f"{repo}.desktop")
jsonf = join(base_dir, "skill.json")
skill_code = join(base_dir, "__init__.py")

res_folder = join(base_dir, "locale", "en-us")
Expand All @@ -38,33 +32,21 @@ def read_samples(path):
samples += expand_options(_)
return samples


samples = []
for root, folders, files in os.walk(res_folder):
for f in files:
if f.endswith(".intent"):
samples += read_samples(join(root, f))
skill._data["examples"] = list(set(samples))

has_android = exists(android_ui)
with open(skill_code) as f:
has_homescreen = f"{repo}.{author}.home" in f.read()

if not exists(readme):
with open(readme, "w") as f:
f.write(skill.generate_readme())

if has_homescreen and not exists(desktopf):
with open(desktopf, "w") as f:
f.write(skill.desktop_file)

if not exists(jsonf):
data = skill.json
with open(jsonf, "w") as f:
if not has_android or not has_homescreen:
data.pop("android")
if not has_homescreen:
data.pop("desktop")
data["desktopFile"] = False
data["desktopFile"] = False
else:
with open(jsonf) as f:
data = json.load(f)
Expand Down
Loading

0 comments on commit 8beccb1

Please sign in to comment.