Repository navigation
Conversation
|
Thanks. Considering this is sort of a library inside a library, I would say there are 3 options:
I think 3 will be quite a bit of work unless we find a good angle so I'm leaning 2 but ofc understand that not having to maintain yet another package is good for you. We will think it through |
Thanks @metalwarrior665 for the quick feedback. "Library inside a library" is fair, but the package already spans a vitest library, a CLI (
Which part would read as a second way, creating the Actor or asserting on it? The assertion side is the existing one. The harness reuses
Two problems. "A few things" would in practice be Worth noting what a second consumer of the shared code already found:
That's what I tried to do, within reason. If you see a concrete seam I missed, point at it.
That doesn't work for a library because we need to pin Actor dependencies. The point of our tests is to run the Actor against the library code in the checkout (the PR branch) rather than a published version. A pre-registered Actor called from a test runs whatever was built last, so every test run has to build first, from source that carries the unpublished packages (tarballs plus Once every run builds with injected artifacts, a pre-existing Actor gives you nothing, and "only rebuild what changed" is moot because every change to the library changes every Actor. For context, all three repos (crawlee, JS SDK, Python SDK) already build their test Actors from the checkout, each with its own hand-rolled runner. This PR exists to unify that mechanism so that adding a test, or moving one between repos, is cheap, and to reuse it for the JS client and actor-scraper next.
It isn't only good for us. Splitting overlapping functionality across two packages owned by two teams is a net loss for both.
Appreciated. I know this landed out of nowhere, but the crawlee and SDK majors would benefit greatly from this, so I'd be grateful for a quick turnaround. |
|
Notes from talking to @JuanGalilea:
|
|
additionaly, this might make it benefitial for our own actor-oriented libraries (like |
|
A key difference between On my machine, the tarball approach is roughly 8 times faster, which, projected to crawlee's e2e tests means roughly an hour of time spent re-installing dev dependencies and building crawlee. |
There was a problem hiding this comment.
it all seems reasonable, my main gripes are on how its exposed to users.
This is more aimed to be used to test tools used to build actors instead of actors themselves, so i'd expose it as a completely separate thing (like its done with apify-test-tools/harness).
See comments below for what i think needs changing
| @@ -1,2 +1,4 @@ | |||
| export { describe, testActor, testStandbyActor, ExpectStatic } from './lib/lib.js'; | |||
| export { RunTestResult } from './lib/run-test-result.js'; | |||
| export { useHarness, type VitestHarness } from './lib/harness-vitest.js'; | |||
There was a problem hiding this comment.
do we want this on the main export?
Harness is a pretty niche usecase imo
There was a problem hiding this comment.
Yeah, I arrived at the same conclusion actually. The harness is gone and the ad-hoc actors are tested using the existing testActor interface.
| `TESTER_APIFY_TOKEN` can be the token of any account with enough memory for the runs. To run only some tests, pass a specific file instead of `test/platform`, or filter by | ||
| name with vitest's `-t <name>` when running vitest directly. See [Running locally](cli.md#running-locally) for the full flow. | ||
|
|
||
| ## Throwaway Actors for library repositories |
There was a problem hiding this comment.
i would throw this whole section to its own doc file.
Harness is a pretty different usecase since its not about testing the actor itself in a way.
There we could explain the idea and use of it without confusing users that just want to test their actors.
There was a problem hiding this comment.
After the latest changes, this is about building ad-hoc Actors for later use via testActor. But I can still see it in its own doc file. Thoughts?
JuanGalilea
left a comment
There was a problem hiding this comment.
meant to request changes on the previous one 😓
skill issue much?
|
Let's not make any changes yet pls. I want to focus now on clearing a few pending PRs and then we will sync about this in few days. |
testActor
metalwarrior665
left a comment
There was a problem hiding this comment.
I think it is fine like this, commented a few potential refactors. The maintenance burden seems relatively small. Let's wait for others to review.
JuanGalilea
left a comment
There was a problem hiding this comment.
all i could uncover, but it was taking too long to review :sadge:
|
Thanks for the feedback @JuanGalilea @metalwarrior665 @gytelio! I believe that everything has been addressed, please re-check. |
|
Pls wait with the merge after #252 which should merge on Monday as that one is already quite big release. We will communicate this separately. |
Discussed on slack: https://apify.slack.com/archives/C0AMFHY27FB/p1794319738563179 --- Turns out that the file changed so much that git doesn't even think it's the same one anymore (I renamed it) 😭 It is a lot of changes and mostly clauded so let me know if anything looks wrong to you :P Changes: - **Duplicate check**: A cheap deduplication agent runs first, which will make sure the issue gets deduplicated from the already opened GH issues. - The recurring issues will now be nicely and deterministically reported in a **recurring** comment that will get edited each time and updated with the new failures. ~- **Renamed** `public_platform-tests-claude-investigate-and-fix.yaml` => `public_platform-tests-claude-investigate.yaml`.~ It's a breaking change. ~Both the workflow is renamed~ and the NPM_TOKEN removal is a breaking change.
add postfix comment option so teams can tag specific people (probably themselves) on stale warning comments
Lets
testActortake an ad-hoc Actor: one that isn't inapify-test-tools.config.jsonand is built from files in the repository when the test first runs it. This is for library repositories (crawlee, apify-sdk-js, actor-scraper), whose tests need Actors built against the checkout rather than a published version. See "Ad-hoc Actors" indocs/lib.md.defineActor(name, { source, token, memory, env, permissions, syncDelayMs })describes the Actor;testActor(actor, …)builds it on the firstrun()and pins every run to that build. The Actor is created if missing and kept afterwardstokenis explicit: the Actor is built, run and cleaned up with it, and lives under its account. An ad-hoc Actor is never inACTOR_BUILDS, so it can't get a token the way other Actors do in v1. A missing token fails that Actor's tests onlybuild-from-local:ActorSourcecollects the files,ApifyBuilder.buildFromLocalSourcezips, uploads and builds version0.98.build-from-localnow uses both too. Those files moved tobin/from-local-files/ActorSource.dirs(...)overlays directories,.pin(packs)pointspackage.jsonatpnpm packtarballs of the code under test (npmoverridesorpnpm.overrides),.with(step)applies a custom stepinlineMain(filename, fn)is a step that ships a top-level function of the test file as the Actor's entry point. It's type-checked on its own with the project'stsc, so anything borrowed from the rest of the file fails as TS2304. Atsconfig.jsonthat doesn't cover the generated file is an error toobuild-from-localas well: each zip is stored under a name with its hash, and a build that started from somebody else's upload is detected throughactVersion.tarballUrl, aborted and repeated. Ad-hoc runs pass memory and permission level themselves instead of reading them from the Actorbuild-from-localand ad-hoc Actors alike: the signed URL on the version would otherwise keep the source downloadable. Version0.98can't be rebuilt from the Console afterwards (closes Delete build source code after 'build-from-local' #274)delete-old-buildssweeps up zips an interrupted build left behind after a week, and the undated one from before zips were datedsyncDelayMsreplaces the 20 s wait after a run for ad-hoc Actors;run()takes noinputand then sends none;buildActorandpollUntilare exportedNotes for review
adds
./ad-hocto theexportsmap of feat!: v1 transition #252. That entry point doesn't import vitest, so it works inglobalSetupnew runtime deps
oxc-parserandoxc-transform, used only byinlineMainand loaded only when it runs;typescriptbecomes an optional peer dependency for the same reason. They're native, so they stay out of the CLI bundle:ActorSourcelives inbin/,inlineMaininlib/the ignored-files lookup passes its paths to
git ls-filesin chunks of 1000. All at once, a checkout withnode_moduleshits the argv limit (related to improvecollectNonIgnoredFiles#187)vitest.config.tssetstestTimeoutto 30 s: the tests that spawn the CLI time out at the default 5 s when the suite runs in parallel, on master tootwo suites creating the same ad-hoc Actor for the very first time at the same moment still collide, and one fails
the diff shows unrelated changes in
docs/workflows.mdandpublic_stale-issues.yaml: master's last three commits, which this branch has and feat!: v1 transition #252 doesn't yettest/e2e/ad-hoc.e2e.test.tsruns under the existing sandbox token. The e2e suites of apify-sdk-js (test: Restructure e2e tests apify-sdk-js#863) and crawlee (refactor: Restructure e2e tests using apify-test-tools crawlee#4375) run on feat: Support running Actors under test locally #254follow-up: feat: Support running Actors under test locally #254, running ad-hoc Actors locally with the same
mainand matchers