Skip to content

Commit

Permalink
Merge branch 'master' into python3.12
Browse files Browse the repository at this point in the history
  • Loading branch information
svlandeg committed May 15, 2024
2 parents 929615b + a79d4c0 commit f4347ae
Show file tree
Hide file tree
Showing 23 changed files with 80 additions and 32 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ jobs:
if: ( github.event_name != 'pull_request' || github.secret_source == 'Actions' )
run: python -m mkdocs build --config-file mkdocs.insiders.yml

- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: docs-site
path: ./site/**
Expand Down
16 changes: 7 additions & 9 deletions .github/workflows/deploy-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,16 @@ jobs:
run: |
rm -rf ./site
mkdir ./site
- name: Download Artifact Docs
id: download
uses: dawidd6/action-download-artifact@v3.1.4
- uses: actions/download-artifact@v4
with:
if_no_artifact_found: ignore
github_token: ${{ secrets.GITHUB_TOKEN }}
workflow: build-docs.yml
run_id: ${{ github.event.workflow_run.id }}
name: docs-site
path: ./site/
pattern: docs-site
merge-multiple: true
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ github.event.workflow_run.id }}
- name: Deploy to Cloudflare Pages
if: steps.download.outputs.found_artifact == 'true'
# hashFiles returns an empty string if there are no files
if: hashFiles('./site/*')
id: deploy
uses: cloudflare/pages-action@v1
with:
Expand Down
10 changes: 6 additions & 4 deletions .github/workflows/smokeshow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@ jobs:

- run: pip install smokeshow

- uses: dawidd6/action-download-artifact@v3.1.4
- uses: actions/download-artifact@v4
with:
workflow: test.yml
commit: ${{ github.event.workflow_run.head_sha }}
name: coverage-html
path: htmlcov
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ github.event.workflow_run.id }}

- run: smokeshow upload coverage-html
- run: smokeshow upload htmlcov
env:
SMOKESHOW_GITHUB_STATUS_DESCRIPTION: Coverage {coverage-percentage}
SMOKESHOW_GITHUB_COVERAGE_THRESHOLD: 100
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/test-redistribute.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ jobs:
run: |
cd dist/typer*/
pip install -r requirements-tests.txt
env:
TIANGOLO_BUILD_PACKAGE: ${{ matrix.package }}
- name: Run source distribution tests
if: ${{ matrix.package != 'typer-cli' }}
run: |
Expand Down
28 changes: 21 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,23 @@ on:

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
os: [ ubuntu-latest, windows-latest, macos-latest ]
python-version: [ "3.12" ]
include:
- os: ubuntu-latest
python-version: "3.7"
- os: macos-latest
python-version: "3.8"
- os: windows-latest
python-version: "3.9"
- os: ubuntu-latest
python-version: "3.10"
- os: macos-latest
python-version: "3.11"
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
- name: Dump GitHub context
env:
Expand All @@ -33,6 +45,7 @@ jobs:
# cache: "pip"
# cache-dependency-path: pyproject.toml
- uses: actions/cache@v3
if: ${{ runner.os != 'macOS' }}
id: cache
with:
path: ${{ env.pythonLocation }}
Expand All @@ -50,9 +63,9 @@ jobs:
COVERAGE_FILE: coverage/.coverage.${{ runner.os }}-py${{ matrix.python-version }}
CONTEXT: ${{ runner.os }}-py${{ matrix.python-version }}
- name: Store coverage files
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: coverage
name: coverage-${{ runner.os }}-${{ matrix.python-version }}
path: coverage

coverage-combine:
Expand All @@ -71,17 +84,18 @@ jobs:
# cache: "pip"
# cache-dependency-path: pyproject.toml
- name: Get coverage files
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: coverage
pattern: coverage-*
path: coverage
merge-multiple: true
- run: pip install coverage[toml]
- run: ls -la coverage
- run: coverage combine coverage
- run: coverage report
- run: coverage html --show-contexts --title "Coverage for ${{ github.sha }}"
- name: Store coverage HTML
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: coverage-html
path: htmlcov
Expand Down
6 changes: 6 additions & 0 deletions docs/release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

