-
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
add vnu-validator 23.4.11 #24509
Merged
Merged
add vnu-validator 23.4.11 #24509
Changes from 11 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
cc232fb
add vnu-validator 23.4.11
bollwyvl 860afd5
fix tests
bollwyvl 79e4a94
Merge remote-tracking branch 'upstream/main' into add-vnu-validator-2…
bollwyvl 29b0b4b
fix win
bollwyvl 62aa632
add a host env
bollwyvl 0d6eb5d
try to ignore python
bollwyvl 51184db
echo off
bollwyvl 9896135
move ignore
bollwyvl 80cafe1
try to get single builds per platform
bollwyvl f8e7c96
Merge branch 'main' into add-vnu-validator-23.4.11
bollwyvl 9b33bdd
Merge branch 'main' into add-vnu-validator-23.4.11
bollwyvl bdc289b
add CREDITS
bollwyvl a437379
Merge branch 'main' into add-vnu-validator-23.4.11
bollwyvl acb7316
fix CREDITS, with cachebusting local name
bollwyvl b3c2c29
Merge branch 'main' into add-vnu-validator-23.4.11
bollwyvl ec0c1e8
Merge branch 'main' into add-vnu-validator-23.4.11
bollwyvl bc7838e
simplify
isuruf bbb808f
Update recipes/vnu-validator/meta.yaml
bollwyvl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
@ECHO ON | ||
|
||
cd "%SRC_DIR%" | ||
|
||
if not exist "%LIBRARY_LIB%" mkdir "%LIBRARY_LIB%" | ||
|
||
copy build\dist\vnu.jar "%LIBRARY_LIB%\vnu.jar" || exit 1 | ||
|
||
if not exist "%LIBRARY_BIN%" mkdir "%LIBRARY_BIN%" | ||
|
||
echo @ECHO OFF > "%LIBRARY_BIN%\vnu.cmd" | ||
echo java -jar "%LIBRARY_LIB%\vnu.jar" %%* >> "%LIBRARY_BIN%\vnu.cmd" | ||
echo IF %%ERRORLEVEL%% NEQ 0 EXIT /B %%ERRORLEVEL%% >> "%LIBRARY_BIN%\vnu.cmd" | ||
|
||
type %LIBRARY_BIN%\vnu.cmd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/usr/bin/env bash | ||
set -eux | ||
|
||
mkdir -p "${PREFIX}/lib/" | ||
cp "${SRC_DIR}/build/dist/vnu.jar" "${PREFIX}/lib/" | ||
|
||
mkdir -p "${PREFIX}/bin" | ||
|
||
echo '#!/usr/bin/env bash' > "${PREFIX}/bin/vnu" | ||
echo 'java -jar "'$PREFIX'/lib/vnu.jar" "$@"' >> "${PREFIX}/bin/vnu" | ||
chmod +x "${PREFIX}/bin/vnu" | ||
|
||
cat "${PREFIX}/bin/vnu" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
noarch_platform: | ||
- unix # [osx] | ||
- unix # [linux] | ||
- win # [win] | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{% set version = "23.4.11" %} | ||
|
||
package: | ||
name: vnu-validator | ||
version: {{ version }} | ||
|
||
source: | ||
# building from source is... untenable due to sh/py/ant/java/git sandwich | ||
url: https://registry.npmjs.org/vnu-jar/-/vnu-jar-{{ version }}.tgz | ||
sha256: cbba595a86d680d48e9c5261a16d9ef409e5658ad8aa47081c593690a652cf0f | ||
|
||
build: | ||
number: 0 | ||
noarch: generic | ||
|
||
requirements: | ||
run: | ||
- __{{ noarch_platform }} | ||
- openjdk >=8 | ||
|
||
test: | ||
requires: | ||
- m2-grep # [win] | ||
- python | ||
bollwyvl marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- pytest | ||
|
||
about: | ||
home: https://validator.github.io/validator | ||
license: MIT | ||
# TODO: see if licenses are in jar (unlikely) | ||
license_file: LICENSE | ||
bollwyvl marked this conversation as resolved.
Show resolved
Hide resolved
|
||
summary: Helps you catch problems in your HTML/CSS/SVG | ||
dev_url: https://github.com/validator/validator | ||
|
||
extra: | ||
recipe-maintainers: | ||
- bollwyvl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,176 @@ | ||
import os | ||
from subprocess import Popen, PIPE | ||
import pytest | ||
import re | ||
import sys | ||
import shutil | ||
import time | ||
import textwrap | ||
import socket | ||
from urllib.request import urlopen | ||
from pathlib import Path | ||
|
||
WIN = os.name == "nt" | ||
|
||
UTF8 = dict(encoding="utf-8") | ||
|
||
BAD_HTML = """ | ||
<html/> | ||
""" | ||
|
||
GOOD_HTML = """<!DOCTYPE html> | ||
<html lang="en-US"> | ||
<head> | ||
<title>hello world</title> | ||
<meta charset="utf-8"> | ||
</head> | ||
<body> | ||
<h1>hello world</h1> | ||
</body> | ||
</html> | ||
""" | ||
|
||
HTML = {"bad": BAD_HTML, "good": GOOD_HTML} | ||
|
||
VNU = shutil.which("vnu") or shutil.which("vnu.cmd") | ||
JAVA = Path(shutil.which("java") or shutil.which("java.exe")) | ||
JAR = Path(sys.prefix) / ("Library/lib" if WIN else "lib") / "vnu.jar" | ||
|
||
|
||
def test_version(): | ||
"""Can it report its version?""" | ||
vnu("--version", expect_stdout=re.escape(os.environ["PKG_VERSION"])) | ||
|
||
|
||
def test_help(): | ||
"""Can it provide help?""" | ||
vnu("--help") | ||
|
||
|
||
@pytest.mark.parametrize("http", [True, False]) | ||
@pytest.mark.parametrize( | ||
"keys,rc,stdout,stderr", | ||
[ | ||
("good", 0, r"^$", r"^$"), | ||
("bad", 1, r"^$", r"Start tag seen"), | ||
("bad,good", 1, r"^$", r"Start tag seen"), | ||
], | ||
) | ||
def test_files_cli( | ||
tmp_path: Path, | ||
a_vnu_client_http_args: list[str], | ||
keys: list[str], | ||
rc: int, | ||
stdout: str | None, | ||
stderr: str | None, | ||
http: bool, | ||
): | ||
"""Can it validate?""" | ||
htmls = [] | ||
for key in keys.split(","): | ||
html = tmp_path / f"{key}.html" | ||
html.write_text(HTML[key].strip(), **UTF8) | ||
htmls.append(html) | ||
|
||
vnu( | ||
*htmls, | ||
expect_rc=rc, | ||
expect_stdout=stdout, | ||
expect_stderr=stderr, | ||
http=http, | ||
http_args=a_vnu_client_http_args, | ||
) | ||
|
||
|
||
def vnu( | ||
*args, | ||
expect_rc=0, | ||
expect_stdout=None, | ||
expect_stderr=None, | ||
http=False, | ||
http_args=None, | ||
): | ||
"""Run vnu and look for output.""" | ||
vnu_args = [str(VNU)] | ||
if http: | ||
vnu_args = http_args | ||
if expect_stderr is not None: | ||
# only writes to stdout | ||
expect_stdout = expect_stderr | ||
expect_stderr = None | ||
str_args = list(map(str, [*vnu_args, *args])) | ||
print("\t".join(str_args)) | ||
proc = Popen(str_args, stdout=PIPE, stderr=PIPE, **UTF8) | ||
stdout, stderr = proc.communicate() | ||
proc.wait() | ||
rc = proc.returncode | ||
_indent_some(rc=rc, stdout=stdout, stderr=stderr) | ||
assert rc == expect_rc, f"vnu unexpectedly returned code: {rc}" | ||
if expect_stdout is not None: | ||
assert re.findall(expect_stdout, str(stdout if stdout else "").strip()) | ||
if expect_stderr is not None: | ||
assert re.findall(expect_stderr, str(stderr if stderr else "").strip()) | ||
return rc, stdout, stderr | ||
|
||
|
||
@pytest.fixture() | ||
def an_unused_port() -> int: | ||
"""Find an unused network port (could still create race conditions).""" | ||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | ||
s.bind(("127.0.0.1", 0)) | ||
s.listen(1) | ||
port = s.getsockname()[1] | ||
s.close() | ||
return port | ||
|
||
|
||
@pytest.fixture() | ||
def a_vnu_client_http_args(an_unused_port: int): | ||
java = [str(JAVA), "-cp", str(JAR)] | ||
host = "127.0.0.1" | ||
server_args = [ | ||
*java, | ||
f"-Dnu.validator.servlet.bind-address={host}", | ||
"nu.validator.servlet.Main", | ||
str(an_unused_port), | ||
] | ||
server = Popen(server_args) | ||
|
||
retries = 5 | ||
started = False | ||
last_error = None | ||
|
||
time.sleep(5) | ||
|
||
for retry in range(retries): | ||
try: | ||
urlopen(f"http://{host}:{an_unused_port}/", timeout=10) | ||
started = True | ||
break | ||
except Exception as err: | ||
last_error = err | ||
time.sleep(1) | ||
pass | ||
|
||
assert started, f"{last_error}" | ||
|
||
client_args = [ | ||
*java, | ||
f"-Dnu.validator.client.port={an_unused_port}", | ||
f"-Dnu.validator.client.host={host}", | ||
"nu.validator.client.HttpClient", | ||
] | ||
|
||
yield client_args | ||
server.terminate() | ||
server.kill() | ||
|
||
|
||
def _indent_some(**label_text): | ||
for label, text in label_text.items(): | ||
print("=" * 8, label, "=" * 8) | ||
print(textwrap.indent(str(text), " " * 8)) | ||
|
||
|
||
if __name__ == "__main__": | ||
pytest.main(["-vv", "--color=yes", __file__]) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for the review!,
we'll get there over in
conda-forge.yml
: here, it's being used as the name of__{virtual platform}
, as we only want to end up with 2 builds (unix
andwin
).This is adapted from
ipython-feedstock
:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's overly complicated. Here's a simplification of the ipython-feedstock. conda-forge/ipython-feedstock#205
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, tried that locally, getting: