-
-
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.
* workflows * workflows
- Loading branch information
Showing
9 changed files
with
437 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
name: Auto translate | ||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- dev | ||
|
||
jobs: | ||
translate: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
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 | ||
with: | ||
python-version: 3.8 | ||
- name: Install Translate Tools | ||
run: | | ||
pip install git+https://github.com/NeonGeckoCom/neon-lang-plugin-libretranslate | ||
- name: Auto Translate | ||
run: | | ||
python scripts/translate.py | ||
- name: Commit to dev | ||
uses: stefanzweifel/git-auto-commit-action@v4 | ||
with: | ||
commit_message: Auto Translate | ||
branch: dev | ||
prepare_skillstore: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
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 | ||
with: | ||
python-version: 3.8 | ||
- name: Install OSM | ||
run: | | ||
pip install ovos-skills-manager~=0.0.10 | ||
- name: Update Skill Store metadata | ||
run: | | ||
python scripts/prepare_skillstore.py | ||
- name: Commit to dev | ||
uses: stefanzweifel/git-auto-commit-action@v4 | ||
with: | ||
commit_message: Update skill store metadata | ||
branch: dev |
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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
name: Run Build Tests | ||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
branches: | ||
- dev | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build_tests: | ||
strategy: | ||
max-parallel: 2 | ||
matrix: | ||
python-version: [ 3.7, 3.8, 3.9, "3.10" ] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Setup Python | ||
uses: actions/setup-python@v1 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install Build Tools | ||
run: | | ||
python -m pip install build wheel | ||
- name: Install System Dependencies | ||
run: | | ||
sudo apt-get update | ||
sudo apt install python3-dev swig libssl-dev | ||
- name: Build Source Packages | ||
run: | | ||
python setup.py sdist | ||
- name: Build Distribution Packages | ||
run: | | ||
python setup.py bdist_wheel | ||
- name: Install skill | ||
run: | | ||
pip install . | ||
- uses: pypa/[email protected] |
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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
name: Run License Tests | ||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
branches: | ||
- dev | ||
workflow_dispatch: | ||
|
||
jobs: | ||
license_tests: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Setup Python | ||
uses: actions/setup-python@v1 | ||
with: | ||
python-version: 3.8 | ||
- name: Install Build Tools | ||
run: | | ||
python -m pip install build wheel | ||
- name: Install System Dependencies | ||
run: | | ||
sudo apt-get update | ||
sudo apt install python3-dev swig libssl-dev | ||
- name: Install core repo | ||
run: | | ||
pip install . | ||
- name: Get explicit and transitive dependencies | ||
run: | | ||
pip freeze > requirements-all.txt | ||
- name: Check python | ||
id: license_check_report | ||
uses: pilosus/[email protected] | ||
with: | ||
requirements: 'requirements-all.txt' | ||
fail: 'Copyleft,Other,Error' | ||
fails-only: true | ||
exclude: '^(tqdm|skill-news).*' | ||
exclude-license: '^(Mozilla).*$' | ||
- name: Print report | ||
if: ${{ always() }} | ||
run: echo "${{ steps.license_check_report.outputs.report }}" |
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 |
---|---|---|
@@ -0,0 +1,73 @@ | ||
name: Run UnitTests | ||
on: | ||
pull_request: | ||
branches: | ||
- dev | ||
paths-ignore: | ||
- 'version.py' | ||
- 'requirements.txt' | ||
- 'examples/**' | ||
- '.github/**' | ||
- '.gitignore' | ||
- 'LICENSE' | ||
- 'CHANGELOG.md' | ||
- 'MANIFEST.in' | ||
- 'readme.md' | ||
- 'scripts/**' | ||
push: | ||
branches: | ||
- master | ||
paths-ignore: | ||
- 'version.py' | ||
- 'requirements.txt' | ||
- 'examples/**' | ||
- '.github/**' | ||
- '.gitignore' | ||
- 'LICENSE' | ||
- 'CHANGELOG.md' | ||
- 'MANIFEST.in' | ||
- 'readme.md' | ||
- 'scripts/**' | ||
workflow_dispatch: | ||
|
||
jobs: | ||
unit_tests: | ||
strategy: | ||
max-parallel: 2 | ||
matrix: | ||
python-version: [ 3.7, 3.8, 3.9, "3.10" ] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install System Dependencies | ||
run: | | ||
sudo apt-get update | ||
sudo apt install python3-dev | ||
python -m pip install build wheel | ||
- name: Install core repo | ||
run: | | ||
pip install . | ||
- name: Install test dependencies | ||
run: | | ||
pip install pytest pytest-timeout pytest-cov | ||
- name: Install System Dependencies | ||
run: | | ||
sudo apt-get update | ||
sudo apt install libfann-dev | ||
- name: Install ovos dependencies | ||
run: | | ||
pip install ovos-plugin-manager ovos-core[skills_lgpl]>=0.0.5a28 | ||
- name: Run unittests | ||
run: | | ||
pytest --cov=ovos-skill-template-repo --cov-report xml test/unittests | ||
# NOTE: additional pytest invocations should also add the --cov-append flag | ||
# or they will overwrite previous invocations' coverage reports | ||
# (for an example, see OVOS Skill Manager's workflow) | ||
- name: Upload coverage | ||
env: | ||
CODECOV_TOKEN: ${{secrets.CODECOV_TOKEN}} | ||
uses: codecov/codecov-action@v2 |
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 |
---|---|---|
@@ -0,0 +1,76 @@ | ||
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 | ||
|
||
|
||
branch = "dev" | ||
repo = "skill-ovos-news" | ||
author = "OpenVoiceOS" | ||
|
||
url = f"https://github.com/{author}/{repo}@{branch}" | ||
|
||
skill = SkillEntry.from_github_url(url) | ||
tmp_skills = "/tmp/osm_installed_skills" | ||
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") | ||
skill_code = join(base_dir, "__init__.py") | ||
|
||
res_folder = join(base_dir, "locale", "en-us") | ||
|
||
|
||
def read_samples(path): | ||
samples = [] | ||
with open(path) as fi: | ||
for _ in fi.read().split("\n"): | ||
if _ and not _.strip().startswith("#"): | ||
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 | ||
else: | ||
with open(jsonf) as f: | ||
data = json.load(f) | ||
|
||
# set dev branch | ||
data["branch"] = "dev" | ||
|
||
with open(jsonf, "w") as f: | ||
json.dump(data, f, indent=4) |
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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import os | ||
from os.path import dirname, join, exists | ||
from ovos_utils.bracket_expansion import expand_options | ||
from libretranslate_neon_plugin import LibreTranslatePlugin | ||
|
||
tx = LibreTranslatePlugin(config={"libretranslate_host": "https://libretranslate.2022.us"}) | ||
|
||
src_lang = "en-us" | ||
target_langs = ["es-es", "de-de", "fr-fr", "it-it", "pt-pt"] | ||
|
||
exts = [".voc", ".dialog", ".intent", ".entity"] | ||
res_folder = join(dirname(dirname(__file__)), "locale") | ||
target_langs = list(set(target_langs + os.listdir(res_folder))) | ||
|
||
src_files = {} | ||
for root, dirs, files in os.walk(res_folder): | ||
if src_lang not in root: | ||
continue | ||
for f in files: | ||
if any(f.endswith(e) for e in exts): | ||
src_files[f] = join(root, f) | ||
|
||
for lang in target_langs: | ||
os.makedirs(join(res_folder, lang), exist_ok=True) | ||
|
||
for name, src in src_files.items(): | ||
dst = join(res_folder, lang, name) | ||
if exists(dst): | ||
continue | ||
|
||
tx_lines = [] | ||
with open(src) as f: | ||
lines = [l for l in f.read().split("\n") if l and not l.startswith("#")] | ||
|
||
for l in lines: | ||
expanded = expand_options(l) | ||
for l2 in expanded: | ||
try: | ||
translated = tx.translate(l2, target=lang, source=src_lang) | ||
tx_lines.append(translated) | ||
except Exception as e: | ||
print(e) | ||
continue | ||
if tx_lines: | ||
with open(dst, "w") as f: | ||
f.write(f"# auto translated from {src_lang} to {lang}\n") | ||
for translated in set(tx_lines): | ||
f.write(translated + "\n") |
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# write your first unittest! | ||
import unittest | ||
from os.path import exists | ||
from shutil import rmtree | ||
|
||
from ovos_skills_manager import SkillEntry | ||
|
||
branch = "dev" | ||
url = f"https://github.com/OpenVoiceOS/skill-ovos-news@{branch}" | ||
|
||
|
||
class TestOSM(unittest.TestCase): | ||
@classmethod | ||
def setUpClass(self): | ||
self.skill_id = "skill-ovos-news.openvoiceos" | ||
|
||
def test_osm_install(self): | ||
skill = SkillEntry.from_github_url(url) | ||
tmp_skills = "/tmp/osm_installed_skills" | ||
skill_folder = f"{tmp_skills}/{skill.uuid}" | ||
|
||
if exists(skill_folder): | ||
rmtree(skill_folder) | ||
|
||
updated = skill.install(folder=tmp_skills, default_branch=branch) | ||
self.assertEqual(updated, True) | ||
self.assertTrue(exists(skill_folder)) | ||
|
||
updated = skill.install(folder=tmp_skills, default_branch=branch) | ||
self.assertEqual(updated, False) |
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import unittest | ||
from ovos_plugin_manager.skills import find_skill_plugins | ||
|
||
|
||
class TestPlugin(unittest.TestCase): | ||
@classmethod | ||
def setUpClass(self): | ||
self.skill_id = "skill-ovos-news.openvoiceos" | ||
|
||
def test_find_plugin(self): | ||
plugins = find_skill_plugins() | ||
self.assertIn(self.skill_id, list(plugins)) | ||
|
Oops, something went wrong.