Skip to content

Commit 2334d7c

Browse files
committed
🎉
0 parents  commit 2334d7c

File tree

11 files changed

+732
-0
lines changed

11 files changed

+732
-0
lines changed

.github/workflows/build_tests.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Run Build Tests
2+
on:
3+
push:
4+
branches:
5+
- master
6+
pull_request:
7+
branches:
8+
- dev
9+
workflow_dispatch:
10+
11+
jobs:
12+
build_tests:
13+
strategy:
14+
max-parallel: 3
15+
matrix:
16+
python-version: ["3.10", "3.11"]
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v4
20+
- name: Setup Python
21+
uses: actions/setup-python@v5
22+
with:
23+
python-version: ${{ matrix.python-version }}
24+
- name: Install Build Tools
25+
run: |
26+
python -m pip install build wheel
27+
- name: Install System Dependencies
28+
run: |
29+
sudo apt-get update
30+
sudo apt install python3-dev swig libssl-dev
31+
- name: Build Source Packages
32+
run: |
33+
python setup.py sdist
34+
- name: Build Distribution Packages
35+
run: |
36+
python setup.py bdist_wheel
37+
- name: Install skill
38+
run: |
39+
pip install .
40+
- uses: pypa/gh-action-pip-audit@v1.0.8
41+
with:
42+
# mercurial vulnerability that doesn't affect this
43+
# setuptools vulnerability we can't do much about
44+
ignore-vulns: |
45+
PYSEC-2022-43012
46+
PYSEC-2023-228
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# auto add labels to PRs
2+
on:
3+
pull_request_target:
4+
types: [ opened, edited ]
5+
name: conventional-release-labels
6+
jobs:
7+
label:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: bcoe/conventional-release-labels@v1
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Run License Tests
2+
on:
3+
push:
4+
branches:
5+
- master
6+
pull_request:
7+
branches:
8+
- dev
9+
workflow_dispatch:
10+
11+
jobs:
12+
license_tests:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
- name: Setup Python
17+
uses: actions/setup-python@v5
18+
with:
19+
python-version: "3.10"
20+
- name: Install Build Tools
21+
run: |
22+
python -m pip install build wheel
23+
- name: Install System Dependencies
24+
run: |
25+
sudo apt-get update
26+
sudo apt install python3-dev swig libssl-dev
27+
- name: Install core repo
28+
run: |
29+
pip install .
30+
- name: Get explicit and transitive dependencies
31+
run: |
32+
pip freeze > requirements-all.txt
33+
- name: Check python
34+
id: license_check_report
35+
uses: pilosus/action-pip-license-checker@v0.5.0
36+
with:
37+
requirements: 'requirements-all.txt'
38+
fail: 'Copyleft,Other,Error'
39+
fails-only: true
40+
#exclude: '^(tqdm|skill-wikipedia-for-humans|ovos-skill-wikipedia).*'
41+
exclude-license: '^(Mozilla).*$'
42+
- name: Print report
43+
if: ${{ always() }}
44+
run: echo "${{ steps.license_check_report.outputs.report }}"
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Stable Release
2+
on:
3+
push:
4+
branches: [master]
5+
workflow_dispatch:
6+
7+
jobs:
8+
publish_stable:
9+
uses: TigreGotico/gh-automations/.github/workflows/publish-stable.yml@master
10+
secrets: inherit
11+
with:
12+
branch: 'master'
13+
version_file: 'ovos_wolfram_alpha_solver/version.py'
14+
setup_py: 'setup.py'
15+
publish_release: true
16+
17+
publish_pypi:
18+
needs: publish_stable
19+
if: success() # Ensure this job only runs if the previous job succeeds
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@v4
23+
with:
24+
ref: master
25+
fetch-depth: 0 # otherwise, there would be errors pushing refs to the destination repository.
26+
- name: Setup Python
27+
uses: actions/setup-python@v5
28+
with:
29+
python-version: "3.10"
30+
- name: Install Build Tools
31+
run: |
32+
python -m pip install build wheel
33+
- name: version
34+
run: echo "::set-output name=version::$(python setup.py --version)"
35+
id: version
36+
- name: Build Distribution Packages
37+
run: |
38+
python setup.py sdist bdist_wheel
39+
- name: Publish to PyPI
40+
uses: pypa/gh-action-pypi-publish@master
41+
with:
42+
password: ${{secrets.PYPI_TOKEN}}
43+
44+
45+
sync_dev:
46+
needs: publish_stable
47+
if: success() # Ensure this job only runs if the previous job succeeds
48+
runs-on: ubuntu-latest
49+
steps:
50+
- uses: actions/checkout@v4
51+
with:
52+
fetch-depth: 0 # otherwise, there would be errors pushing refs to the destination repository.
53+
ref: master
54+
- name: Push master -> dev
55+
uses: ad-m/github-push-action@master
56+
with:
57+
github_token: ${{ secrets.GITHUB_TOKEN }}
58+
branch: dev
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
name: Release Alpha and Propose Stable
2+
3+
on:
4+
pull_request:
5+
types: [closed]
6+
branches: [dev]
7+
workflow_dispatch:
8+
9+
jobs:
10+
11+
publish_alpha:
12+
uses: TigreGotico/gh-automations/.github/workflows/publish-alpha.yml@master
13+
secrets: inherit
14+
with:
15+
branch: 'dev'
16+
version_file: 'ovos_wolfram_alpha_solver/version.py'
17+
setup_py: 'setup.py'
18+
update_changelog: true
19+
publish_prerelease: true
20+
changelog_max_issues: 100
21+
22+
notify:
23+
if: github.event.pull_request.merged == true
24+
needs: publish_alpha
25+
runs-on: ubuntu-latest
26+
steps:
27+
- uses: actions/checkout@v4
28+
- name: Send message to Matrix bots channel
29+
id: matrix-chat-message
30+
uses: fadenb/matrix-chat-message@v0.0.6
31+
with:
32+
homeserver: 'matrix.org'
33+
token: ${{ secrets.MATRIX_TOKEN }}
34+
channel: '!WjxEKjjINpyBRPFgxl:krbel.duckdns.org'
35+
message: |
36+
new ${{ github.event.repository.name }} PR merged! https://github.com/${{ github.repository }}/pull/${{ github.event.number }}
37+
38+
39+
publish_pypi:
40+
needs: publish_alpha
41+
if: success() # Ensure this job only runs if the previous job succeeds
42+
runs-on: ubuntu-latest
43+
steps:
44+
- uses: actions/checkout@v4
45+
with:
46+
ref: dev
47+
fetch-depth: 0 # otherwise, there would be errors pushing refs to the destination repository.
48+
- name: Setup Python
49+
uses: actions/setup-python@v5
50+
with:
51+
python-version: "3.11"
52+
- name: Install Build Tools
53+
run: |
54+
python -m pip install build wheel
55+
- name: version
56+
run: echo "::set-output name=version::$(python setup.py --version)"
57+
id: version
58+
- name: Build Distribution Packages
59+
run: |
60+
python setup.py sdist bdist_wheel
61+
- name: Publish to PyPI
62+
uses: pypa/gh-action-pypi-publish@master
63+
with:
64+
password: ${{secrets.PYPI_TOKEN}}
65+
66+
propose_release:
67+
needs: publish_alpha
68+
if: success() # Ensure this job only runs if the previous job succeeds
69+
runs-on: ubuntu-latest
70+
steps:
71+
- name: Checkout dev branch
72+
uses: actions/checkout@v3
73+
with:
74+
ref: dev
75+
76+
- name: Setup Python
77+
uses: actions/setup-python@v2
78+
with:
79+
python-version: '3.10'
80+
81+
- name: Get version from setup.py
82+
id: get_version
83+
run: |
84+
VERSION=$(python setup.py --version)
85+
echo "VERSION=$VERSION" >> $GITHUB_ENV
86+
87+
- name: Create and push new branch
88+
run: |
89+
git checkout -b release-${{ env.VERSION }}
90+
git push origin release-${{ env.VERSION }}
91+
92+
- name: Open Pull Request from dev to master
93+
env:
94+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
95+
run: |
96+
# Variables
97+
BRANCH_NAME="release-${{ env.VERSION }}"
98+
BASE_BRANCH="master"
99+
HEAD_BRANCH="release-${{ env.VERSION }}"
100+
PR_TITLE="Release ${{ env.VERSION }}"
101+
PR_BODY="Human review requested!"
102+
103+
# Create a PR using GitHub API
104+
curl -X POST \
105+
-H "Accept: application/vnd.github+json" \
106+
-H "Authorization: token $GITHUB_TOKEN" \
107+
-d "{\"title\":\"$PR_TITLE\",\"body\":\"$PR_BODY\",\"head\":\"$HEAD_BRANCH\",\"base\":\"$BASE_BRANCH\"}" \
108+
https://api.github.com/repos/${{ github.repository }}/pulls
109+

