Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 9 additions & 12 deletions .github/workflows/deploy-dev-docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,25 @@ jobs:
git config --global user.email github-actions@github.com

- name: Checkout main repo
uses: actions/checkout@main
uses: actions/checkout@v4
with:
path: 'main-repo'

- name: Install uv
uses: astral-sh/setup-uv@v6

- name: Set up Python 3.9
uses: actions/setup-python@main
uses: actions/setup-python@v5
with:
python-version: 3.9
cache: 'pip'

- uses: actions/cache@v4
with:
path: ${{ env.pythonLocation }}
key: ${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}

- name: Install dependencies
run: |
cd main-repo
python -m pip install --upgrade pip
pip install --editable ".[dev]"
uv sync

- name: Checkout dev docs repo
uses: actions/checkout@main
uses: actions/checkout@v4
with:
repository: a-rich/DJ-Tools-dev-docs
path: 'dev-docs-repo'
Expand All @@ -50,7 +46,8 @@ jobs:
cd dev-docs-repo/
rm -rf docs && rm -rf src
cp -r ../main-repo/docs . && cp -r ../main-repo/src .
mkdocs gh-deploy --force --config-file docs/mkdocs.yml
cd ../main-repo
uv run mkdocs gh-deploy --force --config-file ../dev-docs-repo/docs/mkdocs.yml

- name: Commit changes
run: |
Expand Down
20 changes: 7 additions & 13 deletions .github/workflows/deploy-prod-docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,18 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@main
uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v6

- name: Set up Python 3.9
uses: actions/setup-python@main
uses: actions/setup-python@v5
with:
python-version: 3.9
cache: 'pip'

