Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support tsc to check actions/github-script steps #389

Open
nomeata opened this issue Jan 10, 2024 · 1 comment
Open

Support tsc to check actions/github-script steps #389

nomeata opened this issue Jan 10, 2024 · 1 comment

Comments

@nomeata
Copy link

nomeata commented Jan 10, 2024

This suggest is a sibling of #55. I see more an more actions migrating from simple bash to actions/github-script, but thus losing any actionlint guardrails. It would be great if actionlint could somehow check actions/github-script scripts.

In #55 eslint was suggested, but there are good reasons why supporting that is not easy.

I wonder if using the typescript compiler to check the JavaScript snippts (given that JavaScript is a subset of typescript) would work? Maybe it is already preinstalled?

One hurdle is of course that the snipptes passed to actions/github-script probably has to be wrapped in a type-annotated function declaration that matches what actions/github-script is doing; I don’t know how hard and how reliable that is.

@nomeata nomeata changed the title Support tsc Support tsc to check actions/github-script steps Jan 10, 2024
github-merge-queue bot pushed a commit to leanprover/lean4 that referenced this issue Jan 15, 2024
I keep messing things up, so time for some guard rails, so check them
using
[actionlint](https://github.com/raven-actions/actionlint).

This also runs [shellcheck](https://www.shellcheck.net/) on the files.
Shellcheck
is a bit picky about putting double quotes around variables, and will
flag many
cases where we know it’s safe, but why not simply always write the safer
variant.

Unfortunately, actionlint does not (yet) check `actions/github-script`
scripts, which is
unfortunate. Maybe they will in the future
(rhysd/actionlint#389)
@rhysd
Copy link
Owner

rhysd commented Mar 6, 2024

It would be nice to have. Thanks for your suggestion.

Though it is hard to check the script when ${{ }} is used in it, I think we can skip checking such script.

Things unclear for me:

  • Some non-standard global objects are defined. They need separate type definitions which typically sit in types directories of npm packages. How can we pass the type definitions to tsc on checking scripts?
  • How is TypeScript's --checkJs useful? I don't have experience to use the option.
  • Scripts can be a single return statement like script: return "hello". How can we handle this?

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

No branches or pull requests

2 participants