Skip to content

Commit

Permalink
Initial refactoring for standardizing linting and testing (#15)
Browse files Browse the repository at this point in the history
* Inline dependencies with Py3.8 as 1.0.0
* Add isort, black and basic invoke tasks
* Typo in docstring
* Add package installation by default
* Ignore the lines which are too long
* Initial automatic linting
* Use pytest for running tests
* Fix testing with pytest
* Don't change Python code (cosmestics only)
* Add setup and publishing commands
* Update README to match the Invoke usage
* Explain ignored codes
* Add github actions pipeline

---------

Co-authored-by: Matti Mokko <matti@robocorp.com>
  • Loading branch information
cmin764 and mmokko committed Sep 21, 2023
1 parent 667f480 commit e9bd5ef
Show file tree
Hide file tree
Showing 22 changed files with 988 additions and 552 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: java-access-bridge-wrapper

on:
push:
paths:
- src/**
- .github/workflows/**

jobs:
lint:
# Not using the latest ubuntu until this issue is fixed in setup-python:
# https://github.com/actions/setup-python/issues/401
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.10.12
- name: Upgrade pip
run: python -m pip install --upgrade pip
- name: Install requirements
run: pip install -Ur requirements.txt
- name: Set up cache
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ hashFiles('poetry.lock') }}
- name: Install dependencies
run: invoke update
- name: Run lint
run: invoke lint
38 changes: 26 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@

Python wrapper around the Java Access Bridge / Windows Access Bridge.

# Prerequisites
# Requirements

* 64-bit Windows
* Java >= 8 (https://docs.aws.amazon.com/corretto/latest/corretto-8-ug/downloads-list.html)
* If you are doing development install JDK, otherwise JRE is enough
* Python >= 3.7 (https://www.python.org/downloads/release/python-375/)
* Python >= 3.8 (https://www.python.org/downloads/release/python-375/)

Enable the Java Access Bridge in windows

Expand Down Expand Up @@ -67,30 +67,44 @@ Once the JABWrapper object is initialized, attach to some frame and optionally c

# Development

## Development prerequisites
## Prerequisites

* Install poetry: https://python-poetry.org/docs/
1. Install Invoke, Poetry and the other required dependencies in order to be able to develop and package the library:
`pip install -Ur requirements.txt`.
- If you want to isolate these from the other projects and not rely on the OS
Python, enable a (_pyenv_) virtual environment first by following these
[instructions](https://github.com/robocorp/rpaframework/blob/master/docs/source/contributing/development.md#virtual-environments).
2. Now you're ready to set-up Poetry for the first time with `inv setup`.
- Check with `-h` on how to pass credentials for ensuring that both your production PyPI and CI DevPI are
configured. You'll find these in our **Robocorp** > **Shared** 1Password by searching for keywords like "pypi"
(where we recommend a personal _token_ instead) and "devpi".
3. Run `inv update` so the library gets ready for development.

## Test
## Testing

Run test script against simple Swing application
Run test script against a simple Swing application.

Set environment variable

set RC_JAVA_ACCESS_BRIDGE_DLL="C:\path\to\Java\bin\WindowsAccessBridge-64.dll"

Initialize poetry
Update requirements and install the library in development mode

poetry intall
inv update

Run test with poetry
Run tests

poetry run python tests\test.py
inv test

## Packaging

poetry build
poetry publish
Check linting

inv lint # apply with '-a'

Building and publishing

inv publish # '-c' for DevPI

## TODO:

Expand Down
22 changes: 22 additions & 0 deletions config/flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# List of codes:
# https://pycodestyle.pycqa.org/en/latest/intro.html#error-codes
# https://flake8.pycqa.org/en/latest/user/error-codes.html

[flake8]
ignore =
# W503: line break before binary operator
W503,
# E203: whitespace before ‘,’, ‘;’, or ‘:’
E203,
# E501: line too long (82 > 79 characters)
E501
per-file-ignores =
# F401: module imported but unused
*/__init__.py: F401
exclude =
.git,
.venv

max-complexity = 10
# Subject to change after deciding upon a global Python library standard.
max-line-length = 120
Loading

0 comments on commit e9bd5ef

Please sign in to comment.