Move maturin test coverage into CI (#3714)

This test can take over 60s to run, which is too much for a unit test.
We'll run it in a separate CI job to retain coverage.
This commit is contained in:
Zanie Blue 2024-05-21 15:17:48 -04:00 committed by GitHub
parent cf997080b0
commit dfd6ccf0f9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 60 additions and 42 deletions

View file

@ -436,6 +436,31 @@ jobs:
./uv venv
./${{ matrix.command }}
integration-test-maturin:
needs: build-binary-linux
name: "integration test | maturin"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- name: "Download binary"
uses: actions/download-artifact@v4
with:
name: uv-linux-${{ github.sha }}
- name: "Prepare binary"
run: chmod +x ./uv
- name: "Compile"
run: |
echo '-e ${PROJECT_ROOT}/scripts/packages/maturin_editable' | ./uv pip compile - -o requirements.txt
- name: "Sync"
run: |
./uv venv
./uv pip sync requirements.txt
cache-test-ubuntu:
needs: build-binary-linux
name: "check cache | ubuntu"

View file

@ -90,7 +90,7 @@ reqwest = { workspace = true, features = ["blocking"], default-features = false
ignored = ["flate2"]
[features]
default = ["flate2/zlib-ng", "python", "pypi", "git", "maturin", "python-patch"]
default = ["flate2/zlib-ng", "python", "pypi", "git", "python-patch"]
# Introduces a dependency on a local Python installation.
python = []
# Introduces a dependency on a local Python installation with specific patch versions.
@ -99,8 +99,6 @@ python-patch = []
pypi = []
# Introduces a dependency on Git.
git = []
# Introduces a dependency on Maturin.
maturin = []
# Adds self-update functionality.
self-update = ["axoupdater"]

View file

@ -3327,13 +3327,11 @@ fn respect_file_env_var() -> Result<()> {
}
#[test]
#[cfg(feature = "maturin")]
fn compile_editable() -> Result<()> {
let context = TestContext::new("3.12");
let requirements_in = context.temp_dir.child("requirements.in");
requirements_in.write_str(indoc! {r"
-e ../../scripts/packages/poetry_editable
-e ${PROJECT_ROOT}/../../scripts/packages/maturin_editable
-e file://../../scripts/packages/black_editable[dev]
boltons # normal dependency for comparison
"
@ -3347,8 +3345,6 @@ fn compile_editable() -> Result<()> {
----- stdout -----
# This file was autogenerated by uv via the following command:
# uv pip compile --cache-dir [CACHE_DIR] --exclude-newer 2024-03-25T00:00:00Z [TEMP_DIR]/requirements.in
-e ${PROJECT_ROOT}/../../scripts/packages/maturin_editable
# via -r [TEMP_DIR]/requirements.in
-e ../../scripts/packages/poetry_editable
# via -r [TEMP_DIR]/requirements.in
-e file://../../scripts/packages/black_editable
@ -3383,8 +3379,8 @@ fn compile_editable() -> Result<()> {
# via aiohttp
----- stderr -----
Built 3 editables in [TIME]
Resolved 14 packages in [TIME]
Built 2 editables in [TIME]
Resolved 13 packages in [TIME]
"###);
Ok(())

View file

@ -2123,19 +2123,25 @@ fn refresh_package() -> Result<()> {
}
#[test]
#[cfg(feature = "maturin")]
fn sync_editable() -> Result<()> {
let context = TestContext::new("3.12");
let poetry_editable = context.temp_dir.child("poetry_editable");
// Copy into the temporary directory so we can mutate it
copy_dir_all(
context
.workspace_root
.join("scripts/packages/poetry_editable"),
&poetry_editable,
)?;
let requirements_txt = context.temp_dir.child("requirements.txt");
requirements_txt.write_str(&indoc::formatdoc! {r"
boltons==23.1.1
-e {workspace_root}/scripts/packages/maturin_editable
numpy==1.26.2
# via poetry-editable
-e file://{workspace_root}/scripts/packages/poetry_editable
-e file://{poetry_editable}
",
workspace_root = context.workspace_root.simplified_display(),
poetry_editable = poetry_editable.display()
})?;
// Install the editable packages.
@ -2146,14 +2152,13 @@ fn sync_editable() -> Result<()> {
----- stdout -----
----- stderr -----
Built 2 editables in [TIME]
Built 1 editable in [TIME]
Resolved 2 packages in [TIME]
Downloaded 2 packages in [TIME]
Installed 4 packages in [TIME]
Installed 3 packages in [TIME]
+ boltons==23.1.1
+ maturin-editable==0.1.0 (from file://[WORKSPACE]/scripts/packages/maturin_editable)
+ numpy==1.26.2
+ poetry-editable==0.1.0 (from file://[WORKSPACE]/scripts/packages/poetry_editable)
+ poetry-editable==0.1.0 (from file://[TEMP_DIR]/poetry_editable)
"###
);
@ -2170,50 +2175,44 @@ fn sync_editable() -> Result<()> {
Built 1 editable in [TIME]
Uninstalled 1 package in [TIME]
Installed 1 package in [TIME]
- poetry-editable==0.1.0 (from file://[WORKSPACE]/scripts/packages/poetry_editable)
+ poetry-editable==0.1.0 (from file://[WORKSPACE]/scripts/packages/poetry_editable)
- poetry-editable==0.1.0 (from file://[TEMP_DIR]/poetry_editable)
+ poetry-editable==0.1.0 (from file://[TEMP_DIR]/poetry_editable)
"###
);
// Make sure we have the right base case.
let python_source_file = context
.workspace_root
.join("scripts/packages/maturin_editable/python/maturin_editable/__init__.py");
let python_version_1 = indoc::indoc! {r"
from .maturin_editable import *
let python_source_file = poetry_editable.path().join("poetry_editable/__init__.py");
let check_installed = indoc::indoc! {r#"
from poetry_editable import a
assert a() == "a", a()
"#};
context.assert_command(check_installed).success();
// Edit the sources and make sure the changes are respected without syncing again
let python_version_1 = indoc::indoc! {r"
version = 1
"};
fs_err::write(&python_source_file, python_version_1)?;
let check_installed = indoc::indoc! {r#"
from maturin_editable import sum_as_string, version
let check_installed = indoc::indoc! {r"
from poetry_editable import version
assert version == 1, version
assert sum_as_string(1, 2) == "3", sum_as_string(1, 2)
"#};
"};
context.assert_command(check_installed).success();
// Edit the sources.
let python_version_2 = indoc::indoc! {r"
from .maturin_editable import *
version = 2
"};
fs_err::write(&python_source_file, python_version_2)?;
let check_installed = indoc::indoc! {r#"
from maturin_editable import sum_as_string, version
from pathlib import Path
let check_installed = indoc::indoc! {r"
from poetry_editable import version
assert version == 2, version
assert sum_as_string(1, 2) == "3", sum_as_string(1, 2)
"#};
"};
context.assert_command(check_installed).success();
// Don't create a git diff.
fs_err::write(&python_source_file, python_version_1)?;
uv_snapshot!(context.filters(), command(&context)
.arg(requirements_txt.path()), @r###"
success: true
@ -2221,7 +2220,7 @@ fn sync_editable() -> Result<()> {
----- stdout -----
----- stderr -----
Audited 4 packages in [TIME]
Audited 3 packages in [TIME]
"###
);

View file

@ -1,2 +1,2 @@
def a():
pass
return "a"