.github/workflows/unit_tests.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Run UnitTests
2+
on:
3+
pull_request:
4+
branches:
5+
- dev
6+
paths-ignore:
7+
- 'version.py'
8+
- 'requirements.txt'
9+
- 'examples/**'
10+
- '.github/**'
11+
- '.gitignore'
12+
- 'LICENSE'
13+
- 'CHANGELOG.md'
14+
- 'MANIFEST.in'
15+
- 'readme.md'
16+
- 'scripts/**'
17+
push:
18+
branches:
19+
- master
20+
paths-ignore:
21+
- 'version.py'
22+
- 'requirements.txt'
23+
- 'examples/**'
24+
- '.github/**'
25+
- '.gitignore'
26+
- 'LICENSE'
27+
- 'CHANGELOG.md'
28+
- 'MANIFEST.in'
29+
- 'readme.md'
30+
- 'scripts/**'
31+
workflow_dispatch:
32+
33+
jobs:
34+
unit_tests:
35+
strategy:
36+
max-parallel: 3
37+
matrix:
38+
python-version: ["3.10", "3.11" ]
39+
runs-on: ubuntu-latest
40+
steps:
41+
- uses: actions/checkout@v4
42+
- name: Set up python ${{ matrix.python-version }}
43+
uses: actions/setup-python@v2
44+
with:
45+
python-version: ${{ matrix.python-version }}
46+
- name: Install System Dependencies
47+
run: |
48+
sudo apt-get update
49+
sudo apt install python3-dev libfann-dev
50+
python -m pip install build wheel
51+
- name: Install ovos components
52+
run: |
53+
pip install wheel "cython<3.0.0" # TODO: cython patching https://github.com/yaml/pyyaml/issues/724
54+
pip install --no-build-isolation pyyaml~=5.4 # TODO: patching https://github.com/yaml/pyyaml/issues/724
55+
pip install ovos-plugin-manager ovos-core[skills_lgpl]>=0.0.5a28 ovos-translate-server-plugin
56+
- name: Install core repo
57+
run: |
58+
pip install .
59+
- name: Install test dependencies
60+
run: |
61+
pip install pytest pytest-timeout pytest-cov
62+
- name: Run unittests
63+
run: |
64+
pytest --cov=skill_ovos_wikipedia --cov-report xml test/unittests
65+
# NOTE: additional pytest invocations should also add the --cov-append flag
66+
# or they will overwrite previous invocations' coverage reports
67+
# (for an example, see OVOS Skill Manager's workflow)
68+
- name: Upload coverage
69+
env:
70+
CODECOV_TOKEN: ${{secrets.CODECOV_TOKEN}}
71+
uses: codecov/codecov-action@v2

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Wikipedia Plugin
2+
3+
```python
4+
from ovos_wikipedia_solver import WikipediaSolver
5+
6+
s = WikipediaSolver()
7+
print(s.get_spoken_answer("quem é Elon Musk", "pt"))
8+
9+
query = "who is Isaac Newton"
10+
print(s.extract_keyword(query, "en-us"))
11+
assert s.extract_keyword(query, "en-us") == "Isaac Newton"
12+
13+
print(s.get_spoken_answer("venus", "en"))
14+
print(s.get_spoken_answer("elon musk", "en"))
15+
print(s.get_spoken_answer("mercury", "en"))
16+
```

0 commit comments

Comments
 (0)