-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Py313 (#56) * use Run CI workflow name * run 3.13 tests * update poetry.lock * add python version icons * poetry version minor * Async dataservice (#60) * AsyncDataService * minor version * remove DataItem from __all__ * Playwright optional (#61) * make playwright optional * update README.rst * minor version * Boilerplate (#62) * add cli tool * add py to filename if not present * update cli and template.py.j2 * remove check playwright in init (#63) * refactor Playwright,add PW config and devices.py * init page to None * fix playwright tests * change log.info to debug * add debug log messages * improve logs * change log level * add test_init_browser * add intercept_content_type * update publish.yml * update publish.yml for dev * update ci * fix pyproject.toml * update deps
- Loading branch information
1 parent
c7a28fd
commit 7efce08
Showing
21 changed files
with
2,060 additions
and
603 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
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 |
---|---|---|
|
@@ -2,15 +2,13 @@ name: Publish Python Package | |
|
||
on: | ||
workflow_run: | ||
workflows: [ "ci (3.11)", "ci (3.12)" ] | ||
workflows: ["CI"] | ||
types: | ||
- completed | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
release: | ||
if: github.event.workflow_run.conclusion == 'success' && github.ref == 'refs/heads/dev' | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
|
@@ -29,38 +27,53 @@ jobs: | |
- name: Install dependencies | ||
run: | | ||
poetry install --no-root | ||
poetry install --no-root -E playwright | ||
- name: Check if version is already published | ||
id: check_version | ||
run: | | ||
VERSION=$(poetry version -s) | ||
if python -m pip search dataservice==$VERSION; then | ||
echo "Version $VERSION is already published. Skipping." | ||
exit 0 | ||
else | ||
echo "Version $VERSION is not published yet. Proceeding." | ||
fi | ||
- name: Build package | ||
if: ${{ steps.check_version.outcome == 'success' }} | ||
run: | | ||
poetry build | ||
- name: Publish to PyPI | ||
- name: Publish to Test PyPI | ||
env: | ||
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.DS_PYPI_API_TOKEN }} | ||
POETRY_TEST_PYPI_TOKEN_PYPI: ${{ secrets.DS_TEST_PYPI_API_TOKEN }} | ||
run: | | ||
poetry config http-basic.pypi "__token__" "${POETRY_PYPI_TOKEN_PYPI}" | ||
poetry publish | ||
poetry config repositories.test-pypi https://test.pypi.org/legacy/ | ||
poetry config pypi-token.test-pypi "${POETRY_TEST_PYPI_TOKEN_PYPI}" | ||
poetry publish -r test-pypi | ||
- name: Get the version from pyproject.toml | ||
id: get_version | ||
run: | | ||
echo "::set-output name=version::$(poetry version -s)" | ||
- name: Create Git tag | ||
if: ${{ steps.check_version.outcome == 'success' }} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.CI_TOKEN }} | ||
run: | | ||
git config user.name "github-actions" | ||
git config user.email "[email protected]" | ||
git tag -a v${{ steps.get_version.outputs.version }} -m "Release version ${{ steps.get_version.outputs.version }}" | ||
git push https://x-access-token:${GITHUB_TOKEN}@github.com/lucaromagnoli/dataservice.git v${{ steps.get_version.outputs.version }} | ||
git tag -a v${{ steps.get_version.outputs.version }} -m "Release version ${{ steps.get_version.outputs.version }}-dev" | ||
git push https://x-access-token:${GITHUB_TOKEN}@github.com/lucaromagnoli/dataservice.git v${{ steps.get_version.outputs.version }}-dev | ||
- name: Create GitHub Release | ||
if: ${{ steps.check_version.outcome == 'success' }} | ||
uses: ncipollo/release-action@v1 | ||
with: | ||
tag: v${{ steps.get_version.outputs.version }} | ||
name: "Release ${{ steps.get_version.outputs.version }}" | ||
body: "New release version ${{ steps.get_version.outputs.version }} is published" | ||
tag: v${{ steps.get_version.outputs.version }}-dev | ||
name: "Release ${{ steps.get_version.outputs.version }}-dev" | ||
body: "New release version ${{ steps.get_version.outputs.version }}-dev is published" | ||
draft: false | ||
prerelease: false |
This file was deleted.
Oops, something went wrong.
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
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
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
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,75 @@ | ||
import argparse | ||
import os | ||
|
||
from jinja2 import Environment, PackageLoader, select_autoescape | ||
|
||
|
||
def main(): | ||
parser = argparse.ArgumentParser( | ||
description="Generate a Python file with boilerplate code for a data service." | ||
) | ||
parser.add_argument( | ||
"filename", type=str, help="The name of the Python file to create." | ||
) | ||
parser.add_argument( | ||
"--data-item", | ||
action="store_true", | ||
help="Include BaseDataItem in the generated code.", | ||
) | ||
parser.add_argument( | ||
"--service-config", | ||
action="store_true", | ||
help="Include ServiceConfig in the generated code.", | ||
) | ||
parser.add_argument( | ||
"--proxy-config", action="store_true", help="Import ProxyConfig." | ||
) | ||
parser.add_argument( | ||
"--async-service", | ||
action="store_true", | ||
help="Use AsyncDataService and make the main function async.", | ||
) | ||
parser.add_argument( | ||
"--client", | ||
help="The name of the client to use. Default is HttpXClient.", | ||
choices=["httpx", "playwright"], | ||
default="httpx", | ||
) | ||
|
||
args = parser.parse_args() | ||
|
||
filename = args.filename | ||
if not filename.endswith(".py"): | ||
filename = f"{filename}.py" | ||
script_name = filename.split(".")[0] | ||
use_httpx_client = args.client == "httpx" | ||
use_playwright_client = args.client == "playwright" | ||
use_async_data_service = args.async_service | ||
use_data_service = not use_async_data_service | ||
|
||
env = Environment( | ||
loader=PackageLoader("dataservice", "templates"), | ||
autoescape=select_autoescape(["html", "xml"]), | ||
) | ||
|
||
template = env.get_template("template.py.j2") | ||
|
||
content = template.render( | ||
script_name=script_name, | ||
use_base_data_item=args.data_item, | ||
use_service_config=args.service_config, | ||
use_httpx_client=use_httpx_client, | ||
use_playwright_client=use_playwright_client, | ||
use_data_service=use_data_service, | ||
use_async_data_service=use_async_data_service, | ||
) | ||
|
||
filepath = os.path.join(os.getcwd(), filename) | ||
with open(filepath, "w") as f: | ||
f.write(content) | ||
|
||
print(f"File '{filename}' created with boilerplate code.") | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
Oops, something went wrong.