Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: use correct platform #194

Merged
merged 3 commits into from
Feb 8, 2025
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
7 changes: 4 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- run: uvx hatch run +py=${{matrix.python-version}} types:check

test:
runs-on: ubuntu-latest
runs-on: ${{matrix.os}}
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13', pypy3.9, pypy3.10]
Expand All @@ -44,8 +44,9 @@ jobs:

- name: Upload coverage data
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
if: matrix.os == 'ubuntu-latest'
with:
name: coverage-data-${{ matrix.python-version }}-${{matrix.os}}-${{strategy.job-index}}
name: coverage-data-${{github.run_id}}-${{ matrix.python-version }}-${{matrix.os}}-${{strategy.job-index}}
path: .coverage.*
include-hidden-files: true
if-no-files-found: ignore
Expand All @@ -64,7 +65,7 @@ jobs:

- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
pattern: coverage-data-*
pattern: coverage-data-${{github.run_id}}-*
merge-multiple: true

- name: Combine coverage & fail if it's <100%
Expand Down
5 changes: 3 additions & 2 deletions src/inline_snapshot/testing/_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from argparse import ArgumentParser
from io import StringIO
from pathlib import Path
from pathlib import PurePosixPath
from tempfile import TemporaryDirectory
from typing import Any

Expand Down Expand Up @@ -175,7 +176,7 @@ def run_inline(
recorder.fix_all()

report_output = StringIO()
console = Console(file=report_output)
console = Console(file=report_output, width=80)

# TODO: add all the report output here
report_problems(console)
Expand Down Expand Up @@ -298,7 +299,7 @@ def run_pytest(

for name, content in sorted(self._read_files(tmp_path).items()):
if name not in self.files or self.files[name] != content:
current_files[name] = content
current_files[str(PurePosixPath(*Path(name).parts))] = content
assert changed_files == current_files

return Example(self._read_files(tmp_path))
17 changes: 12 additions & 5 deletions tests/test_formating.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import platform
import re
import sys
from types import SimpleNamespace
Expand All @@ -8,6 +9,8 @@
from inline_snapshot.testing import Example
from tests._is_normalized import normalization

executable = sys.executable.replace("\\", "\\\\")


def test_black_formatting_error(mocker):
mocker.patch.object(CliRunner, "invoke", return_value=SimpleNamespace(exit_code=1))
Expand Down Expand Up @@ -77,7 +80,7 @@ def test_format_command():
""",
"pyproject.toml": f"""\
[tool.inline-snapshot]
format-command="{sys.executable} fmt_cmd.py {{filename}}"
format-command="{executable} fmt_cmd.py {{filename}}"
""",
"test_a.py": """\
from inline_snapshot import snapshot
Expand Down Expand Up @@ -106,13 +109,17 @@ def test_format_command_fail():

@normalization
def NoPaths(text):
path_re = "/[^ ]*/" if platform.system() != "Windows" else r".:\\[^ ]*\\"
text = re.sub(
"The format_command.*following error:",
lambda m: m[0].replace("\n", ""),
"The.format_command.*following.error:",
lambda m: re.sub(" *\n *", " ", m[0]),
text,
flags=re.MULTILINE | re.DOTALL,
)
text = re.sub("/[^ ]*/", "/.../", text, flags=re.MULTILINE)
text = re.sub(path_re, "/.../", text, flags=re.MULTILINE)

text = text.replace("python.exe", "python3")

return text

Example(
Expand All @@ -124,7 +131,7 @@ def NoPaths(text):
""",
"pyproject.toml": f"""\
[tool.inline-snapshot]
format-command="{sys.executable} fmt_cmd.py {{filename}}"
format-command="{executable} fmt_cmd.py {{filename}}"
""",
"test_a.py": """
from inline_snapshot import snapshot
Expand Down
2 changes: 1 addition & 1 deletion tests/test_pytest_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,7 @@ def test_storage_dir_config(project, tmp_path, storage_dir):
project.pyproject(
f"""
[tool.inline-snapshot]
storage-dir = "{storage_dir}"
storage-dir = {str(storage_dir)!r}
"""
)

Expand Down
Loading