### Internal

* ✅ Add CI configs to run tests on Windows and MacOS. PR [#824](https://github.com/tiangolo/typer/pull/824) by [@svlandeg](https://github.com/svlandeg).
* 👷 Update GitHub Actions to upload and download artifacts. PR [#829](https://github.com/tiangolo/typer/pull/829) by [@tiangolo](https://github.com/tiangolo).
* 👷 Tweak CI for test-redistribute, add needed env vars for slim. PR [#827](https://github.com/tiangolo/typer/pull/827) by [@tiangolo](https://github.com/tiangolo).
* ✅ Generalize test suite to run on Windows. PR [#810](https://github.com/tiangolo/typer/pull/810) by [@svlandeg](https://github.com/svlandeg).
* ✅ Add `__init__.py` files to fix test suite. PR [#809](https://github.com/tiangolo/typer/pull/809) by [@svlandeg](https://github.com/svlandeg).
* 🔧 Update MkDocs Material, enable plugins. PR [#813](https://github.com/tiangolo/typer/pull/813) by [@tiangolo](https://github.com/tiangolo).
* 🔧 Tweak development scripts and configs after migration to PDM, Ruff, etc.. PR [#797](https://github.com/tiangolo/typer/pull/797) by [@tiangolo](https://github.com/tiangolo).

## 0.12.3
Expand Down
Empty file.
Empty file.
6 changes: 3 additions & 3 deletions mkdocs.insiders.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
INHERIT: mkdocs.yml
# plugins:
# TODO: Re-enable once this is fixed: https://github.com/squidfunk/mkdocs-material/issues/6983
# - social
plugins:
social:
typeset:
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ omit = [
"typer/_typing.py"
]
context = '${CONTEXT}'
relative_files = true

[tool.coverage.report]
exclude_lines = [
Expand Down
3 changes: 3 additions & 0 deletions requirements-tests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ pytest-xdist >=1.32.0,<4.0.0
pytest-sugar >=0.9.4,<0.10.0
mypy ==1.4.1
ruff ==0.2.0
# Needed explicitly by typer-slim
rich >=10.11.0
shellingham >=1.3.0
10 changes: 7 additions & 3 deletions tests/test_completion/test_completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@

from docs_src.commands.index import tutorial001 as mod

from ..utils import needs_linux


@needs_linux
def test_show_completion():
result = subprocess.run(
[
"bash",
"-c",
f"{sys.executable} -m coverage run {mod.__file__} --show-completion",
f"'{sys.executable}' -m coverage run '{mod.__file__}' --show-completion",
],
capture_output=True,
encoding="utf-8",
Expand All @@ -20,6 +23,7 @@ def test_show_completion():
assert "_TUTORIAL001.PY_COMPLETE=complete_bash" in result.stdout


@needs_linux
def test_install_completion():
bash_completion_path: Path = Path.home() / ".bashrc"
text = ""
Expand All @@ -29,7 +33,7 @@ def test_install_completion():
[
"bash",
"-c",
f"{sys.executable} -m coverage run {mod.__file__} --install-completion",
f"'{sys.executable}' -m coverage run '{mod.__file__}' --install-completion",
],
capture_output=True,
encoding="utf-8",
Expand All @@ -38,7 +42,7 @@ def test_install_completion():
new_text = bash_completion_path.read_text()
bash_completion_path.write_text(text)
assert "source" in new_text
assert ".bash_completions/tutorial001.py.sh" in new_text
assert str(Path(".bash_completions/tutorial001.py.sh")) in new_text
assert "completion installed in" in result.stdout
assert "Completion will take effect once you restart the terminal" in result.stdout

Expand Down
6 changes: 3 additions & 3 deletions tests/test_completion/test_completion_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ def test_completion_install_bash():
)
new_text = bash_completion_path.read_text()
bash_completion_path.write_text(text)
install_source = ".bash_completions/tutorial001.py.sh"
assert install_source not in text
assert install_source in new_text
install_source = Path(".bash_completions/tutorial001.py.sh")
assert str(install_source) not in text
assert str(install_source) in new_text
assert "completion installed in" in result.stdout
assert "Completion will take effect once you restart the terminal" in result.stdout
install_source_path = Path.home() / install_source
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
import subprocess
import sys

Expand Down Expand Up @@ -55,5 +56,6 @@ def test_script():
[sys.executable, "-m", "coverage", "run", mod.__file__, "--help"],
capture_output=True,
encoding="utf-8",
env={**os.environ, "PYTHONIOENCODING": "utf-8"},
)
assert "Usage" in result.stdout
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
import subprocess
import sys

Expand Down Expand Up @@ -55,5 +56,6 @@ def test_script():
[sys.executable, "-m", "coverage", "run", mod.__file__, "--help"],
capture_output=True,
encoding="utf-8",
env={**os.environ, "PYTHONIOENCODING": "utf-8"},
)
assert "Usage" in result.stdout
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
import subprocess
import sys

Expand Down Expand Up @@ -56,5 +57,6 @@ def test_script():
[sys.executable, "-m", "coverage", "run", mod.__file__, "--help"],
capture_output=True,
encoding="utf-8",
env={**os.environ, "PYTHONIOENCODING": "utf-8"},
)
assert "Usage" in result.stdout
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
import subprocess
import sys

Expand Down Expand Up @@ -56,5 +57,6 @@ def test_script():
[sys.executable, "-m", "coverage", "run", mod.__file__, "--help"],
capture_output=True,
encoding="utf-8",
env={**os.environ, "PYTHONIOENCODING": "utf-8"},
)
assert "Usage" in result.stdout
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
import subprocess
import sys

Expand Down Expand Up @@ -47,5 +48,6 @@ def test_script():
[sys.executable, "-m", "coverage", "run", mod.__file__, "--help"],
capture_output=True,
encoding="utf-8",
env={**os.environ, "PYTHONIOENCODING": "utf-8"},
)
assert "Usage" in result.stdout
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
import subprocess
import sys

Expand Down Expand Up @@ -51,5 +52,6 @@ def test_script():
[sys.executable, "-m", "coverage", "run", mod.__file__, "--help"],
capture_output=True,
encoding="utf-8",
env={**os.environ, "PYTHONIOENCODING": "utf-8"},
)
assert "Usage" in result.stdout
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
import subprocess
import sys

Expand Down Expand Up @@ -51,5 +52,6 @@ def test_script():
[sys.executable, "-m", "coverage", "run", mod.__file__, "--help"],
capture_output=True,
encoding="utf-8",
env={**os.environ, "PYTHONIOENCODING": "utf-8"},
)
assert "Usage" in result.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def test_main(tmpdir):
if binary_file.exists(): # pragma: no cover
binary_file.unlink()
result = runner.invoke(app, ["--file", f"{binary_file}"])
text = binary_file.read_text()
text = binary_file.read_text(encoding="utf-8")
binary_file.unlink()
assert result.exit_code == 0
assert "Binary file written" in result.output
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def test_main(tmpdir):
if binary_file.exists(): # pragma: no cover
binary_file.unlink()
result = runner.invoke(app, ["--file", f"{binary_file}"])
text = binary_file.read_text()
text = binary_file.read_text(encoding="utf-8")
binary_file.unlink()
assert result.exit_code == 0
assert "Binary file written" in result.output
Expand Down
4 changes: 4 additions & 0 deletions tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@
needs_py310 = pytest.mark.skipif(
sys.version_info < (3, 10), reason="requires python3.10+"
)

needs_linux = pytest.mark.skipif(
not sys.platform.startswith("linux"), reason="Test requires Linux"
)

0 comments on commit f4347ae

Please sign in to comment.