Skip to content

Commit

Permalink
Merge branch 'main' into tox4
Browse files Browse the repository at this point in the history
  • Loading branch information
crwilcox authored Feb 16, 2024
2 parents 0a31782 + 5c82dc5 commit 93fe07e
Show file tree
Hide file tree
Showing 38 changed files with 680 additions and 373 deletions.
5 changes: 0 additions & 5 deletions .flake8

This file was deleted.

16 changes: 7 additions & 9 deletions .github/action_helper.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

import json
import sys


Expand All @@ -11,10 +12,12 @@ def filter_version(version: str) -> str:
version_ = version[5:]
elif version.startswith("pypy"):
version_ = version[4:]
elif version.startswith("~"):
version_ = version[1:]
else:
version_ = version

# remove extra specifier e.g. "3.12-dev" => "3.12"
# remove extra specifier e.g. "3.12-dev" => "3.12", "~3.12.0-0" => "3.12"
version_ = version_.split("-")[0]

version_parts = version_.split(".")
Expand Down Expand Up @@ -56,18 +59,13 @@ def setup_action(input_: str) -> None:
if "3.11" in cpython_versions_filtered:
index = cpython_versions_filtered.index("3.11")
index = versions.index(cpython_versions[index])
cpython_310 = versions.pop(index)
versions.append(cpython_310)
cpython_nox = versions.pop(index)
versions.append(cpython_nox)
else:
# add this to install nox
versions.append("3.11")

if len(versions) > 20:
raise ValueError(f"too many interpreters to install: {len(versions)} > 20")

print(f"interpreter_count={len(versions)}")
for i, version in enumerate(versions):
print(f"interpreter_{i}={version}")
print(f"interpreters={json.dumps(versions)}")


if __name__ == "__main__":
Expand Down
10 changes: 7 additions & 3 deletions .github/workflows/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,20 @@ jobs:
windows-2022,
macos-11,
macos-12,
macos-13,
]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: ./
- run: nox --non-interactive --error-on-missing-interpreter --session github_actions_default_tests
action-all-tests:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-python@v2
with:
python-version: 3.9
- uses: ./
with:
python-versions: "2.7.18, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9, 3.10, 3.11, pypy-2.7, pypy-3.7, pypy-3.8, pypy-3.9-v7.3.9"
python-versions: "3.4, 3.5, 3.6, 3.7, 3.8, 3.9, 3.10, 3.11, 3.12, pypy-2.7, pypy-3.7, pypy-3.8, pypy-3.9-v7.3.9"
- run: nox --non-interactive --error-on-missing-interpreter --session github_actions_all_tests
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ jobs:
strategy:
matrix:
os: [ubuntu-20.04, windows-latest, macos-latest]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
tox-version: ["latest", "<4"]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
Expand Down Expand Up @@ -67,7 +67,7 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python 3.9
uses: actions/setup-python@v4
with:
Expand All @@ -80,7 +80,7 @@ jobs:
docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python 3.9
uses: actions/setup-python@v4
with:
Expand All @@ -95,7 +95,7 @@ jobs:
runs-on: ubuntu-latest
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Build sdist and wheel
run: pipx run build
- name: Publish distribution PyPI
Expand Down
56 changes: 9 additions & 47 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,8 @@ ci:
autofix_commit_msg: "style: pre-commit fixes"

repos:
- repo: https://github.com/psf/black
rev: "23.1.0"
hooks:
- id: black
args:
- "--preview"

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
Expand All @@ -25,46 +18,20 @@ repos:
- id: requirements-txt-fixer
- id: trailing-whitespace

- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort
args: ["-a", "from __future__ import annotations"]

- repo: https://github.com/asottile/pyupgrade
rev: v3.3.1
hooks:
- id: pyupgrade
args: [--py37-plus]

- repo: https://github.com/tox-dev/pyproject-fmt
rev: "0.7.0"
rev: "1.3.0"
hooks:
- id: pyproject-fmt

- repo: https://github.com/hadialqattan/pycln
rev: v2.1.3
hooks:
- id: pycln
args: [--all]
stages: [manual]

- repo: https://github.com/asottile/yesqa
rev: v1.4.0
hooks:
- id: yesqa
additional_dependencies: &flake8-dependencies
- flake8-bugbear

- repo: https://github.com/pycqa/flake8
rev: 6.0.0
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.3
hooks:
- id: flake8
exclude: docs/conf.py
additional_dependencies: *flake8-dependencies
- id: ruff
args: ["--fix", "--show-fixes"]
- id: ruff-format

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.0.0
rev: v1.6.1
hooks:
- id: mypy
files: ^nox/
Expand All @@ -75,20 +42,15 @@ repos:
- importlib_metadata

