Skip to content
Closed
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
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ __pycache__
.pytest_cache
.ruff_cache
*.egg-info
dist
2 changes: 0 additions & 2 deletions .gitattributes

This file was deleted.

51 changes: 39 additions & 12 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Wheels

on:
push:
branches: [master]
branches: [main]
pull_request:
workflow_dispatch:
inputs:
Expand All @@ -29,16 +29,18 @@ jobs:
include:
- target: linux-amd64
runner: ubuntu-24.04
identifier: cp313-manylinux_x86_64
architecture: x86_64
image: quay.io/pypa/manylinux_2_28_x86_64@sha256:e0adf18521ad35192df733a6c62d35df7801957d24e0470238aacecfab2188a3
- target: linux-arm64
runner: ubuntu-24.04-arm
identifier: cp313-manylinux_aarch64
architecture: aarch64
image: quay.io/pypa/manylinux_2_28_aarch64@sha256:a3e02308c822fb6ce0d12248b0c941817ba5e1a1bc9e7bb5929f29c50eaa40a9
- target: macos-amd64
runner: macos-15-intel
identifier: cp313-macosx_x86_64
architecture: x86_64
- target: macos-arm64
runner: macos-15
identifier: cp313-macosx_arm64
architecture: arm64
runs-on: ${{ matrix.runner }}
timeout-minutes: 35
steps:
Expand All @@ -54,12 +56,35 @@ jobs:
if: runner.os == 'macOS'
run: |
brew list cmake >/dev/null || brew install cmake
rustup toolchain install 1.99.1 --profile minimal
- name: Build and exercise installed wheel
- name: Build and exercise Linux wheel
if: runner.os == 'Linux'
env:
WHEEL_IDENTIFIER: ${{ matrix.identifier }}
CIBW_TEST_COMMAND: uv run --no-project python {project}/bin/test_wheel.py --install-ca
run: uvx --from cibuildwheel==4.3.5 cibuildwheel --only "$WHEEL_IDENTIFIER" --output-dir dist
MANYLINUX_IMAGE: ${{ matrix.image }}
WHEEL_ARCHITECTURE: ${{ matrix.architecture }}
run: |
docker run --rm -v "$PWD:/project" -w /project \
-e WHEEL_ARCHITECTURE -e CARGO_TARGET_DIR=/tmp/target \
"$MANYLINUX_IMAGE" bash -euo pipefail -c '
dnf install -y clang clang-devel cmake git
curl --proto "=https" --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain none --profile minimal
export PATH="/root/.cargo/bin:$PATH"
uv run --no-project --python /opt/python/cp313-cp313/bin/python python bin/build_wheel.py --out-dir /tmp/native-wheel
Comment thread
pirate marked this conversation as resolved.
Resolved
uvx --from auditwheel==6.8.2 auditwheel repair --plat "manylinux_2_28_$WHEEL_ARCHITECTURE" --wheel-dir dist /tmp/native-wheel/*.whl
uv venv --python /opt/python/cp313-cp313/bin/python /tmp/wheel-test
uv pip install --python /tmp/wheel-test/bin/python dist/*.whl
Comment thread
pirate marked this conversation as resolved.
Resolved
VIRTUAL_ENV=/tmp/wheel-test PATH="/tmp/wheel-test/bin:$PATH" uv run --no-project python bin/test_wheel.py --install-ca
'
- name: Build and exercise macOS wheel
if: runner.os == 'macOS'
env:
WHEEL_ARCHITECTURE: ${{ matrix.architecture }}
MACOSX_DEPLOYMENT_TARGET: "11.0"
run: |
uv run --no-project python bin/build_wheel.py --out-dir "$RUNNER_TEMP/native-wheel"
uvx --from delocate==0.13.0 delocate-wheel --require-archs "$WHEEL_ARCHITECTURE" --wheel-dir dist "$RUNNER_TEMP/native-wheel"/*.whl
uv venv --python 3.13 "$RUNNER_TEMP/wheel-test"
uv pip install --python "$RUNNER_TEMP/wheel-test/bin/python" dist/*.whl
VIRTUAL_ENV="$RUNNER_TEMP/wheel-test" PATH="$RUNNER_TEMP/wheel-test/bin:$PATH" uv run --no-project python bin/test_wheel.py --install-ca
- name: Check package metadata
run: |
uvx --from twine==7.0.0 twine check --strict dist/*.whl
Expand All @@ -71,7 +96,7 @@ jobs:
if-no-files-found: error

publish:
if: github.event_name == 'workflow_dispatch' && inputs.publish && github.ref == 'refs/heads/master'
if: github.event_name == 'workflow_dispatch' && inputs.publish && github.ref == 'refs/heads/main'
needs: wheels
runs-on: ubuntu-24.04
environment: pypi
Expand Down Expand Up @@ -112,8 +137,10 @@ jobs:
for wheel in wheels:
assert wheel.name.startswith(f'archivebox_proxy-{version}-py3-none-'), wheel
with zipfile.ZipFile(wheel) as archive:
engine = archive.getinfo('archivebox_proxy/bin/archivebox-proxy-engine')
engine = archive.getinfo('archivebox_proxy/engine/archivebox-proxy-engine')
assert engine.external_attr >> 16 & 0o111, wheel
metadata = archive.read(next(name for name in archive.namelist() if name.endswith('/WHEEL'))).decode()
assert 'Root-Is-Purelib: false' in metadata, wheel
PY
# Only wheels are published: installation never needs a compiler or a
# first-run binary download, and unsupported platforms fail at resolution.
Expand Down
95 changes: 35 additions & 60 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Tests

on:
push:
branches: [master]
branches: [main]
pull_request:
workflow_dispatch:

Expand Down Expand Up @@ -34,7 +34,7 @@ jobs:
sudo apt-get install -y clang cmake libclang-dev pkg-config
- name: Build pinned Proxelar engine
run: |
cargo fmt --check
uv run python bin/build_engine.py --fmt
uv run python bin/build_engine.py --locked
uv run python bin/build_engine.py --locked --clippy
- name: Install and check controller
Expand All @@ -46,88 +46,57 @@ jobs:
container:
runs-on: ubuntu-24.04
timeout-minutes: 25
env:
COMPOSE_PROJECT_NAME: archivebox-proxy-ci
ARCHIVEBOX_DATA: /tmp/archivebox-proxy-ci-data
ARCHIVEBOX_PORT: "18800"
PROXY_PORT: "18880"
PROXY_WORKER_PORT: "18882"
PLUGINS: screenshot,title,headers
PROXY_PERSONA: Default
steps:
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6
with:
persist-credentials: false
- name: Validate deployment configuration
env:
ARCHIVEBOX_DATA: /tmp/archivebox
- name: Validate and start the complete deployment
run: |
docker compose config --quiet
docker compose -f docker-compose.yml -f docker-compose.archive.yml config --quiet
docker compose -f docker-compose.yml -f docker-compose.capture.yml config --quiet
- name: Build proxy image
run: docker build --target runtime -t archivebox-proxy:ci .
- name: Exercise HTTPS cache in the container
docker compose up -d --build --wait --wait-timeout 120
curl --fail --silent --show-error http://localhost:18800/health/ | grep -qx OK
docker compose exec -T proxy archivebox-proxy --export-ca > /tmp/proxy-ca.pem
- name: Exercise HTTPS caching and automatic ArchiveBox capture
shell: bash
run: |
set -euo pipefail
docker run -d --name proxy -p 127.0.0.1:18880:8080 -p 127.0.0.1:18882:8082 archivebox-proxy:ci
trap 'docker logs proxy; docker rm -f -v proxy' EXIT
curl --compressed --noproxy '' --fail --silent --show-error --max-time 30 --cacert /tmp/proxy-ca.pem --proxy socks5h://127.0.0.1:18880 -H 'Accept-Encoding: gzip, deflate, br, zstd' -H 'Sec-Fetch-Mode: navigate' -H 'Sec-Fetch-Dest: document' https://news.ycombinator.com/ask -o /tmp/first.html
# Observe the asynchronous store before the one warm-cache request.
for _ in {1..100}; do
if docker cp proxy:/cache/trust.pem /tmp/proxy-ca.pem 2>/dev/null; then
if docker compose exec -T proxy sh -c "grep -q 'STORED visitor .* 200 GET https://news.ycombinator.com/ask' /cache/proxy/proxy.log"; then
break
fi
test "$(docker inspect --format '{{.State.Running}}' proxy)" = true
sleep 0.1
done
test -s /tmp/proxy-ca.pem
curl --noproxy '' --fail --silent --show-error --max-time 30 --cacert /tmp/proxy-ca.pem --proxy http://127.0.0.1:18880 https://news.ycombinator.com/ -o /tmp/first.html
# Streaming completion precedes the controller's asynchronous store.
# Observe persistence before making the one warm-cache request.
for _ in {1..100}; do
if docker exec proxy sh -c "grep -q 'STORED visitor .* 200 GET https://news.ycombinator.com/' /cache/proxy.log"; then
break
fi
test "$(docker inspect --format '{{.State.Running}}' proxy)" = true
sleep 0.1
done
docker exec proxy sh -c "grep -q 'STORED visitor .* 200 GET https://news.ycombinator.com/' /cache/proxy.log"
curl --noproxy '' --fail --silent --show-error --max-time 30 --cacert /tmp/proxy-ca.pem --proxy http://127.0.0.1:18882 https://news.ycombinator.com/ -D /tmp/second.headers -o /tmp/second.html
docker compose exec -T proxy sh -c "grep -q 'STORED visitor .* 200 GET https://news.ycombinator.com/ask' /cache/proxy/proxy.log"
curl --compressed --noproxy '' --fail --silent --show-error --max-time 30 --cacert /tmp/proxy-ca.pem --proxy http://127.0.0.1:18882 -H 'Accept-Encoding: gzip, deflate, br, zstd' https://news.ycombinator.com/ask -D /tmp/second.headers -o /tmp/second.html
cmp /tmp/first.html /tmp/second.html
grep -qi '^x-archivebox-proxy-cache: HIT' /tmp/second.headers
grep -q 'Hacker News' /tmp/second.html
- name: Build optional ArchiveBox CLI image
run: |
docker build --target with-archivebox -t archivebox-proxy:with-archivebox .
docker run --rm --entrypoint archivebox archivebox-proxy:with-archivebox version
- name: Exercise automatic ArchiveBox capture
shell: bash
run: |
set -euo pipefail
capture_evidence=$(mktemp -d)
capture_collection=$(docker volume create)
trap 'docker logs archivebox-capture || true; docker exec archivebox-capture cat /cache/hooks.log || true; docker rm -f -v archivebox-capture || true; docker volume rm "$capture_collection"' EXIT
docker run --rm --mount "type=volume,source=$capture_collection,target=/data" --entrypoint archivebox archivebox-proxy:with-archivebox init
docker run -d --name archivebox-capture --mount "type=volume,source=$capture_collection,target=/data" --mount "type=volume,source=$capture_collection,target=/archivebox,readonly" -e PLUGINS=screenshot,title,headers -p 127.0.0.1:18880:8080 archivebox-proxy:with-archivebox --bind 0.0.0.0 --archivebox-dir /data --archive /archivebox
for _ in {1..100}; do
if docker cp archivebox-capture:/cache/trust.pem "$capture_evidence/ca.pem" 2>/dev/null; then
break
fi
test "$(docker inspect --format '{{.State.Running}}' archivebox-capture)" = true
sleep 0.1
done
test -s "$capture_evidence/ca.pem"
curl --noproxy '' --fail --silent --show-error --max-time 30 --cacert "$capture_evidence/ca.pem" --proxy http://127.0.0.1:18880 -H 'Accept-Encoding: gzip, deflate, br, zstd' -H 'Sec-Fetch-Mode: navigate' -H 'Sec-Fetch-Dest: document' https://news.ycombinator.com/ask -o /dev/null
for _ in {1..180}; do
if docker cp archivebox-capture:/cache/hooks.jsonl "$capture_evidence/hooks.jsonl" 2>/dev/null; then
if jq -e 'select(.event == "finish" and .returncode == 0)' "$capture_evidence/hooks.jsonl" >/dev/null; then
if docker compose cp proxy:/cache/proxy/hooks.jsonl /tmp/hooks.jsonl 2>/dev/null; then
if jq -e 'select(.event == "finish" and .returncode == 0)' /tmp/hooks.jsonl >/dev/null; then
break
fi
if jq -e 'select(.event == "error" or (.event == "finish" and .returncode != 0))' "$capture_evidence/hooks.jsonl" >/dev/null; then
if jq -e 'select(.event == "error" or (.event == "finish" and .returncode != 0))' /tmp/hooks.jsonl >/dev/null; then
exit 1
fi
fi
test "$(docker inspect --format '{{.State.Running}}' archivebox-capture)" = true
sleep 1
done
jq -e 'select(.event == "finish" and .returncode == 0)' "$capture_evidence/hooks.jsonl" >/dev/null
docker exec -i archivebox-capture uv run --no-project python - <<'PY'
jq -e 'select(.event == "finish" and .returncode == 0)' /tmp/hooks.jsonl >/dev/null
docker compose exec -T proxy uv run --no-project python - <<'PYCODE'
import json
from pathlib import Path
root = Path('/data/archive')
screenshots = list(root.rglob('screenshot/screenshot.png'))
screenshots = list(Path('/data/archive').rglob('screenshot/screenshot.png'))
assert len(screenshots) == 1, screenshots
assert screenshots[0].read_bytes().startswith(b'\x89PNG\r\n\x1a\n')
assert screenshots[0].stat().st_size > 10000
Expand All @@ -136,7 +105,13 @@ jobs:
response = json.loads((snapshot / 'headers/headers.json').read_text())
assert response['status'] == 200
assert response['response_headers']['x-archivebox-proxy-cache'] == 'HIT'
assert (Path('/archivebox') / screenshots[0].relative_to('/data')).is_file()
assert len(Path('/cache/navigations.jsonl').read_text().splitlines()) == 1
assert len(Path('/cache/proxy/navigations.jsonl').read_text().splitlines()) == 1
print('Automatic ArchiveBox capture saved screenshot, title, and cache HIT headers.')
PY
PYCODE
curl --fail --silent --show-error http://localhost:18800/health/ | grep -qx OK
- name: Show logs and stop the deployment
if: always()
run: |
docker compose logs
docker compose exec -T proxy cat /cache/proxy/hooks.log || true
docker compose down --volumes
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
y-forums
w-github
/target/
/dist/
/src/archivebox_proxy/engine/archivebox-proxy-engine
/.venv/
/data/
__pycache__/
Expand Down
73 changes: 0 additions & 73 deletions Dockerfile

This file was deleted.

Loading
Loading