feat(apify): .actor/ scaffold (.actor/src/main.py + Dockerfile entrypoint swap + make actor-build)

The Apify platform expects the actor entry at .actor/src/main.py. Until
now Pry used `python -m apify_actor` via Dockerfile.apify, which works
but doesn't match the documented convention used by every other actor
on the platform.

  - Add .actor/src/main.py as a thin asyncio wrapper around apify_actor.main()
  - Swap Dockerfile.apify ENTRYPOINT to the new path
  - Add `make actor-build` Makefile target that regenerates
    .actor/input_schema.json from the ApifySchemaBuilder fluent API
    (urls, max_pages, timeout, output_format, crawl)

Conflicts: none — .actor/actor.json (full version:3.0.0 schema with
input/output blocks inline) already existed from earlier work; this
commit adds the conventional entry path and a build hook that emits
the schema as a sibling file. Apify Console accepts either form.
This commit is contained in:
opencode 2026-07-06 20:36:17 +07:00
parent cf376ab3a8
commit 372ce228f4
4 changed files with 90 additions and 12 deletions

View file

@ -1,21 +1,22 @@
SHELL := /bin/bash
PYTHON := python3
.PHONY: help install dev lint format typecheck test security check clean precommit ci
.PHONY: help install dev lint format typecheck test security check clean precommit ci actor-build
help:
@echo "Pry Makefile"
@echo ""
@echo " install Install dependencies"
@echo " dev Start dev server"
@echo " lint Run ruff check"
@echo " format Run ruff format"
@echo " typecheck Run mypy"
@echo " test Run pytest"
@echo " security Run bandit + safety"
@echo " check Full audit (lint + typecheck + test)"
@echo " clean Remove build artifacts"
@echo " precommit Run ruff + mypy + bandit"
@echo " install Install dependencies"
@echo " dev Start dev server"
@echo " lint Run ruff check"
@echo " format Run ruff format"
@echo " typecheck Run mypy"
@echo " test Run pytest"
@echo " security Run bandit + safety"
@echo " check Full audit (lint + typecheck + test)"
@echo " clean Remove build artifacts"
@echo " precommit Run ruff + mypy + bandit"
@echo " actor-build Regenerate .actor/input_schema.json from apify_schema.py"
install:
pip install -e ".[dev]"
@ -46,3 +47,9 @@ clean:
precommit: lint format typecheck security
ci: precommit test
# Regenerate .actor/input_schema.json from the ApifySchemaBuilder fluent API.
# Pin schema version + title so Apify Console recognises the file.
actor-build:
$(PYTHON) -c "from apify_schema import ApifySchemaBuilder, StringField, IntegerField, BooleanField, EnumField; b = ApifySchemaBuilder('Pry Scraper', 'Scrape any website with Pry\\'s 12-tier fallback chain.'); b.add_array('urls', 'URLs to scrape', {'type': 'string', 'pattern': '^https?://'}, required=True).add_integer('max_pages', 'Max pages', default=10, minimum=1, maximum=1000).add_integer('timeout', 'Timeout (seconds)', default=30, minimum=5, maximum=120).add_enum('output_format', 'Output format', ['markdown','html','text'], default='markdown').add_boolean('crawl', 'Crawl linked pages', default=False); import json, pathlib; pathlib.Path('.actor').mkdir(exist_ok=True); pathlib.Path('.actor/input_schema.json').write_text(json.dumps(b.build_input_schema(), indent=2))"
@echo "wrote .actor/input_schema.json"