curl / trurl

trurl is a command line tool for URL parsing and manipulation.
https://curl.se/trurl/
Other
3.15k stars 102 forks source link

ci: add Windows builds + tests #249

Closed vszakats closed 10 months ago

vszakats commented 10 months ago

Add automated Windows builds and tests.

Use curl-for-win with llvm + mingw64, and a minimal libcurl build with no external dependencies to build x64, ARM64 and x86 trurl.exe.

Boost build performance by not building the curl tool [EXPERIMENTAL]. Use a customized curl-for-win build with disabled TLS to further reduce footprint and build time.

Non-UNITY libcurl builds can make turl binaries about 120KB smaller, but they require 2x build times (4m vs. 2m), so opted not to use those here.

Also enable tests and fix issues along the way:

Fixes #109 Closes #249

vszakats commented 10 months ago

First successful build: https://github.com/curl/trurl/actions/runs/6814620035/job/18531898994#step:3:5308 Also for x86 and arm64.

vszakats commented 10 months ago

Second run (3m11s), with downloadable artifacts: https://github.com/curl/trurl/actions/runs/6814704059

bagder commented 10 months ago

Nice!

There is of course a lot of stuff in that downloadable, but we can potentially polish on that later.

vszakats commented 10 months ago

More details about these builds:

vszakats commented 10 months ago

@bagder: Yes, the artifact was tailored for curl. For trurl this can be re-done locally by picking out bin/turl.exe and bin/libcurl*.dll from the artifact. I'm thinking of an option to leave the necessary directories on disk (DONE → https://github.com/curl/curl-for-win/commit/67a04d17f5ec442548c71a942d0eac83c65fd1e2). (I was also thinking doing this for the standalone curl binaries for easier access that doesn't require any unpacking, though GHA will zip it anyway, so didn't pursue this just yet.)

vszakats commented 10 months ago

Improved artifacts with nothing else than necessary for trurl: https://github.com/curl/trurl/actions/runs/6815583239

curl-8.5.0-DEV_4fc402b9f2cefa597f58b9703293af2992988d68-win32-mingw-pico/bin/libcurl.dll
curl-8.5.0-DEV_4fc402b9f2cefa597f58b9703293af2992988d68-win32-mingw-pico/bin/trurl.exe
curl-8.5.0-DEV_4fc402b9f2cefa597f58b9703293af2992988d68-win64-mingw-pico/bin/libcurl-x64.dll
curl-8.5.0-DEV_4fc402b9f2cefa597f58b9703293af2992988d68-win64-mingw-pico/bin/trurl.exe
curl-8.5.0-DEV_4fc402b9f2cefa597f58b9703293af2992988d68-win64a-mingw-pico/bin/libcurl-arm64.dll
curl-8.5.0-DEV_4fc402b9f2cefa597f58b9703293af2992988d68-win64a-mingw-pico/bin/trurl.exe
urls.txt
vszakats commented 10 months ago

Now with a 'flat' package artifact:

curl-8.5.0-DEV_8197af4364d7c8402bc3a36f809801508ad2e96c-win32-mingw-zero/libcurl.dll
curl-8.5.0-DEV_8197af4364d7c8402bc3a36f809801508ad2e96c-win32-mingw-zero/trurl.exe
curl-8.5.0-DEV_8197af4364d7c8402bc3a36f809801508ad2e96c-win64-mingw-zero/libcurl-x64.dll
curl-8.5.0-DEV_8197af4364d7c8402bc3a36f809801508ad2e96c-win64-mingw-zero/trurl.exe
curl-8.5.0-DEV_8197af4364d7c8402bc3a36f809801508ad2e96c-win64a-mingw-zero/libcurl-arm64.dll
curl-8.5.0-DEV_8197af4364d7c8402bc3a36f809801508ad2e96c-win64a-mingw-zero/trurl.exe
vszakats commented 10 months ago

Made some finishing touches and implemented a flattening option in curl-for-win (so now it works for all platforms): https://github.com/curl/trurl/actions/runs/6828186933

vszakats commented 10 months ago

Made trurl.exe static (tested for Windows for now). The artifact now:

curl-8.5.0-DEV_3a2d22a9204d9e93e3820e275164e708dcd8552b-win32-mingw-zero/trurl.exe
curl-8.5.0-DEV_3a2d22a9204d9e93e3820e275164e708dcd8552b-win64-mingw-zero/trurl.exe
curl-8.5.0-DEV_3a2d22a9204d9e93e3820e275164e708dcd8552b-win64a-mingw-zero/trurl.exe
vszakats commented 10 months ago

When trying to run tests (after fixing a bunch of roadblocks), there are 10 tests still failing: https://github.com/curl/trurl/actions/runs/6864110037/job/18665177457#step:3:4226

These are test tests failing in the Windows libcurl + wine configuration:

20: passed  https://curl.se:22/ -s port=443
21: passed  https://curl.se:22/ -s port=443 --get '{url}'
23: passed  --default-port --url https://curl.se/we/are.html --get '{port}'
27: passed  --url 'imap://hello:secret;crazy@curl.se/we/are.html' --get '{options}'
35: passed  --url https://curl.se/we/are.html -g '{default:port}'
59: passed  https://hello:443/foo
60: passed  ftp://hello:21/foo
62: passed  ftp://hello:443/foo -s scheme=https
84: passed  https://curl.se --iterate 'port=80 81 443'
105: passed 'imaps://user:password;crazy@[ff00::1234%hello]:1234/path?a=b&c=d#fragment' --json

E.g.:

59: failed  https://hello:443/foo
--- stdout --- 
expected:
'https://hello/foo\n'
got:
'https://hello:443/foo\n'

Does anybody have an idea where the problem might be?

UPDATE-1: This replicates with a local macOS build, using curl 8.5.0-DEV. UPDATE-2: Also with curl 8.4.0 stable. UPDATE-3: Also with a local Linux MUSL build, using curl 8.5.0-DEV.

vszakats commented 10 months ago

Right, the solution is that I reduced the libcurl build to the absolute minimum, meaning no TLS, but, this also makes curl not recognize the HTTPS scheme anymore, thus not regarding 443 a default port for HTTPS. And since by default trurl hides default ports, it hides it with a libcurl built with a TLS backend and shows it with a libcurl without a TLS backend.

This extends to all schemes a curl build might recognize, e.g. FTP in above failures (which FWIW are also disabled in the libcurl here).

If anything, tests should not rely on such property of libcurl, so one good fix is to add --keep-port to these.

vszakats commented 10 months ago

Down to:

28: failed  --url '***curl.se/we/are.html' --get '{options}'
106: failed '***[ff00::1234%hello]:1234/path?a=b&c=d#fragment' --json

UPDATE: Fixed by enabling IMAP in libcurl and moving imaps to imap to work without TLS.