diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 5794911..4c2582b 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -20,7 +20,6 @@ on: - cron: 0 12 1 * * jobs: test-suite: - runs-on: ubuntu-latest strategy: fail-fast: true matrix: @@ -31,6 +30,7 @@ jobs: command: "matrix:cov", matrix: "+py=3.12", hatch_version: "1.0", + os: ubuntu-latest, } - { name: Python-3.11, @@ -38,6 +38,7 @@ jobs: command: "matrix:cov", matrix: "+py=3.11", hatch_version: "1.0", + os: ubuntu-latest, } - { name: Python-3.10, @@ -45,6 +46,7 @@ jobs: command: "matrix:cov", matrix: "+py=3.10", hatch_version: "1.0", + os: ubuntu-latest, } - { name: Python-3.9, @@ -52,6 +54,7 @@ jobs: command: "matrix:cov", matrix: "+py=3.9", hatch_version: "1.0", + os: ubuntu-latest, } - { name: Python-3.8, @@ -59,6 +62,7 @@ jobs: command: "matrix:cov", matrix: "+py=3.8", hatch_version: "1.0", + os: ubuntu-latest, } - { name: Hatch-1.7.x, @@ -66,6 +70,7 @@ jobs: command: "versions:cov", matrix: "+version=1.7.x", hatch_version: "1.7.0", + os: ubuntu-latest, } - { name: Hatch-1.8.x, @@ -73,6 +78,7 @@ jobs: command: "versions:cov", matrix: "+version=1.8.x", hatch_version: "1.8.0", + os: ubuntu-latest, } - { name: Hatch-1.9.x, @@ -80,7 +86,17 @@ jobs: command: "versions:cov", matrix: "+version=1.9.x", hatch_version: "1.9.0", + os: ubuntu-latest, } + - { + name: Hatch-Windows, + python: "3.11", + command: "matrix:cov", + matrix: "+py=3.11", + hatch_version: "1.0", + os: windows-latest, + } + runs-on: ${{ matrix.os }} concurrency: group: ${{ github.workflow }}-${{ matrix.name }}-${{ github.ref }} cancel-in-progress: true diff --git a/docs/gen_pages.py b/docs/gen_pages.py index 8c4dde0..e755fae 100644 --- a/docs/gen_pages.py +++ b/docs/gen_pages.py @@ -30,9 +30,7 @@ mkdocs_gen_files.set_edit_path(full_doc_path, path) - -with open("README.md") as in_file: - readme_content = in_file.read() +readme_content = Path("README.md").read_text(encoding="utf-8") # Exclude parts that are between two exact `<!--skip-->` lines readme_content = "\n".join(readme_content.split("\n<!--skip-->\n")[::2]) with mkdocs_gen_files.open("index.md", "w") as index_file: diff --git a/hatch_pip_compile/lock.py b/hatch_pip_compile/lock.py index 9f6ba7f..c350155 100644 --- a/hatch_pip_compile/lock.py +++ b/hatch_pip_compile/lock.py @@ -53,7 +53,9 @@ def process_lock(self, lockfile: pathlib.Path) -> None: lockfile_text, ) if self.constraints_file is not None: - constraint_sha = hashlib.sha256(self.constraints_file.read_bytes()).hexdigest() + lockfile_contents = self.constraints_file.read_bytes() + cross_platform_contents = lockfile_contents.replace(b"\r\n", b"\n") + constraint_sha = hashlib.sha256(cross_platform_contents).hexdigest() constraints_path = self.constraints_file.relative_to(self.project_root).as_posix() constraints_line = f"# [constraints] {constraints_path} (SHA256: {constraint_sha})" joined_dependencies = "\n".join([constraints_line, "#", joined_dependencies]) @@ -156,7 +158,9 @@ def get_file_content_hash(self) -> str: """ Get hash of lock file """ - return hashlib.sha256(self.lock_file.read_bytes()).hexdigest() + lockfile_contents = self.lock_file.read_bytes() + cross_platform_contents = lockfile_contents.replace(b"\r\n", b"\n") + return hashlib.sha256(cross_platform_contents).hexdigest() def read_lock_requirements(self) -> List[Requirement]: """ diff --git a/tests/test_integration.py b/tests/test_integration.py index cc1030e..12b10ac 100644 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -6,6 +6,7 @@ and external tools (pip-tools / pip). """ +import sys from typing import Dict, Type import hatch @@ -28,6 +29,8 @@ def test_new_dependency( """ Test adding a new dependency """ + if installer == "pip-sync" and sys.platform == "win32": + pytest.skip("Flaky test on Windows") original_requirements = pip_compile.default_environment.piptools_lock.read_header_requirements() assert original_requirements == [packaging.requirements.Requirement("hatch")] pip_compile.toml_doc["project"]["dependencies"] = ["requests"]