Skip to content

Commit

Permalink
Merge pull request #3278 from davidhewitt/ffi-check-ci
Browse files Browse the repository at this point in the history
decouple pyo3-ffi-check from MSRV
  • Loading branch information
davidhewitt authored Jun 28, 2023
2 parents b329439 + a0aa9ce commit 1d56cfe
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 48 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,10 @@ jobs:
- '.github/workflows/build.yml'
- name: Run pyo3-ffi-check
run: nox -s ffi-check
# pypy 3.7 and 3.8 are not PEP 3123 compliant so fail checks here, nor
# is pypy 3.9 on windows
if: ${{ steps.ffi-changes.outputs.changed == 'true' && inputs.rust == 'stable' && inputs.python-version != 'pypy3.7' && inputs.python-version != 'pypy3.8' && !(inputs.python-version == 'pypy3.9' && contains(inputs.os, 'windows')) }}
run: nox -s ffi-check


- name: Test cross compilation
Expand Down
2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,6 @@ harness = false
[workspace]
members = [
"pyo3-ffi",
"pyo3-ffi-check",
"pyo3-ffi-check/macro",
"pyo3-build-config",
"pyo3-macros",
"pyo3-macros-backend",
Expand Down
66 changes: 24 additions & 42 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def test_rust(session: nox.Session):

_run_cargo_test(session)
_run_cargo_test(session, features="abi3")
if not "skip-full" in session.posargs:
if "skip-full" not in session.posargs:
_run_cargo_test(session, features="full")
_run_cargo_test(session, features="abi3 full")

Expand All @@ -49,11 +49,10 @@ def test_py(session: nox.Session) -> None:
@nox.session(venv_backend="none")
def coverage(session: nox.Session) -> None:
session.env.update(_get_coverage_env())
_run(session, "cargo", "llvm-cov", "clean", "--workspace", external=True)
_run_cargo(session, "llvm-cov", "clean", "--workspace")
test(session)
_run(
_run_cargo(
session,
"cargo",
"llvm-cov",
"--package=pyo3",
"--package=pyo3-build-config",
Expand All @@ -64,7 +63,6 @@ def coverage(session: nox.Session) -> None:
"--codecov",
"--output-path",
"coverage.json",
external=True,
)


Expand All @@ -76,7 +74,8 @@ def fmt(session: nox.Session):

@nox.session(name="fmt-rust", venv_backend="none")
def fmt_rust(session: nox.Session):
_run(session, "cargo", "fmt", "--all", "--check", external=True)
_run_cargo(session, "fmt", "--all", "--check")
_run_cargo(session, "fmt", *_FFI_CHECK, "--all", "--check")


@nox.session(name="fmt-py")
Expand All @@ -96,19 +95,14 @@ def _clippy(session: nox.Session, *, env: Dict[str, str] = None) -> bool:
env = env or os.environ
for feature_set in _get_feature_sets():
try:
_run(
_run_cargo(
session,
"cargo",
"clippy",
*feature_set,
"--all-targets",
"--workspace",
# linting pyo3-ffi-check requires docs to have been built or
# the macros will error; doesn't seem worth it on CI
"--exclude=pyo3-ffi-check",
"--",
"--deny=warnings",
external=True,
env=env,
)
except Exception:
Expand Down Expand Up @@ -136,20 +130,14 @@ def check_all(session: nox.Session) -> None:

def _check(env: Dict[str, str]) -> None:
nonlocal success
env = env or os.environ
for feature_set in _get_feature_sets():
try:
_run(
_run_cargo(
session,
"cargo",
"check",
*feature_set,
"--all-targets",
"--workspace",
# linting pyo3-ffi-check requires docs to have been built or
# the macros will error; doesn't seem worth it on CI
"--exclude=pyo3-ffi-check",
external=True,
env=env,
)
except Exception:
Expand Down Expand Up @@ -313,9 +301,8 @@ def docs(session: nox.Session) -> None:
rustdoc_flags.append(session.env.get("RUSTDOCFLAGS", ""))
session.env["RUSTDOCFLAGS"] = " ".join(rustdoc_flags)

_run(
_run_cargo(
session,
"cargo",
*toolchain_flags,
"doc",
"--lib",
Expand All @@ -324,7 +311,6 @@ def docs(session: nox.Session) -> None:
"--no-deps",
"--workspace",
*cargo_flags,
external=True,
)


Expand All @@ -339,8 +325,6 @@ def format_guide(session: nox.Session):

for path in Path("guide").glob("**/*.md"):
session.log("Working on %s", path)
content = path.read_text()

lines = iter(path.read_text().splitlines(True))
new_lines = []

Expand Down Expand Up @@ -387,9 +371,8 @@ def format_guide(session: nox.Session):

@nox.session(name="address-sanitizer", venv_backend="none")
def address_sanitizer(session: nox.Session):
_run(
_run_cargo(
session,
"cargo",
"+nightly",
"test",
"--release",
Expand All @@ -402,7 +385,6 @@ def address_sanitizer(session: nox.Session):
"RUSTDOCFLAGS": "-Zsanitizer=address",
"ASAN_OPTIONS": "detect_leaks=0",
},
external=True,
)


Expand Down Expand Up @@ -479,15 +461,9 @@ def set_minimal_package_versions(session: nox.Session):
# possible version, so that this matches what CI will resolve to.
for project in projects:
if project is None:
_run(session, "cargo", "update", external=True)
_run_cargo(session, "update")
else:
_run(
session,
"cargo",
"update",
f"--manifest-path={project}/Cargo.toml",
external=True,
)
_run_cargo(session, "update", f"--manifest-path={project}/Cargo.toml")

for project in projects:
lock_file = Path(project or "") / "Cargo.lock"
Expand Down Expand Up @@ -521,22 +497,21 @@ def load_pkg_versions():
# supported on MSRV
for project in projects:
if project is None:
_run(session, "cargo", "metadata", silent=True, external=True)
_run_cargo(session, "metadata", silent=True)
else:
_run(
_run_cargo(
session,
"cargo",
"metadata",
f"--manifest-path={project}/Cargo.toml",
silent=True,
external=True,
)


@nox.session(name="ffi-check")
def ffi_check(session: nox.Session):
session.run("cargo", "doc", "-p", "pyo3-ffi", "--no-deps", external=True)
_run(session, "cargo", "run", "-p", "pyo3-ffi-check", external=True)
_run_cargo(session, "doc", *_FFI_CHECK, "-p", "pyo3-ffi", "--no-deps")
_run_cargo(session, "clippy", "--workspace", "--all-targets", *_FFI_CHECK)
_run_cargo(session, "run", *_FFI_CHECK)


@lru_cache()
Expand Down Expand Up @@ -618,6 +593,10 @@ def _run(session: nox.Session, *args: str, **kwargs: Any) -> None:
print("::endgroup::", file=sys.stderr)


def _run_cargo(session: nox.Session, *args: str, **kwargs: Any) -> None:
_run(session, "cargo", *args, **kwargs, external=True)


def _run_cargo_test(
session: nox.Session,
*,
Expand All @@ -639,7 +618,7 @@ def _run_cargo_test(


def _run_cargo_publish(session: nox.Session, *, package: str) -> None:
_run(session, "cargo", "publish", f"--package={package}", external=True)
_run_cargo(session, "publish", f"--package={package}")


def _run_cargo_set_package_version(
Expand Down Expand Up @@ -686,3 +665,6 @@ def _job_with_config(implementation, version) -> bool:

for version in PYPY_VERSIONS:
_job_with_config("PyPy", version)


_FFI_CHECK = ("--manifest-path", "pyo3-ffi-check/Cargo.toml")
7 changes: 6 additions & 1 deletion pyo3-ffi-check/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,10 @@ path = "../pyo3-ffi"
features = ["extension-module"] # A lazy way of skipping linking in most cases (as we don't use any runtime symbols)

[build-dependencies]
bindgen = "0.65.1"
bindgen = "0.66.1"
pyo3-build-config = { path = "../pyo3-build-config" }

[workspace]
members = [
"macro"
]
2 changes: 1 addition & 1 deletion pyo3-ffi-check/macro/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ proc-macro = true
glob = "0.3"
quote = "1"
proc-macro2 = "1"
scraper = "0.12"
scraper = "0.17"
3 changes: 2 additions & 1 deletion pyo3-ffi-check/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ fn main() {
non_camel_case_types,
non_upper_case_globals,
dead_code,
improper_ctypes
improper_ctypes,
clippy::all
)]
mod bindings {
include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
Expand Down

0 comments on commit 1d56cfe

Please sign in to comment.