Skip to content

Verify input schemas if present#39

Closed
Sviatozar Petrenko (foxt451) wants to merge 12 commits into
masterfrom
feat/apify-vis
Closed

Verify input schemas if present#39
Sviatozar Petrenko (foxt451) wants to merge 12 commits into
masterfrom
feat/apify-vis

Conversation

@foxt451
Copy link
Copy Markdown

Closes #27

Runs on unitTest job. Installs apify cli and runs apify vis (mainly taken from existing husky on actor repos), but conditionally checks presence of ./actors/ or .actor/ folders

Tested locally with act

Comment thread .github/workflows/pr-build-test.yaml Outdated
# let apify cli initialize its config to avoid race conditions with xargs
apify --version >/dev/null 2>&1
if [ -d ./.actor ]; then
apify vis
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vis is outdated, we should use validate-schema. It should now validate all schemas

Comment thread .github/workflows/pr-build-test.yaml Outdated
run: npm run lint

- name: Install Apify CLI
run: npm install -g apify-cli
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit worried this will bloat the action runtime a lot. Maybe we could let it work with the current cache but I don't have a good idea how. The current cache is based on hash(package-lock.json) so in this case it will just load the local node modules and will not update the cache after this install since there is no change in the key (I think). JuanGalilea any ideas?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

apify-cli into devDependencies? since that allows us to use it in scripts without knip getting mad at us.
We use the CLI a lot so i dont see a big issue in just adding it to the projects.

This is my knee-jerk solution but i haven't thought much about it. Seems reasonable enough at a glance.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a big fan of that, we would need to add it to all projects and it would bloat all regular installs forever. That's not worth for this check (we do it locally in pre-commit anyway) by me.

But let's first test how long this install takes. If it is like 5 sec, I'm fine with it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just realized these are the shared actions 😢.

Still like the devDependencies idea but its waaaaaayyy harder to implement damn

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming CLI is much bigger than things like knip. If not, then Juan's solution would be ok since we already have all these other tools in devDeps

Copy link
Copy Markdown
Contributor

@JuanGalilea JuanGalilea May 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe its worth it to think about custom images?

Interesting. Probably not worth for just npm install apify-cli but maybe we can find more things. I assume there will be some downsides, maybe slower starts.
Lukas Krivka

we could get some more mileage like with tools like knip and some other use everywhere but just for scripts tools.

Definitively out of scope for this PR

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it takes 26s, the most out of all steps. But I think the Juan's idea is reasonable, especially since we use apify-cli in a pre-commit, so it's an actual dev dep

Copy link
Copy Markdown
Contributor

@metalwarrior665 Lukáš Křivka (metalwarrior665) May 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you test how much bigger node_modules are with it vs without it (there will be some overlap in sub dependencies)? and what is the install time difference?

Copy link
Copy Markdown
Author

@foxt451 Sviatozar Petrenko (foxt451) May 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The node_modules size difference is noticeable, 257 - 174 = 83 (in actor for testing actions). It adds 253 packages. In two different action runs the install without apify-cli was a couple of seconds slower, would I need to batch test? Also, what do you think of npx --yes apify approach below vs skipping the step? (I see your reply)

Comment thread .github/workflows/pr-build-test.yaml Outdated
fi
if [ -d ./actors ]; then
# `apify vis` fail code is changed from 1 to 255 so xargs aborts on first error.
cd ./actors && ls | xargs -P 8 -I {} sh -c 'cd {} && apify vis || exit 255'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldn't error logs get all mangled with -P 8?
I get the speedup here but people read the failing check logs and if you have errors on >1 actor this would just tangle all the logs afaik.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use it like this for a long time and it fail very rarely. If it does you can dig deeper. Definitely not worth to do it 1 by 1 by maybe the parallelization options in GitHub runner is limited and this will be slow anyway...

Comment thread .github/workflows/pr-build-test.yaml Outdated
apify vis
fi
if [ -d ./actors ]; then
# `apify vis` fail code is changed from 1 to 255 so xargs aborts on first error.
Copy link
Copy Markdown
Contributor

@JuanGalilea JuanGalilea May 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i like the solution but i would prefer for all to run and then get hit by ALL the errors, not fix one just to get hit by another.

@JuanGalilea
Copy link
Copy Markdown
Contributor

love that you are doing CI work and taking some ownership of it ❤️

Comment thread .github/workflows/pr-build-test.yaml
Comment thread .github/workflows/pr-build-test.yaml Outdated
run: |
if [ ! -d "node_modules/apify-cli" ]; then
echo "::warning::apify-cli is not installed as an npm dependency. Skipping schema validation."
exit 0
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can run the initialization command as:

npx --yes apify --version

that way it gets installed on the first command (if missing) and you dont have to exit 0.

It should still show the warning tho since teams should add it to devDependencies. Best of both worlds no?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, but it would inflate the runtime of repos using this action who haven't added this to their deps by >20 seconds, is it okay? cc Lukáš Křivka (@metalwarrior665)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also, for knip and prettier we also just skip the step if not installed, so skipping is in line with the present approach. should we stick to it here too?

Copy link
Copy Markdown
Contributor

@JuanGalilea JuanGalilea May 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tru, but knip is nice to have.
Having the schemas right is important, so its not apples to apples.
Also with the +20s CI increase, each team can easily solve it by just adding it to devDeps so its not like they are just stuck with the bad perf.

Whichever you go for is OK tho, its more opinion based than right/wrong way.

PS: But if you decide to have it do nothing, you should skip the step instead of doing exit 0.
That requires to do the checking in a previous step, emit output and use that in an if clause for this one.

PS2: additionally, if you skip there will be some repos where they don't realize they have the check inactive, since the whole action was green so it must be OK. Whereas in the other version you always get the check so green actually is OK. (even if it took 20s longer)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually giving this anothrr thought, I would drop this completely. Unlike the other checks, this one is hard validated by platform on build. And since we ru this unit test and platform builds in parallel, it just adds to the runtime.without much benefit. So I think keeping it in pre commit only is better

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

giving a second thought I agree. I'll close if Juan doesn't have some reasons to keep it

@foxt451 Sviatozar Petrenko (foxt451) marked this pull request as draft May 13, 2026 14:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add input schema validation to PR checks

3 participants