- uses: actions/cache@v4
with:
path: ${{ env.pythonLocation }}
key: ${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install --editable ".[dev]"
run: uv sync

- name: Deploy docs
run: |
mkdocs gh-deploy --force --config-file docs/mkdocs.yml
run: uv run mkdocs gh-deploy --force --config-file docs/mkdocs.yml
19 changes: 7 additions & 12 deletions .github/workflows/format.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,25 @@ jobs:
git config --global user.email github-actions@github.com

- name: Checkout repo
uses: actions/checkout@main
uses: actions/checkout@v4
with:
token: ${{ secrets.DJTOOLS_WORKFLOWS }}

- name: Install uv
uses: astral-sh/setup-uv@v6

- name: Set up Python 3.9
uses: actions/setup-python@main
uses: actions/setup-python@v5
with:
python-version: 3.9
cache: 'pip'

- uses: actions/cache@v4
with:
path: ${{ env.pythonLocation }}
key: ${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install --editable ".[dev]"
run: uv sync

- name: Format code
id: format_code
run: |
black .
uv run black .
echo "DIFF=$(git diff --name-only)" >> $GITHUB_OUTPUT

- name: Commit changes
Expand Down
25 changes: 10 additions & 15 deletions .github/workflows/release-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,24 @@ jobs:
git config --global user.email github-actions@github.com

- name: Checkout repo
uses: actions/checkout@main
uses: actions/checkout@v4
with:
token: ${{ secrets.DJTOOLS_WORKFLOWS }}

- name: Install uv
uses: astral-sh/setup-uv@v6

- name: Set up Python 3.9
uses: actions/setup-python@main
uses: actions/setup-python@v5
with:
python-version: 3.9
cache: 'pip'

- uses: actions/cache@v4
with:
path: ${{ env.pythonLocation }}
key: ${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install --editable ".[dev]"
run: uv sync

- name: Bump version
run: |
NEXT_VERSION=`python -c "import semver; from djtools.version import get_version; ver = semver.Version.parse(get_version()).bump_prerelease(); print(ver)"`
NEXT_VERSION=`uv run python -c "import semver; from djtools.version import get_version; ver = semver.Version.parse(get_version()).bump_prerelease(); print(ver)"`
SEMVER_REGEX="version = \"([0-9]+)\.([0-9]+)\.([0-9]+)([-]{0,1})(((b{0,1})|(rc{0,1}))[\.]{0,1}[0-9]+){0,1}\""
sed -i -E "s/$SEMVER_REGEX/version = \"$NEXT_VERSION\"/g" pyproject.toml

Expand All @@ -47,11 +42,11 @@ jobs:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.DJTOOLS_PYPI_TOKEN }}
run: |
python -m build
twine upload dist/*
uv build
uv run twine upload dist/*

- name: Commit changes
run: |
git add pyproject.toml
git commit -m "Release: $GITHUB_SHA"
git push --force
git push --force
23 changes: 9 additions & 14 deletions .github/workflows/release-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,24 @@ jobs:
git config --global user.email github-actions@github.com

- name: Checkout repo
uses: actions/checkout@main
uses: actions/checkout@v4
with:
token: ${{ secrets.DJTOOLS_WORKFLOWS }}

- name: Install uv
uses: astral-sh/setup-uv@v6

- name: Set up Python 3.9
uses: actions/setup-python@main
uses: actions/setup-python@v5
with:
python-version: 3.9
cache: 'pip'

- uses: actions/cache@v4
with:
path: ${{ env.pythonLocation }}
key: ${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install --editable ".[dev]"
run: uv sync

- name: Bump version
run: |
NEXT_VERSION=`python -c "import semver; from djtools.version import get_version; ver = semver.Version.parse(get_version()).finalize_version(); print(ver)"`
NEXT_VERSION=`uv run python -c "import semver; from djtools.version import get_version; ver = semver.Version.parse(get_version()).finalize_version(); print(ver)"`
SEMVER_REGEX="version = \"([0-9]+)\.([0-9]+)\.([0-9]+)([-]{0,1})(((b{0,1})|(rc{0,1}))[\.]{0,1}[0-9]+){0,1}\""
sed -i -E "s/$SEMVER_REGEX/version = \"$NEXT_VERSION\"/g" pyproject.toml

Expand All @@ -47,8 +42,8 @@ jobs:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.DJTOOLS_PYPI_TOKEN }}
run: |
python -m build
twine upload dist/*
uv build
uv run twine upload dist/*

- name: Commit changes
run: |
Expand Down
51 changes: 23 additions & 28 deletions .github/workflows/test-lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,33 +20,28 @@ jobs:

steps:
- name: Checkout repo
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v6

- name: Set up Python
uses: actions/setup-python@main
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'

- uses: actions/cache@v4
with:
path: ${{ env.pythonLocation }}
key: ${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install --editable ".[dev]"
run: uv sync

- name: Run pylint on Ubuntu
if: matrix.os == 'ubuntu-latest'
run: |
PYLINT=`pylint --verbose $(git ls-files '*.py')`
PASS=`echo $PYLINT | grep "Your code has been rated at ${{ env.PYLINT_PASS_SCORE}}/10"`
PYLINT=$(uv run pylint --verbose $(git ls-files '*.py') 2>&1) || true
echo "$PYLINT"
PASS=$(echo "$PYLINT" | grep "Your code has been rated at ${{ env.PYLINT_PASS_SCORE}}/10") || true

if [ -z $PASS ]; then
echo $PYLINT
exit 1;
if [ -z "$PASS" ]; then
exit 1
fi

- name: Run pylint on Windows
Expand All @@ -55,28 +50,28 @@ jobs:
# File "C:\hostedtoolcache\windows\Python\3.12.1\x64\Lib\site-packages\pylint\lint\pylinter.py", line 888, in get_ast
if: matrix.os == 'windows-latest' && matrix.python-version != '3.12'
run: |
$PYLINT=pylint --verbose (Get-ChildItem -Recurse -Filter *.py | ForEach-Object { $_.FullName })
$PASS=$PYLINT -match "Your code has been rated at $env:PYLINT_PASS_SCORE/10"
$PYLINT = & uv run pylint --verbose --recursive=y src tests scripts 2>&1 | Out-String
Write-Output $PYLINT
if ($PYLINT -notmatch "Your code has been rated at $env:PYLINT_PASS_SCORE/10") {
exit 1
}

- name: Run pytest with coverage on Ubuntu
if: matrix.os == 'ubuntu-latest'
run: |
PYTEST=`pytest --cov --cov-report term-missing --show-capture=no`
PASS=`echo $PYTEST | grep -E "TOTAL\s+[0-9]+\s+0+\s+${{ env.COVERAGE_TOTAL }}%"`
PYTEST=$(uv run pytest --cov --cov-report term-missing --show-capture=no 2>&1) || true
echo "$PYTEST"
PASS=$(echo "$PYTEST" | grep -E "TOTAL\s+[0-9]+\s+0+\s+${{ env.COVERAGE_TOTAL }}%") || true

if [ -z $PASS ]; then
echo $PYTEST
if [ -z "$PASS" ]; then
exit 1
fi

- name: Run pytest with coverage on Windows
if: matrix.os == 'windows-latest'
run: |
$PYTEST=pytest --cov --cov-report term-missing --show-capture=no
$PASS=$PYTEST -match "TOTAL\s+\d+\s+0+\s+$env:COVERAGE_TOTAL%"

if (-not $PASS) {
Write-Output $PYTEST
exit 1
$PYTEST = & uv run pytest --cov --cov-report term-missing --show-capture=no 2>&1 | Out-String
Write-Output $PYTEST
if ($PYTEST -notmatch "TOTAL\s+\d+\s+0+\s+$env:COVERAGE_TOTAL%") {
exit 1
}
13 changes: 5 additions & 8 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ On `push` events to `main`, for the same file change patterns, the [deploy-prod-
## Local testing (run from DJ-Tools repo)
### Setup dev environment:
```
pyenv virtualenv $(pyenv local) djtools-dev && \
pyenv activate djtools-dev && \
pip install -e ".[dev]" && \
pre-commit install
uv sync && uv run pre-commit install
```

### pre-commit hooks:
Expand All @@ -37,13 +34,13 @@ You can run these same checks at any time with the following commands:

#### Test with pytest
```
pytest --cov --cov-report term-missing
uv run pytest --cov --cov-report term-missing
```
#### Lint with pylint
```
pylint $(git ls-files '*.py')
uv run pylint $(git ls-files '*.py')
```
#### Format code with black
```
black .
```
uv run black .
```
10 changes: 5 additions & 5 deletions docs/tutorials/getting_started/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ The DJ Tools library requires a minimum version of Python 3.9. As always, when w
- Windows installation: [Windows releases](https://www.python.org/downloads/windows/)

## DJ Tools
1. Run `pip install "djtools[accelerated]"` to install the DJ Tools library
- To install DJ Tools without the accelerated computation for Levenshtein distance (might be difficult to install the binaries for non-technical users), run `pip install djtools`
- You can install the pre-release version with `pip install djtools --pre`
- If you want to restrict the version being installed to not include, say, the next minor version's beta release then you can do so like `pip install djtools<2.5.0 --pre`
- Note that installing with the `--pre` flag will also install pre-release versions for all dependencies which may cause breakage, in that case you can target specific pre-release versions like this `pip install djtools==2.4.1-rc9`
1. Run `uv pip install "djtools[accelerated]"` to install the DJ Tools library
- To install DJ Tools without the accelerated computation for Levenshtein distance (might be difficult to install the binaries for non-technical users), run `uv pip install djtools`
- You can install the pre-release version with `uv pip install djtools --pre`
- If you want to restrict the version being installed to not include, say, the next minor version's beta release then you can do so like `uv pip install "djtools<2.5.0" --pre`
- Note that installing with the `--pre` flag will also install pre-release versions for all dependencies which may cause breakage, in that case you can target specific pre-release versions like this `uv pip install djtools==2.4.1-rc9`
1. Confirm your installation works by running `djtools`
1. [Optional] link the `configs` directory of the installation to a user-friendly location for easy editing of your config files: `djtools --link-configs path/to/new/location/`
1. Edit your configuration files to support your usage needs ([see here for more details](configuration.md))
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorials/getting_started/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ For example, whenever I install the newest version of DJ Tools, I remove my link

install djtools:

`pip install djtools`
`uv pip install djtools`

run the following command to link the installed configs directory:

Expand Down
Loading