Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libs/config
Submodule config updated 2 files
+5 −2 AGENTS.md
+1 −1 doc/version.adoc
2 changes: 1 addition & 1 deletion libs/document
Submodule document updated 1 files
+4 −1 AGENTS.md
2 changes: 1 addition & 1 deletion libs/idna
Submodule idna updated 2 files
+3 −0 AGENTS.md
+11 −4 tools/generate_tables.py
2 changes: 1 addition & 1 deletion libs/lexical
2 changes: 1 addition & 1 deletion libs/pratt
Submodule pratt updated 1 files
+3 −0 AGENTS.md
2 changes: 1 addition & 1 deletion libs/trystero
Submodule trystero updated 0 files
2 changes: 1 addition & 1 deletion libs/wasi
Submodule wasi updated 1 files
+3 −0 AGENTS.md
2 changes: 1 addition & 1 deletion libs/xactor
Submodule xactor updated 1 files
+3 −0 AGENTS.md
2 changes: 1 addition & 1 deletion libs/xstate
Submodule xstate updated 1 files
+3 −0 AGENTS.md
2 changes: 1 addition & 1 deletion site
57 changes: 55 additions & 2 deletions tools/ci/actions_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
# https://www.boost.org/LICENSE_1_0.txt)

"""Checks the shell steps of tools/ci/actions: download.sh keeps a file only when its SHA-256 is
the pinned one, exits 1 and leaves no file when the digest differs or the download fails; and the
the pinned one, tries again a connection the server drops, exits 1 and leaves no file when the
digest differs or the download fails; and the
Boost action's install.sh refuses an empty or relative prefix before it downloads anything, since
b2 given an empty --prefix installs into /usr/local, installs b2 in <prefix>/bin and the headers
in <prefix>/include/boost on every runner, Windows's included, where the default layouts would put
Expand Down Expand Up @@ -45,7 +46,8 @@
is not OpenSSL 3; and each refuses a runner it builds nothing for. The node action keys npm's
cache on the lock file of every directory a job runs npm ci in: tools/doc, tools/lint, every
library's oracle and the site. Nothing is fetched
from the network: the downloads are file:// URLs, git is a stand-in, and install.sh runs against
from the network: the downloads are file:// URLs or a server of the test's own on the loopback, git
is a stand-in, and install.sh runs against
a download.sh that only says it was called, or that hands it a stand-in archive. Run with the
names of some cases to run only those."""

Expand All @@ -56,10 +58,12 @@
import os
import re
import shutil
import socket
import subprocess
import sys
import tarfile
import tempfile
import threading
import zipfile
from collections.abc import Callable
from pathlib import Path
Expand Down Expand Up @@ -118,6 +122,54 @@ def test_a_failed_download_exits_1_and_leaves_no_file(scratch: Path) -> None:
assert not file.exists()


class DroppingServer:
"""An HTTP server on the loopback whose first connection closes with no reply, as a server
that drops a TLS handshake does, and which serves `body` on every later one."""

def __init__(self, body: bytes) -> None:
self.body = body
self.connections = 0
self.listener = socket.create_server(('127.0.0.1', 0))
self.thread = threading.Thread(target=self.serve, daemon=True)
self.thread.start()

@property
def url(self) -> str:
return f'http://127.0.0.1:{self.listener.getsockname()[1]}/archive.tar.gz'

def serve(self) -> None:
while True:
try:
connection, _ = self.listener.accept()
except OSError:
return
with connection:
self.connections += 1
if self.connections == 1:
continue
connection.recv(65536)
head = f'HTTP/1.1 200 OK\r\nContent-Length: {len(self.body)}\r\n'
connection.sendall(f'{head}Connection: close\r\n\r\n'.encode() + self.body)

def close(self) -> None:
self.listener.close()
self.thread.join(timeout=5)


def test_a_dropped_connection_is_tried_again(scratch: Path) -> None:
path, digest = source(scratch)
server = DroppingServer(path.read_bytes())
file = scratch / 'downloaded'
try:
result = run(DOWNLOAD, server.url, digest, file,
env={'no_proxy': '127.0.0.1', 'NO_PROXY': '127.0.0.1'})
finally:
server.close()
assert result.returncode == 0, (result.returncode, result.stderr)
assert server.connections == 2, server.connections
assert file.read_bytes() == path.read_bytes()


def test_a_usage_error_exits_2(scratch: Path) -> None:
result = run(DOWNLOAD, 'file:///nothing')
assert result.returncode == 2, (result.returncode, result.stderr)
Expand Down Expand Up @@ -1714,6 +1766,7 @@ def helper(call: str, **variables: str) -> str:
test_a_pinned_download_is_kept,
test_another_digest_leaves_no_file,
test_a_failed_download_exits_1_and_leaves_no_file,
test_a_dropped_connection_is_tried_again,
test_a_usage_error_exits_2,
test_boost_refuses_an_empty_or_relative_prefix,
test_boost_installs_b2_and_the_headers_where_configure_finds_them,
Expand Down
7 changes: 5 additions & 2 deletions tools/ci/download.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ url="$1"
expected="$2"
file="$3"

# A failed download can leave part of the file, which must not be taken for the whole.
curl -fsSL --retry 3 -o "${file}" "${url}" || {
# A failed download can leave part of the file, which must not be taken for the whole. curl's
# --retry alone tries again only a timeout and an HTTP 408, 429 or 5xx; --retry-all-errors also
# tries again a connection the server drops, as a TLS handshake cut short does (curl's exit
# statuses 35, 52 and 56), which failed CI lanes downloading Boost.
curl -fsSL --retry 3 --retry-all-errors -o "${file}" "${url}" || {
status=$?
rm -f "${file}"
printf 'download.sh: could not download %s (curl exit status %s)\n' "${url}" "${status}" >&2
Expand Down
Loading