Skip to content

Commit

Permalink
fix ci process
Browse files Browse the repository at this point in the history
  • Loading branch information
cofiem committed Nov 17, 2024
1 parent d01b104 commit 4ca9884
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 59 deletions.
9 changes: 1 addition & 8 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,7 @@ jobs:
-r requirements-dev.txt
- name: Generate docs
run: >
pdoc
--docformat google
--edit-url screenshot_ocr=https://github.com/cofiem/screenshot-ocr/blob/main/src/screenshot_ocr/
--search
--show-source
--output-directory docs
./src/screenshot_ocr
run: pipx run tox run -e docs

- name: Upload GitHub Pages artifact
uses: actions/upload-pages-artifact@v3
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/test-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ jobs:
# - windows
python-version: ["3.13", "3.9"]

env:
PYTHON: ${{ matrix.python-version }}

steps:
- name: Download pre-built packages
uses: actions/download-artifact@v4
Expand All @@ -181,4 +184,4 @@ jobs:

- name: Lint docs
if: matrix.python-version == '3.13'
run: pipx run tox run --installpkg dist/*.whl -f lint-docs
run: pipx run tox run --installpkg dist/*.whl -e lint-docs
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,4 @@ dmypy.json
# idea
.idea/

.venv-app/
docs/
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ Release 2024-11-17.
- Add GitHub Actions for checking coverage, Actions security, test coverage, linters.
- Lots of minor code updates to satisfy linters.
- Deploy docs via GitHub Actions.
-

## [v0.3.0](https://github.com/cofiem/screenshot-ocr/releases/tag/v0.3.0)

Expand Down
75 changes: 27 additions & 48 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,17 @@ Install runtime dependencies and development dependencies:
source .venv/bin/activate

# install dependencies
python -m pip install --upgrade pip setuptools wheel
python -m pip install --upgrade -r requirements-dev.txt -r requirements.txt

# check for outdated packages
pip list --outdated
python -m pip install --upgrade pip tox build
```

## Run tests and linters

Run the tests and linters with multiple python versions using tox.

If the pip dependencies have changed, it might be necessary to
(un)comment `recreate = true` in the tox section in `pyproject.toml`.

To run using all available python versions:

```bash
python -X dev -m tox
python -X dev -m tox run -e ALL
```

To run using the active python:
Expand All @@ -44,54 +37,23 @@ To run using the active python:
python -X dev -m tox -e py
```

## Generate docs

Generate the docs:

```bash
pdoc --docformat google \
--edit-url screenshot_ocr=https://github.com/cofiem/screenshot-ocr/blob/main/src/screenshot_ocr/ \
--search --show-source \
--output-directory docs \
./src/screenshot_ocr
```

## Create and upload release
## Test a release locally

Generate the distribution package archives.

```bash
python -X dev -m build
```

Upload archives to Test PyPI first.

```bash
python -X dev -m twine upload --repository testpypi dist/*
```

When uploading:

- for username, use `__token__`
- for password, [create a token](https://test.pypi.org/manage/account/#api-tokens)

Go to the [test project page](https://test.pypi.org/project/screenshot-ocr) and check that it looks ok.

Then create a new virtual environment, install the dependencies, and install from Test PyPI.
Then create a new virtual environment, install the dependencies, and install from the local wheelTest PyPI.

```bash
rm -rf .venv-test
python -m venv .venv-test
source .venv-test/bin/activate
python -m pip install --upgrade pip setuptools wheel

# use the requirements file to install dependencies from the production PyPI,
# as the packages may not be on Test PyPI, or they might be different packages.
python -m pip install --upgrade -r requirements.txt
python -m pip install --upgrade pip

SCREENSHOT_OCR_VERSION='0.3.0'
pip install --index-url https://test.pypi.org/simple/ --no-deps screenshot-ocr==$SCREENSHOT_OCR_VERSION
# or
pip install dist/screenshot_ocr-$SCREENSHOT_OCR_VERSION-py3-none-any.whl
```

Expand Down Expand Up @@ -130,16 +92,33 @@ Traceback (most recent call last):
ValueError: Client secrets must be for a web or installed app.
```

If the package seems to work as expected, upload it to the live PyPI.
## Test a release from Test PyPI

If the package seems to work as expected, push changes to the `main` branch.

Push changes to the `main` branch.
The `pypi-package.yml` GitHub Actions workflow will deploy a release to Test PyPI.

Then follow the same process as testing a release locally, except install from Test PyPI.

```bash
python -X dev -m twine upload dist/*
rm -rf .venv-test
python -m venv .venv-test
source .venv-test/bin/activate

python -m pip install --upgrade pip

# use the requirements file to install dependencies from the production PyPI,
# as the packages may not be on Test PyPI, or they might be different (potentially malicious!) packages.
python -m pip install --upgrade -r requirements.txt

pip install --index-url https://test.pypi.org/simple/ --no-deps screenshot-ocr==$SCREENSHOT_OCR_VERSION
```

When uploading:
## Create a release to PyPI

- for username, use `__token__`
- for password, [create a token](https://pypi.org/manage/account/#api-tokens)
Create a tag on the `main` branch.
The `pypi-package.yml` GitHub Actions workflow will deploy a release to PyPI.

Go to the [live project page](https://pypi.org/project/screenshot-ocr) and check that it looks ok.

Expand Down
11 changes: 11 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ env_list = [
"coverage-report",
"py3{9,13}-lint-style",
"lint-docs",
"docs",
]

[tool.tox.env_run_base]
Expand Down Expand Up @@ -148,6 +149,16 @@ commands = [
["codespell", "--quiet-level", "0", "--summary", "--check-filenames", "--write-changes", "--skip", "*.pyc,*.png", "src", "tests"]
]

[tool.tox.env.docs]
commands = [
["pdoc",
"--docformat", "google",
"--edit-url", "screenshot_ocr=https://github.com/cofiem/screenshot-ocr/blob/main/src/screenshot_ocr/",
"--search", "--show-source", "--output-directory", "docs", "./src/screenshot_ocr"
]
]


[tool.mypy]
strict = true
pretty = true
Expand Down

0 comments on commit 4ca9884

Please sign in to comment.