Skip to content

Commit

Permalink
QE-11629 publish and launch p2 (#528)
Browse files Browse the repository at this point in the history
- chore - prep for publish - p2
- replace poetry with uv
- set default local python to 3.12
- run pre-commit with uv
- fix isort with ruff
  • Loading branch information
ddl-cedricyoung authored Sep 12, 2024
1 parent fcca71c commit 1e564c8
Show file tree
Hide file tree
Showing 18 changed files with 1,360 additions and 1,740 deletions.
65 changes: 38 additions & 27 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,40 +26,31 @@ workflows:
jobs:
build:
docker:
- image: cimg/python:3.11.7
- image: cimg/python:3.12
resource_class: medium
steps:
- checkout
- inline-orb-uv/setup-uv
- run:
name: install dependencies
command: |
set +eo pipefail
pip install --upgrade pip
pip install pre-commit
pre-commit install-hooks
name: install cucu with Python 3.12
command: uv sync -p 3.12 --dev
- run:
name: install cucu dependencies
command: |
set +eo pipefail
python -m virtualenv --upgrade-embed-wheels
poetry install --no-ansi
name: run pre-commit validations
command: uv run pre-commit run --show-diff-on-failure --from-ref origin/HEAD --to-ref HEAD
- run:
name: build the cucu python package
command: poetry build
command: uv build
- run:
name: install cucu globally
command: pip install dist/cucu-*.tar.gz
- run:
name: run pre-commit validations
command: pre-commit run --show-diff-on-failure --from-ref origin/HEAD --to-ref HEAD

test:
parameters:
browser:
type: string
default: "chrome"
docker:
- image: cimg/python:3.11.7
- image: cimg/python:3.12
- image: selenium/standalone-<<parameters.browser>>:124.0
environment:
SE_NODE_MAX_SESSIONS: 12
Expand All @@ -70,12 +61,10 @@ jobs:
steps:
- setup_remote_docker
- checkout
- inline-orb-uv/setup-uv
- run:
name: install cucu dependencies
command: |
set +eo pipefail
python -m virtualenv --upgrade-embed-wheels
poetry install --no-ansi
command: uv sync
- run:
name: install test dependencies
command: |
Expand All @@ -88,20 +77,20 @@ jobs:
command: curl --retry 60 --retry-delay 5 --retry-connrefused http://localhost:4444
- run:
name: run_functional_tests
command: poetry run cucu run features --workers 6 --selenium-remote-url http://localhost:4444 --generate-report --junit junit_results --browser "<<parameters.browser>>"
command: uv run cucu run features --workers 6 --selenium-remote-url http://localhost:4444 --generate-report --junit junit_results --browser "<<parameters.browser>>"
environment:
COVERAGE_PROCESS_START: pyproject.toml # set to config file
- run:
name: run unit tests
command: poetry run coverage run -m pytest --junit-xml=results/unit-tests.xml
command: uv run coverage run -m pytest --junit-xml=results/unit-tests.xml
- run:
name: code_coverage_check
command: |
set +eo pipefail
poetry run coverage combine .coverage.*
poetry run coverage html
poetry run coverage report
poetry run coverage xml
uv run coverage combine .coverage.*
uv run coverage html
uv run coverage report
uv run coverage xml
mv coverage.xml coverage-<<parameters.browser>>.xml
- persist_to_workspace:
root: .
Expand All @@ -124,3 +113,25 @@ jobs:
path: report.tgz
- store_test_results:
path: junit_results

orbs:
inline-orb-uv:
commands:
setup-uv:
steps:
- restore_cache:
keys:
- v1-uv-cache-{{ checksum "uv.lock" }}
- run:
name: Install uv
command: |
curl -LsSf https://astral.sh/uv/install.sh | sh
echo 'source $HOME/.cargo/env' >> $BASH_ENV
source $BASH_ENV
- save_cache:
paths:
- $HOME/.cargo/env
key: v1-uv-cache-{{ checksum "uv.lock" }}
- run:
name: Verify uv installation
command: uv --version
39 changes: 21 additions & 18 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,32 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v2
with:
python-version: '3.11'
- name: Install depedencies
enable-cache: true
- name: Install cucu with Python 3.12
run: |
pip install poetry
poetry install --no-ansi
- uses: pre-commit/action@v3.0.1
uv sync -p 3.12 --dev
- name: Run pre-commit
run: |
uv run pre-commit run
unit:
needs: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v2
with:
python-version: '3.11'
- name: Install depedencies
enable-cache: true
- name: Install cucu with Python 3.12
run: |
pip install poetry
poetry install --no-ansi
uv sync -p 3.12 --dev
- name: unit tests
run: |
poetry run coverage run -m pytest --junit-xml=output/unit-tests.xml
uv run coverage run -m pytest --junit-xml=output/unit-tests.xml
- name: package results
if: always()
run: |
Expand Down Expand Up @@ -80,19 +82,20 @@ jobs:

steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v2
with:
python-version: '3.11'
- name: Install depedencies
enable-cache: true
- name: Install Python 3.12
run: |
pip install poetry
poetry install --no-ansi
uv python install 3.12
uv sync
- name: wait_for_selenium
# retry connection every 2s x 60 which is a total of 2 minutes
run: curl --retry 60 --retry-delay 2 --retry-connrefused http://localhost:4444
- name: UI tests
run: |
poetry run cucu run features --browser "${{ matrix.browser }}" --workers 1 --generate-report --report output/report --junit output/junit --selenium-remote-url http://localhost:4444
uv run cucu run features --browser "${{ matrix.browser }}" --workers 1 --generate-report --report output/report --junit output/junit --selenium-remote-url http://localhost:4444
env:
COVERAGE_PROCESS_START: pyproject.toml
SE_NODE_MAX_SESSIONS: 12
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/publish-production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ jobs:
with:
ref: main
fetch-depth: 0
- uses: actions/setup-python@v5
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v2
with:
python-version: '3.11'
- name: Install depedencies
enable-cache: true
- name: Install cucu with Python 3.12
run: |
pip install poetry
poetry install --no-ansi
uv sync -p 3.12
- name: build package
run: |
poetry build
uv build
- name: publish to test.pypi.org
uses: pypa/gh-action-pypi-publish@release/v1
10 changes: 3 additions & 7 deletions .github/workflows/publish-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,12 @@ jobs:
with:
ref: main
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install depedencies
- name: Install cucu with Python 3.12
run: |
pip install poetry
poetry install --no-ansi
uv sync -p 3.12
- name: build package
run: |
poetry build
uv build
- name: publish to test.pypi.org
uses: pypa/gh-action-pypi-publish@release/v1
with:
Expand Down
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project closely adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 0.207.0
- chore - prep for publish - p2
- replace poetry with uv
- set default local python to 3.12
- run pre-commit with uv
- fix isort with ruff

## 0.206.0
- chore - prep for publish
- replace black with ruff
Expand Down
88 changes: 17 additions & 71 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,86 +87,45 @@ There are a few reasons for writing the actual tests in `gherkin` including:
7. [ipdb]() - debugging convience
8. [jellyfish]() / [humanize]() / [tabulate]() - easier human readablilty

TODO remove:
pebble = "^5.0.3"

# Dev Setup
The short list
1. install `poetry`
2. install a compatible python - see pyproject.toml
3. start docker - used for `cucu run`*
4. shell
1. install [uv](https://github.com/astral-sh/uv)
2. start docker - used for `cucu run`*
3. shell
```bash
# install poetry plugin
poetry self add poetry-dotenv-plugin

# creates your poetry env
make install
# creates virtual env, downloading python if needed
make setup

# just making sure all the code checks work
make check
# lint the code
make lint

# from top-level of cucu directory
pre-commit install
```

### Fancier Dev Setup
Disclaimer: Tested only on MacOS, and needed for VSCode debugging

1. use `pipx` to install `poetry` in a separate python virtual environment
```bash
brew install pipx
pipx install poetry
# inject the extension into the poetry pipx virtualenv
pipx inject poetry poetry-dotenv-plugin
uv run pre-commit install
```
_now the poetry app and dependencies won't be in your main python install_
2. setup poetry's directory to use the project's directory (THIS IS A GLOBAL CHANGE)
1. exit poetry shell if you're in it
2. delete all existing poetry virtualenv directories
```bash
rm -rf ~/.cache/pypoetry
```
3. change poetry's global config
```bash
poetry config virtualenvs.in-project true
```
4. re-install cucu's poetry
```bash
poetry install
# you should see the newly created virtualenv directory under the cucu top-level directory
ls .venv/
```
_required for VSCode debugging below_

## Running cucu
1. drop into a poetry shell environment
```bash
poetry shell
```
2. once in the poetry shell use the `cucu` command like normal
1. `uv run` cucu commands
```bash
cucu
uv run cucu
```
3. you can run a test and see the generated **results/** directory
```bash
cucu run features/browser/links.feature
uv run cucu run features/browser/links.feature
ls results
```
4. and even generate an html report
```bash
cucu report
ls report/index.html
uv run cucu report
ls report
```

## Debugging cucu
Here's some options:
1. drop into an ipdb debugger on failure using the cucu run `-i` argument
2. add a `breakpoint()` call to python code to drop into an ipdb debugger
3. configure VSCode to launch and connect in debug mode
1. setup poetry's directory to use the project's directory - see [Fancier Dev Setup](#fancier-dev-setup)
2. in VSCode **`Python: Select Interpreter`** as `./.venv/bin/python`
3. add a launch`.vscode/launch.json` and **change the `args`**
1. in VSCode **`Python: Select Interpreter`** as `./.venv/bin/python`
2. add a launch`.vscode/launch.json` and **change the `args`**
```json
{
"version": "0.2.0",
Expand All @@ -182,8 +141,8 @@ Here's some options:
]
}
```
4. add a VSCode breakpoint to python code
5. run the VSCode debugger as normal
3. add a VSCode breakpoint to python code
4. run the VSCode debugger as normal
4. if are developing cucu and want to test it as a framework in another project then install it in `--editable` mode
```bash
# change to your project
Expand All @@ -199,19 +158,6 @@ Easy as this (but runs a while)
make test
```
TODO - Coverage
```bash
make coverage
```
## Preventing secrets
Only you can prevent 🌳🔥 secrets from being commited to the repo!
We use Yelp's `detect-secrets` in `cucu` development to help prevent secrets from being commited to the repo.
This requires developers to be mindful by using `make check` before committing.
If you encounter false positives, run `make update-secrets`.
This should solve the problem by updating the ignore list.


# Backstory
Cucu was originally developed primarly by Rodney Gomes, leveraging his
years of experience in test automation across multiple programming languages.
Expand Down
Loading

0 comments on commit 1e564c8

Please sign in to comment.