Skip to content

Commit 1126c73

Browse files
committed
Add code style check, pytest, and static type check workflows
Add __future__ import annotations Update dependencies and fix imports Remove unnecessary imports in test_huggingface_sentence_generator.py Update mypy and pytest configurations Update torch_dtype parameter in HuggingfaceSentenceGenerator constructor Update device initialization in HuggingfaceSentenceGenerator Update dependencies and development instructions Add build workflow and update dependencies Update build.yaml to trigger workflow on tag push Add version check in build workflow Add validate-version workflow Fix Python version format in build and validate-version workflows modity validate version Update pytest.yaml to remove unnecessary option Update validate-version.yaml to check if the tag matches __version__ in __init__.py Refactor workflows
1 parent 08ed41a commit 1126c73

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+446
-182
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
1-
name: Pytest
1+
name: Code Style Check
22

33
on:
4-
push:
5-
pull_request:
6-
types: [opened, synchronize]
4+
workflow_call:
75

86
jobs:
97
test:
108
runs-on: windows-latest
119
strategy:
1210
matrix:
13-
python-version: ["3.10", "3.11"]
11+
python-version: [3.8, 3.9, "3.10", "3.11", "3.12"]
1412
steps:
1513
- uses: actions/checkout@v1
1614
- name: Set up Python ${{ matrix.python-version }}
@@ -20,15 +18,8 @@ jobs:
2018
- name: Install requirements
2119
run: |
2220
python -m pip install --upgrade pip
23-
python -m pip install .[huggingface,extra,dev]
24-
- name: Lint
21+
python -m pip install -e .[dev]
22+
- name: Code Style Check
2523
run: |
2624
python -m flake8 simple_typing_application --show-source
2725
python -m flake8 tests --show-source
28-
- name: Type check
29-
run: |
30-
python -m mypy simple_typing_application
31-
python -m mypy tests
32-
- name: Test
33-
run: |
34-
python -m pytest -m "not integrate"
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: On Pull Request
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize]
6+
7+
jobs:
8+
test:
9+
uses: ./.github/workflows/pytest-workflow-call.yaml
10+
static-type-check:
11+
uses: ./.github/workflows/static-type-check-workflow-call.yaml
12+
code-style-check:
13+
uses: ./.github/workflows/code-style-check-workflow-call.yaml

.github/workflows/on-push.yaml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: On Push
2+
3+
on:
4+
push:
5+
branches:
6+
- "*"
7+
8+
jobs:
9+
test:
10+
uses: ./.github/workflows/pytest-workflow-call.yaml
11+
static-type-check:
12+
uses: ./.github/workflows/static-type-check-workflow-call.yaml
13+
code-style-check:
14+
uses: ./.github/workflows/code-style-check-workflow-call.yaml

.github/workflows/on-schedule.yaml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: On Schedule
2+
3+
on:
4+
schedule:
5+
- cron: "0 17 * * 6"
6+
7+
jobs:
8+
test:
9+
uses: ./.github/workflows/pytest-workflow-call.yaml
10+
static-type-check:
11+
uses: ./.github/workflows/static-type-check-workflow-call.yaml
12+
code-style-check:
13+
uses: ./.github/workflows/code-style-check-workflow-call.yaml