- repo: https://github.com/codespell-project/codespell
rev: v2.2.2
rev: v2.2.6
hooks:
- id: codespell

- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.10.0
hooks:
- id: python-check-blanket-noqa
- id: python-check-blanket-type-ignore
- id: python-no-log-warn
exclude: ^tests/test_sessions.py$
- id: python-no-eval
exclude: ^nox/manifest.py$
- id: python-use-type-annotations
- id: rst-backticks
- id: rst-directive-colons
- id: rst-inline-touching-normal
33 changes: 33 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,38 @@
# Changelog

## 2023.04.22

We'd like to thank the following folks who contributed to this release:
- @crwilcox
- @dcermak
- @edgarrmondragon
- @FollowTheProcess
- @henryiii
- @reaperhulk
- @scop

New Features:
- Add support for `NOXPYTHON`, `NOXEXTRAPYTHON` and `NOXFORCEPYTHON` by @edgarrmondragon in https://github.com/wntrblm/nox/pull/688
- feat: --json --list-sessions by @henryiii in https://github.com/wntrblm/nox/pull/665

Documentation Improvements:
- style: spelling and grammar fixes by @scop in https://github.com/wntrblm/nox/pull/682
- Add invite link to the discord server to CONTRIBUTING.md by @dcermak in https://github.com/wntrblm/nox/pull/679

Internal Changes:
- chore: update pre-commit hooks by @edgarrmondragon in https://github.com/wntrblm/nox/pull/690
- chore: move to using Ruff by @henryiii in https://github.com/wntrblm/nox/pull/691
- Fix assertion in GHA tests by @FollowTheProcess in https://github.com/wntrblm/nox/pull/670
- ci: some minor fixes by @henryiii in https://github.com/wntrblm/nox/pull/675
- Constrain tox to <4.0.0 and minor fixes by @FollowTheProcess in https://github.com/wntrblm/nox/pull/677
- chore: long term fix for bugbear opinionated checks by @henryiii in https://github.com/wntrblm/nox/pull/678
- chore: switch to hatchling by @henryiii in https://github.com/wntrblm/nox/pull/659
- Don't run python 2.7 virtualenv tests for newer versions of virtualenv by @crwilcox in https://github.com/wntrblm/nox/pull/702
- allow the use of argcomplete 3 by @reaperhulk in https://github.com/wntrblm/nox/pull/700
- fix: enable `list_sessions` for session completion by @scop in https://github.com/wntrblm/nox/pull/699
- chore: remove 3.6 tests, min version is 3.7 by @crwilcox in https://github.com/wntrblm/nox/pull/703


## 2022.11.21

We'd like to thank the following folks who contributed to this release:
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

# Nox

