Skip to content

Commit

Permalink
Add .envrc and improve tooling
Browse files Browse the repository at this point in the history
The `.envrc` is for `direnv`, which will automatically create and activate the venv when opening the workspace directory.

Other than that, this also adds a `.python-version` and updates various Python versions to 3.12.

Also the redundant CI `build` job is being removed.
  • Loading branch information
Swatinem committed Aug 30, 2024
1 parent 5f3091a commit 6d56cc4
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 41 deletions.
19 changes: 19 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash
# shellcheck disable=SC1091

if [ ! -d .venv ]; then
echo "warning: creating virtualenv for the first time"
if which pyenv > /dev/null; then
eval "$(pyenv init -)"
pyenv install -s
else
echo "warning: pyenv not installed, using python3 and hoping for the best"
fi

python3 -m venv .venv
source .venv/bin/activate
pip install -r python/requirements.dev.txt
else
source .venv/bin/activate
unset PS1
fi
30 changes: 0 additions & 30 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ on:
- main
pull_request:


concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
Expand All @@ -33,38 +32,13 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/setup-python@v3
with:
python-version: '3.12'
- name: Set up venv
run: make ci.setup_venv
- name: Build and run lint
run: |
maturin develop
make lint.python
build:
name: Build
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@nightly
with:
toolchain: nightly
- name: Run build
run: |
cargo build
- uses: actions/setup-python@v3
with:
python-version: '3.12'
- name: Install Python requirements
run: pip install -r python/requirements.dev.txt
- name: Build Python bindings
run: maturin build

test:
name: Test
runs-on: ubuntu-latest
Expand All @@ -82,8 +56,6 @@ jobs:
cargo test
- uses: actions/setup-python@v3
with:
python-version: '3.12'
- name: Set up venv
run: make ci.setup_venv
- name: Run Python tests
Expand Down Expand Up @@ -116,8 +88,6 @@ jobs:
cargo llvm-cov --lcov --output-path core.lcov -- -Z unstable-options --format json --report-time | cargo2junit > core-test-results.xml
- uses: actions/setup-python@v3
with:
python-version: '3.12'
- name: Set up venv
run: make ci.setup_venv
- name: Run Python tests
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
5 changes: 1 addition & 4 deletions bindings/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,4 @@ crate-type = ["cdylib"]
[dependencies]
codecov-rs = { path = "../core" }

pyo3 = { version = "0.22.2", features = [
"extension-module",
"abi3-py311",
] }
pyo3 = { version = "0.22.2", features = ["extension-module", "abi3-py312"] }
12 changes: 5 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ build-backend = "maturin"

[project]
name = "codecov_rs"
authors = [
{name = "Codecov", email = "support@codecov.io"},
]
authors = [{ name = "Codecov", email = "support@codecov.io" }]
readme = "README.md"
requires-python = ">=3.11"
requires-python = ">=3.12"
license = { file = "LICENSE.md" }
classifiers = [
"Programming Language :: Rust",
Expand All @@ -25,7 +23,7 @@ python-source = "python"


[tool.mypy]
python_version = "3.11"
python_version = "3.12"
plugins = ["pydantic.mypy"]

# Don't bother scanning Rust directories
Expand All @@ -39,8 +37,8 @@ include = ["pyproject.toml", "python/**/*.py", "python/**/*.pyi"]
line-length = 88
indent-width = 4

# Assume Python 3.11
target-version = "py311"
# Assume Python 3.12
target-version = "py312"

[tool.ruff.lint]
# Currently only enabled for F (Pyflakes), I (isort), E,W (pycodestyle:Error/Warning), PLC/PLE (Pylint:Convention/Error)
Expand Down

0 comments on commit 6d56cc4

Please sign in to comment.