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
35 changes: 21 additions & 14 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,22 @@ jobs:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
python-version: '3.8'
cache-dependency-glob: "uv.lock"
enable-cache: true
python-version: "3.9"
version: "0.6.13"
- name: Install pyautoenv
run: uv sync --all-groups
- name: Code Quality
run: |
python -m pip install pre-commit
pre-commit run --all-files
uv run pre-commit run --all-files
- name: Test
run: |
python -m pip install poetry
poetry install --only=test
poetry run pytest --cov --cov-report=term-missing --cov-report=xml
uv run pytest --cov --cov-report=term-missing --cov-report=xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
Expand All @@ -29,12 +32,16 @@ jobs:
name: Test-Windows
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
python-version: '3.8'
cache-dependency-glob: "uv.lock"
enable-cache: true
python-version: "3.9"
version: "0.6.13"
- name: Install pyautoenv
run: uv sync --all-groups
- name: Test
run: |
python -m pip install poetry
poetry install --only=test
poetry run pytest --cov --cov-report=term-missing
uv run pytest --cov --cov-report=term-missing
16 changes: 8 additions & 8 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@ jobs:
name: Release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: '3.8'
python-version: '3.9'
- name: Validate Version
run: |
python -m pip install toml
poetry_version="$(python -c 'import toml; print(toml.load("pyproject.toml")["tool"]["poetry"]["version"])')"
echo "Version from input: ${{ github.event.inputs.version }}"
echo "Version from poetry: ${poetry_version}"
if ! [ "${{ github.event.inputs.version }}" = "${poetry_version}" ]; then
pyproject_version="$(python -c 'import toml; print(toml.load("pyproject.toml")["project"]["version"])')"
echo "Version from input: ${{ github.event.inputs.version }}"
echo "Version from pyproject.toml: ${pyproject_version}"
if ! [ "${{ github.event.inputs.version }}" = "${pyproject_version}" ]; then
exit 1;
fi
script_version="$(python -c 'import pyautoenv; print(pyautoenv.__version__)')"
echo "Version from script: ${script_version}"
if ! [ "${poetry_version}" = "${script_version}" ]; then
echo "Version from script: ${script_version}"
if ! [ "${pyproject_version}" = "${script_version}" ]; then
exit 1;
fi
- name: Release
Expand Down
15 changes: 6 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v5.0.0
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
Expand All @@ -10,21 +10,18 @@ repos:
hooks:
- id: remove-crlf
- id: forbid-tabs
- repo: https://github.com/psf/black
rev: 24.4.2
hooks:
- id: black
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.5.3
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.11.5
hooks:
- id: ruff
- id: ruff-format
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.10.1
rev: v1.15.0
hooks:
- id: mypy
additional_dependencies:
- types-toml
- repo: https://github.com/google/yamlfmt
rev: v0.13.0
rev: v0.16.0
hooks:
- id: yamlfmt
75 changes: 75 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Contributing to pyautoenv

Contributions to improve `pyautoenv` are very welcome.
You can contribute to `pyautoenv` in many ways, including:

- Reporting bugs.
- Requesting/recommending features.
- Opening a pull request to implement features or fix bugs.
- Updating, improving, or reporting errors in documentation.

Please open an issue to allow for discussion before starting work.

## How `pyautoenv` Works

The majority of work is done by the `pyautoenv.py` script.
The script generates activation/deactivation commands
based on environment variables and the working directory.

Activation scripts for each shell call the Python script
and run the generated commands on each change of directory.

## Opening an Issue

When opening an issue please ensure you outline,
in as much detail as possible, the changes you wish to develop.

If reporting a bug, provide as much detail as possible,
ideally giving a minimal reproducible example
and the scenario which led to the problem.
Tracebacks and/or scripts are very useful.

## Setting Up a Development Environment

`pyautoenv` uses [`uv`](https://docs.astral.sh/uv/)
to manage its development environment.
Install `uv`, by following the instructions in their
[docs](https://docs.astral.sh/uv/getting-started/installation/).

To make a virtual environment and install the development dependencies, run:

```console
uv sync --all-groups
```

### Tests

Tests are currently all written in Python using `pytest`.
To run the test suite:

```console
uv run pytest tests/
```

### Code Quality

Python linting and code formatting is provided by `ruff`.
These can be run using:

```console
uv run ruff check .
uv run ruff format .
```

A `pre-commit` config is provided to run checks on each commit.
Install pre-commit with:

```console
uv run pre-commit install
```

You can also run all linting/formatting checks using `pre-commit`:

```console
uv run pre-commit run --all-files
```
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Python environment when you cd into the directory that defines that environment
contains a `poetry.lock` file or a `.venv/` directory).
Environments are automatically deactivated when you leave the directory.

Supports Python versions 3.8 and up.
Supports Python versions 3.9 and up.

## Install

Expand Down Expand Up @@ -62,6 +62,8 @@ source <path to pyauotenv>/pyautoenv.bash
Add this to your `.bashrc` to activate the application permanently.

Note that this script will clobber the `cd` command.
It is highly recommended to use a more modern shell,
like ZSH or Fish, when using `pyautoenv`.

</details>

Expand Down Expand Up @@ -117,3 +119,7 @@ There are some environment variables you can set to configure `pyautoenv`.
The directories, and their children,
will be treated as though no virtual environment exists for them.
This means any active environment will be deactivated when changing to them.

## Contributing

See [CONTRIBUTING.md](./CONTRIBUTING.md).
Loading