[![Nox](https://img.shields.io/badge/%F0%9F%A6%8A-Nox-D85E00.svg)](https://github.com/wntrblm/nox)
[![License](https://img.shields.io/github/license/wntrblm/nox)](https://github.com/wntrblm/nox)
[![PyPI](https://img.shields.io/pypi/v/nox.svg?logo=python)](https://pypi.python.org/pypi/nox)
[![GitHub](https://img.shields.io/github/v/release/wntrblm/nox?logo=github&sort=semver)](https://github.com/wntrblm/nox)
Expand Down
87 changes: 6 additions & 81 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ inputs:
python-versions:
description: "comma-separated list of python versions to install"
required: false
default: "3.7, 3.8, 3.9, 3.10, 3.11, pypy-3.7, pypy-3.8, pypy-3.9"
default: "3.7, 3.8, 3.9, 3.10, 3.11, 3.12, pypy-3.7, pypy-3.8, pypy-3.9"
branding:
icon: package
color: blue
Expand All @@ -15,7 +15,7 @@ runs:
- uses: actions/setup-python@v4
id: localpython
with:
python-version: "3.7 - 3.11"
python-version: "3.7 - 3.12"
update-environment: false

- name: "Validate input"
Expand All @@ -25,86 +25,11 @@ runs:
shell: bash

- uses: actions/setup-python@v4
id: allpython
with:
python-version: "${{ steps.helper.outputs.interpreter_0 }}"
if: ${{ steps.helper.outputs.interpreter_count > 0 }}
- uses: actions/setup-python@v4
with:
python-version: "${{ steps.helper.outputs.interpreter_1 }}"
if: ${{ steps.helper.outputs.interpreter_count > 1 }}
- uses: actions/setup-python@v4
with:
python-version: "${{ steps.helper.outputs.interpreter_2 }}"
if: ${{ steps.helper.outputs.interpreter_count > 2 }}
- uses: actions/setup-python@v4
with:
python-version: "${{ steps.helper.outputs.interpreter_3 }}"
if: ${{ steps.helper.outputs.interpreter_count > 3 }}
- uses: actions/setup-python@v4
with:
python-version: "${{ steps.helper.outputs.interpreter_4 }}"
if: ${{ steps.helper.outputs.interpreter_count > 4 }}
- uses: actions/setup-python@v4
with:
python-version: "${{ steps.helper.outputs.interpreter_5 }}"
if: ${{ steps.helper.outputs.interpreter_count > 5 }}
- uses: actions/setup-python@v4
with:
python-version: "${{ steps.helper.outputs.interpreter_6 }}"
if: ${{ steps.helper.outputs.interpreter_count > 6 }}
- uses: actions/setup-python@v4
with:
python-version: "${{ steps.helper.outputs.interpreter_7 }}"
if: ${{ steps.helper.outputs.interpreter_count > 7 }}
- uses: actions/setup-python@v4
with:
python-version: "${{ steps.helper.outputs.interpreter_8 }}"
if: ${{ steps.helper.outputs.interpreter_count > 8 }}
- uses: actions/setup-python@v4
with:
python-version: "${{ steps.helper.outputs.interpreter_9 }}"
if: ${{ steps.helper.outputs.interpreter_count > 9 }}
- uses: actions/setup-python@v4
with:
python-version: "${{ steps.helper.outputs.interpreter_10 }}"
if: ${{ steps.helper.outputs.interpreter_count > 10 }}
- uses: actions/setup-python@v4
with:
python-version: "${{ steps.helper.outputs.interpreter_11 }}"
if: ${{ steps.helper.outputs.interpreter_count > 11 }}
- uses: actions/setup-python@v4
with:
python-version: "${{ steps.helper.outputs.interpreter_12 }}"
if: ${{ steps.helper.outputs.interpreter_count > 12 }}
- uses: actions/setup-python@v4
with:
python-version: "${{ steps.helper.outputs.interpreter_13 }}"
if: ${{ steps.helper.outputs.interpreter_count > 13 }}
- uses: actions/setup-python@v4
with:
python-version: "${{ steps.helper.outputs.interpreter_14 }}"
if: ${{ steps.helper.outputs.interpreter_count > 14 }}
- uses: actions/setup-python@v4
with:
python-version: "${{ steps.helper.outputs.interpreter_15 }}"
if: ${{ steps.helper.outputs.interpreter_count > 15 }}
- uses: actions/setup-python@v4
with:
python-version: "${{ steps.helper.outputs.interpreter_16 }}"
if: ${{ steps.helper.outputs.interpreter_count > 16 }}
- uses: actions/setup-python@v4
with:
python-version: "${{ steps.helper.outputs.interpreter_17 }}"
if: ${{ steps.helper.outputs.interpreter_count > 17 }}
- uses: actions/setup-python@v4
with:
python-version: "${{ steps.helper.outputs.interpreter_18 }}"
if: ${{ steps.helper.outputs.interpreter_count > 18 }}
- uses: actions/setup-python@v4
with:
python-version: "${{ steps.helper.outputs.interpreter_19 }}"
if: ${{ steps.helper.outputs.interpreter_count > 19 }}
python-version: "${{ join(fromJSON(steps.helper.outputs.interpreters), '\n') }}"
allow-prereleases: true

- name: "Install nox"
run: pipx install --python "${{ steps.localpython.outputs.python-path }}" '${{ github.action_path }}'
run: pipx install --python "${{ steps.allpython.outputs.python-path }}" '${{ github.action_path }}'
shell: bash
32 changes: 32 additions & 0 deletions docs/cookbook.rst
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,35 @@ Even more so with a sprinkling of Nox:
session.run("git", "push", "--tags", external=True)
Now a simple ``nox -s release -- patch`` will automate your release (provided you have Bump2Version set up to change your files). This is especially powerful if you have a CI/CD pipeline set up!


Generating a matrix with GitHub Actions
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Nox knows what sessions it needs to run. Why not tell GitHub Actions what jobs to run dynamically? Using the ``--json`` flag and a bit of json processing, it's easy:

.. code-block:: yaml
jobs:
generate-jobs:
runs-on: ubuntu-latest
outputs:
session: ${{ steps.set-matrix.outputs.session }}
steps:
- uses: actions/checkout@v3
- uses: wntrblm/nox@main
- id: set-matrix
shell: bash
run: echo session=$(nox --json -l | jq -c '[.[].session]') | tee --append $GITHUB_OUTPUT
checks:
name: Session ${{ matrix.session }}
needs: [generate-jobs]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
session: ${{ fromJson(needs.generate-jobs.outputs.session) }}
steps:
- uses: actions/checkout@v3
- uses: wntrblm/nox@main
- run: nox -s "${{ matrix.session }}"
Loading

0 comments on commit 93fe07e

Please sign in to comment.