#5 Use pytest-env, now that it is packaged
Merged 11 months ago by churchyard. Opened 11 months ago by music.
rpms/ music/pre-commit pytest-env  into  rawhide

@@ -1,23 +0,0 @@ 

- --- a/tests/languages/node_test.py	2021-03-10 01:57:10.000000000 +0100

- +++ b/tests/languages/node_test.py	2021-03-23 20:20:58.740387439 +0100

- @@ -82,7 +82,7 @@

-          assert not node.healthy(prefix, 'system')

-  

-  

- -@xfailif_windows  # pragma: win32 no cover

- +@pytest.mark.xfail(strict=True)

-  def test_installs_without_links_outside_env(tmpdir):

-      tmpdir.join('bin/main.js').ensure().write(

-          '#!/usr/bin/env node\n'

- 

- --- a/tests/languages/ruby_test.py	2021-03-10 01:57:10.000000000 +0100

- +++ b/tests/languages/ruby_test.py	2021-03-23 20:11:20.654877325 +0100

- @@ -65,7 +65,7 @@

-          cmd_output('rbenv', '--help')

-  

-  

- -@xfailif_windows  # pragma: win32 no cover

- +@pytest.mark.xfail(strict=True)

-  def test_install_ruby_with_version(fake_gem_prefix):

-      ruby.install_environment(fake_gem_prefix, '2.7.2', ())

-  

file modified
+85 -37
@@ -1,37 +1,42 @@ 

  %bcond_without check

- %global pypi_name pre-commit

  

- Name:           %{pypi_name}

+ Name:           pre-commit

  Version:        2.16.0

- Release:        2%{?dist}

+ Release:        3%{?dist}

  Summary:        Framework for managing and maintaining multi-language pre-commit hooks

  

  License:        MIT

  URL:            https://pre-commit.com

  Source0:        https://github.com/%{name}/%{name}/archive/v%{version}/%{name}-%{version}.tar.gz

- Patch0:         0001-disable-tests-with-network-install.patch

+ 

  BuildArch:      noarch

  

  BuildRequires:  python3-devel

- BuildRequires:  python3dist(setuptools)

  

  %if %{with check}

+ # All of the tests for the following require network access, so we can avoid

+ # pulling in these dependencies for now.

+ #

+ # BuildRequires:  R-core

+ # BuildRequires:  conda

+ # BuildRequires:  dotnet-host

+ # BuildRequires:  dotnet-hostfxr-6.0

+ # BuildRequires:  dotnet-sdk-6.0

+ # BuildRequires:  golang-bin

+ 

+ # These BR’s would enable a few extra tests, but are inconveniently

+ # ExclusiveArch. If we wanted to conditionalize BR’s based on build

+ # architecture, we would have to make *this* package arched.

+ #

+ # BuildRequires:  swift-lang

+ 

+ BuildRequires:  cargo

  BuildRequires:  git-core

- BuildRequires:  python3dist(aspy-yaml)

- BuildRequires:  python3dist(cfgv) >= 2.0.0

- BuildRequires:  python3dist(flake8)

- BuildRequires:  python3dist(identify) >= 1.0.0

  BuildRequires:  npm

  BuildRequires:  nodejs

+ BuildRequires:  perl-CPAN

+ BuildRequires:  rubypick

  BuildRequires:  rubygems

- BuildRequires:  python3dist(mock)

- BuildRequires:  python3dist(re-assert)

- BuildRequires:  python3dist(nodeenv) >= 0.11.1

- BuildRequires:  python3dist(pytest)

- BuildRequires:  python3dist(pyyaml)

- BuildRequires:  python3dist(six)

- BuildRequires:  python3dist(toml)

- BuildRequires:  python3dist(virtualenv) >= 20

  %endif

  

  %description
@@ -40,17 +45,22 @@ 

  

  %prep

  %autosetup -p1

+ # Do not generate BR’s for coverage, linters, etc.:

+ sed -r '/^(covdefaults|coverage)\b/d' requirements-dev.txt |

+   tee requirements-dev-filtered.txt

+ 

  

- # Remove bundled egg-info

- rm -rf %{pypi_name}.egg-info

+ %generate_buildrequires

+ %pyproject_buildrequires -r %{?with_check:requirements-dev-filtered.txt}

  

  

  %build

- %py3_build

+ %pyproject_wheel

  

  

  %install

- %py3_install

+ %pyproject_install

+ %pyproject_save_files pre_commit

  

  

  %if %{with check}
@@ -58,29 +68,67 @@ 

  git init

  git config --global user.email "you@example.com"

  git config --global user.name "Your Name"

- export PYTHONPATH=%{buildroot}%{python3_sitelib}

- 

- # Disable few tests

- # * 'make_archives_test' and 'repository_test' need a network connection, hence disabled.

- # * 'install_uninstall_test' needs pytest-env (currently not packaged)

- %pytest -v \

-     --deselect tests/make_archives_test.py \

-     --deselect tests/repository_test.py \

-     --deselect tests/commands/install_uninstall_test.py

+ 

+ # For general discusson on test failures building distribution packages, see:

+ # https://github.com/pre-commit/pre-commit/issues/1183,

+ # https://github.com/pre-commit/pre-commit/issues/1202

+ #

+ # Require network access:

+ # See https://github.com/pre-commit/pre-commit/issues/1202

+ k="${k-}${k+ and }not test_additional_dependencies_roll_forward"

+ k="${k-}${k+ and }not test_additional_golang_dependencies_installed"

+ k="${k-}${k+ and }not test_additional_node_dependencies_installed"

+ k="${k-}${k+ and }not test_additional_ruby_dependencies_installed"

+ k="${k-}${k+ and }not test_additional_rust_cli_dependencies_installed"

+ k="${k-}${k+ and }not test_additional_rust_lib_dependencies_installed"

+ k="${k-}${k+ and }not test_conda_hook"

+ k="${k-}${k+ and }not test_conda_with_additional_dependencies_hook"

+ k="${k-}${k+ and }not test_dotnet_hook"

+ k="${k-}${k+ and }not test_golang_hook"

+ k="${k-}${k+ and }not test_golang_hook_still_works_when_gobin_is_set"

+ k="${k-}${k+ and }not test_golang_with_recursive_submodule"

+ k="${k-}${k+ and }not test_install_ruby_with_version"

+ k="${k-}${k+ and }not test_installs_without_links_outside_env"

+ k="${k-}${k+ and }not test_local_conda_additional_dependencies"

+ k="${k-}${k+ and }not test_local_golang_additional_dependencies"

+ k="${k-}${k+ and }not test_local_perl_additional_dependencies"

+ k="${k-}${k+ and }not test_local_rust_additional_dependencies"

+ k="${k-}${k+ and }not test_r_hook"

+ k="${k-}${k+ and }not test_r_inline_hook"

+ k="${k-}${k+ and }not test_r_local_with_additional_dependencies_hook"

+ k="${k-}${k+ and }not test_r_with_additional_dependencies_hook"

+ k="${k-}${k+ and }not test_run_a_node_hook_default_version"

+ k="${k-}${k+ and }not test_run_ruby_hook_with_disable_shared_gems"

+ k="${k-}${k+ and }not test_run_versioned_node_hook"

+ k="${k-}${k+ and }not test_run_versioned_ruby_hook"

+ # Requires Python 2 (forbidden as a BR, obsolete)

+ k="${k-}${k+ and }not test_switch_language_versions_doesnt_clobber"

+ # Requires dart (not packaged):

+ k="${k-}${k+ and }not test_dart_hook"

+ k="${k-}${k+ and }not test_local_dart_additional_dependencies"

+ k="${k-}${k+ and }not test_local_dart_additional_dependencies_versioned"

+ # Does not work under (i.e., respect) an “external” PYTHONPATH

+ k="${k-}${k+ and }not test_installed_from_venv"

+ # Fails in koji but not local mock (hook exits with code 1, no useful output)

+ k="${k-}${k+ and }not test_run_a_ruby_hook"

+ %pytest -v -k "${k-}"

  %endif

  

  

- %files

- %license LICENSE

+ %files -f %{pyproject_files}

  %doc README.md CHANGELOG.md CONTRIBUTING.md

- %{_bindir}/%{pypi_name}

- %{_bindir}/%{pypi_name}-validate-config

- %{_bindir}/%{pypi_name}-validate-manifest

- %{python3_sitelib}/pre_commit/

- %{python3_sitelib}/pre_commit-%{version}-py%{python3_version}.egg-info/

+ %{_bindir}/pre-commit

+ %{_bindir}/pre-commit-validate-config

+ %{_bindir}/pre-commit-validate-manifest

  

  

  %changelog

+ * Thu Mar 24 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 2.16.0-3

+ - Use pytest-env, now that it is packaged

+ - Skip tests more precisely/selectively

+ - Drop unnecessary BR on deprecated python-mock

+ - Port to pyproject-rpm-macros

+ 

  * Fri Jan 21 2022 Fedora Release Engineering <releng@fedoraproject.org> - 2.16.0-2

  - Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild

  

  • Use pytest-env, now that it is packaged
  • Skip tests more precisely/selectively
  • Drop unnecessary BR on deprecated python-mock

Increases test coverage from

= 558 passed, 1 skipped, 138 deselected, 5 xfailed, 1 warning in 99.88s (0:01:39) =

to

===== 657 passed, 8 skipped, 34 deselected, 3 xfailed in 69.42s (0:01:09) ======

rebased onto b7eb1b7

11 months ago

rebased onto b659162

11 months ago

rebased onto 1ad2c11

11 months ago

Scratch build on all architectures, to confirm there are no remaining builder-arch-dependent issues or inconveniently-ExcludeArch BR’s: https://koji.fedoraproject.org/koji/taskinfo?taskID=84789746

Awesome! Thanks.

Would you be interested in converting the package to pyproject macros as well? Not a requirement.

Would you be interested in converting the package to pyproject macros as well? Not a requirement.

Sure! Would you like that combined with this, or as a separate PR?

Extra commit for sure. Whether or not a separate PR, I don't have a preference.

1 new commit added

  • Port to pyproject-rpm-macros
11 months ago

some sanity checks:

$ rpm -qpl --licensefiles pre-commit-2.16.0-3.fc37.noarch.rpm 
/usr/lib/python3.10/site-packages/pre_commit-2.16.0.dist-info/LICENSE

$ rpm -qpR pre-commit-2.16.0-3.fc37.src.rpm 
cargo
git-core
nodejs
npm
perl-CPAN
pyproject-rpm-macros
python3-devel
python3-devel
python3dist(cfgv) >= 2
python3dist(distlib)
python3dist(identify) >= 1
python3dist(nodeenv) >= 0.11.1
python3dist(packaging)
python3dist(pip) >= 19
python3dist(pytest)
python3dist(pytest-env)
python3dist(pyyaml) >= 5.1
python3dist(re-assert)
python3dist(setuptools) >= 40.8
python3dist(toml)
python3dist(virtualenv) >= 20.0.8
python3dist(wheel)
rpmlib(CompressedFileNames) <= 3.0.4-1
rpmlib(DynamicBuildRequires) <= 4.15.0-1
rpmlib(FileDigests) <= 4.6.0-1
rubygems
rubypick

$ rpm -qpR pre-commit-2.16.0-3.fc37.noarch.rpm 
/usr/bin/bash
/usr/bin/python3
python(abi) = 3.10
python3.10dist(cfgv) >= 2
python3.10dist(identify) >= 1
python3.10dist(nodeenv) >= 0.11.1
python3.10dist(pyyaml) >= 5.1
python3.10dist(toml)
python3.10dist(virtualenv) >= 20.0.8
rpmlib(CompressedFileNames) <= 3.0.4-1
rpmlib(FileDigests) <= 4.6.0-1
rpmlib(PartialHardlinkSets) <= 4.0.4-1
rpmlib(PayloadFilesHavePrefix) <= 4.0-1
rpmlib(PayloadIsZstd) <= 5.4.18-1

$ mock -r fedora-rawhide-x86_64 install ./pre-commit-2.16.0-3.fc37.noarch.rpm
...
Finish: run

I guess the dev requirements are only useful for %check? What about %{?with_check:requirements-dev-filtered.txt}?

I guess the dev requirements are only useful for %check? What about %{?with_check:requirements-dev-filtered.txt}?

Excellent suggestion. I’ll implement and force-push.

2 new commits added

  • Port to pyproject-rpm-macros
  • Use pytest-env, now that it is packaged
11 months ago

Pull-Request has been merged by churchyard

11 months ago