.github/workflows/on_push_tags.yaml

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: On Push Tags
2+
3+
on:
4+
push:
5+
tags:
6+
- "*.*.*"
7+
8+
jobs:
9+
test:
10+
uses: ./.github/workflows/pytest-workflow-call.yaml
11+
static-type-check:
12+
uses: ./.github/workflows/static-type-check-workflow-call.yaml
13+
code-style-check:
14+
uses: ./.github/workflows/code-style-check-workflow-call.yaml
15+
validate-version:
16+
uses: ./.github/workflows/validate-version-workflow-call.yaml
17+
deploy:
18+
needs: [test, static-type-check, code-style-check, validate-version]
19+
runs-on: windows-latest
20+
env:
21+
PRIVATE_REPO_USER: "hmasdev"
22+
strategy:
23+
matrix:
24+
python-version: ["3.10"]
25+
steps:
26+
- uses: actions/checkout@v1
27+
28+
- name: Set up Python ${{ matrix.python-version }}
29+
uses: actions/setup-python@v1
30+
with:
31+
python-version: ${{ matrix.python-version }}
32+
33+
- name: Install requirements
34+
run: |
35+
python -m pip install --upgrade pip
36+
python -m pip install -e .[dev]
37+
38+
- name: Build
39+
run: |
40+
python setup.py sdist bdist_wheel
41+
42+
- name: Release
43+
id: release
44+
uses: actions/create-release@v1
45+
env:
46+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
47+
with:
48+
tag_name: ${{ github.ref }}
49+
release_name: Release ${{ github.ref }}
50+
draft: false
51+
prerelease: false
52+
53+
- name: Publish tar.gz
54+
uses: actions/upload-release-asset@v1
55+
env:
56+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
57+
with:
58+
upload_url: ${{ steps.release.outputs.upload_url }}
59+
asset_path: dist/*.tar.gz
60+
asset_content_type: application/gzip
61+
62+
- name: Publish .whl
63+
uses: actions/upload-release-asset@v1
64+
env:
65+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
66+
with:
67+
upload_url: ${{ steps.release.outputs.upload_url }}
68+
asset_path: dist/*.whl
69+
asset_content_type: application/zip
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Pytest
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
test:
8+
runs-on: windows-latest
9+
strategy:
10+
matrix:
11+
python-version: [3.8, 3.9, "3.10", "3.11", "3.12"]
12+
option: ["", "huggingface,", "extra,"]
13+
steps:
14+
- uses: actions/checkout@v1
15+
- name: Set up Python ${{ matrix.python-version }}
16+
uses: actions/setup-python@v1
17+
with:
18+
python-version: ${{ matrix.python-version }}
19+
- name: Install requirements
20+
run: |
21+
python -m pip install --upgrade pip
22+
python -m pip install .[${{ matrix.option }}dev]
23+
- name: Test
24+
run: |
25+
python -m pytest -m "not integrate"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Static Type Check
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
test:
8+
runs-on: windows-latest
9+
strategy:
10+
matrix:
11+
python-version: [3.8, 3.9, "3.10", "3.11", "3.12"]
12+
steps:
13+
- uses: actions/checkout@v1
14+
- name: Set up Python ${{ matrix.python-version }}
15+
uses: actions/setup-python@v1
16+
with:
17+
python-version: ${{ matrix.python-version }}
18+
- name: Install requirements
19+
run: |
20+
python -m pip install --upgrade pip
21+
python -m pip install -e .[dev]
22+
- name: Code Style Check
23+
run: |
24+
python -m mypy simple_typing_application
25+
python -m mypy tests
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Validate Version
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
validate_version:
8+
runs-on: windows-latest
9+
env:
10+
PRIVATE_REPO_USER: "hmasdev"
11+
strategy:
12+
matrix:
13+
python-version: ["3.10"]
14+
steps:
15+
- uses: actions/checkout@v1
16+
- name: Set up Python ${{ matrix.python-version }}
17+
uses: actions/setup-python@v1
18+
with:
19+
python-version: ${{ matrix.python-version }}
20+
- name: Install requirements
21+
run: |
22+
python -m pip install --upgrade pip
23+
python -m pip install -e .
24+
- name: Check Version
25+
run: |
26+
# Check if the tag is the same as simple_typing_application.__version__
27+
$env:tag = git describe --tags --abbrev=0
28+
python -c "import os; import simple_typing_application; assert simple_typing_application.__version__ == os.getenv('tag')"

README.md

+72-41
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,29 @@
55
![GitHub](https://img.shields.io/github/license/hmasdev/simple_typing_application)
66
![GitHub last commit](https://img.shields.io/github/last-commit/hmasdev/simple_typing_application)
77

8+
![pytest](https://github.com/hmasdev/simple_typing_application/actions/workflows/pytest.yaml/badge.svg)
9+
![flake8](https://github.com/hmasdev/simple_typing_application/actions/workflows/code-style-check.yaml/badge.svg)
10+
![mypy](https://github.com/hmasdev/simple_typing_application/actions/workflows/static-type-check.yaml/badge.svg)
11+
812
![application image](./pics/application.png)
913

1014
## Requires
1115

12-
- Python >= 3.8
13-
14-
### Dependencies
1516

16-
- `click`
17-
- `langchain`
18-
- `openai`
19-
- `pydantic`
20-
- `pynput`
21-
- `requests`
22-
- `types-pynput`
23-
- `types-requests`
17+
- Python >= 3.8
2418

25-
### Others
19+
- `click`
20+
- `langchain`
21+
- `openai`
22+
- `pydantic`
23+
- `pynput`
24+
- `requests`
25+
- `types-pynput`
26+
- `types-requests`
2627

27-
- OpenAI API
28+
- OpenAI API Key
2829

29-
See `setup.cfg` for other optional dependencies.
30+
See `pyproject.toml` for detail information.
3031

3132
## Installation
3233

@@ -50,7 +51,7 @@ You can specify the following optional dependencies:
5051
- `[extra]`
5152
- `[dev]`
5253

53-
For more details, see [`./setup.cfg`](./setup.cfg).
54+
For more details, see [`./pyproject.toml`](./pyproject.toml).
5455

5556
## Usage
5657

@@ -203,41 +204,71 @@ Refer to [`./sample_record.json`](./sample_record.json) for example.
203204

204205
## Development
205206

206-
### Preparation
207+
1. Fork this repository:
208+
- [https://github.com/hmasdev/simple_typing_application/fork](https://github.com/hmasdev/simple_typing_application/fork)
207209

208-
```bash
209-
$ git clone https://github.com/hmasdev/simple_typing_application.git
210-
$ cd simple_typing_application
211-
$ pip install .[huggingface,extra,dev]
212-
```
210+
2. Clone your forked repository:
213211

214-
or
212+
```bash
213+
$ git clone https://github.com/hmasdev/simple_typing_application
214+
$ cd simple_typing_application
215+
```
215216

216-
```bash
217-
$ git clone https://github.com/hmasdev/simple_typing_application.git
218-
$ cd simple_typing_application
219-
$ pip install -r requirements.txt
220-
$ pip install -r requirements-dev.txt
221-
```
217+
3. Create your feature branch:
222218

223-
### Devlopment
219+
```bash
220+
$ git checkout -b feature/your-feature
221+
```
224222

225-
TBD
223+
4. Setup your development environment:
226224

227-
### Test
225+
```bash
226+
$ pip install .[dev]
227+
```
228228

229-
```bash
230-
$ pytest # Unit test
231-
$ pytest -m integrate # integration test
232-
$ flake8 simple_typing_application
233-
$ flake8 tests
234-
$ mypy simple_typing_application
235-
$ mypy tests
236-
```
229+
if you want to develop the application with `huggingface`, `pandas` and etc., run the following command:
230+
231+
```bash
232+
$ pip install .[huggingface,extra,dev]
233+
```
234+
235+
To know which option is available, see [`./pyproject.toml`](./pyproject.toml).
236+
237+
5. Develop your feature and add tests.
238+
239+
6. Test your feature:
240+
241+
```bash
242+
$ pytest # Unit test
243+
$ pytest -m integrate # integration test
244+
```
245+
246+
7. Check the code style and static type:
247+
248+
```bash
249+
$ flake8 simple_typing_application
250+
$ flake8 tests
251+
$ mypy simple_typing_application
252+
$ mypy tests
253+
```
254+
255+
8. Commit your changes:
256+
257+
```bash
258+
$ git add .
259+
$ git commit -m "Add your feature"
260+
```
261+
262+
9. Push to the branch:
263+
264+
```bash
265+
$ git push -u origin feature/your-feature
266+
```
237267

238-
## Contribute
268+
10. Create a new Pull Request:
269+
- [https://github.com/hmasdev/simple_typing_application/compare](https://github.com/hmasdev/simple_typing_application/compare)
239270

240-
TBD
271+
Thank you for your contribution!
241272

242273
## LICENSE
243274

mypy.ini

-10
This file was deleted.

0 commit comments

Comments
 (0)