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

Add glob bindings #10

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Conversation

maxdeviant
Copy link
Member

Description of the change
This PR add bindings for the @actions/glob package.

Resolves #2.


Checklist:

  • Added the change to the changelog's "Unreleased" section with a link to this PR and your username
  • Linked any existing issues or proposals that this pull request should close
  • Updated or added relevant documentation in the README and/or documentation directory
  • Added a test for the contribution (if applicable)

@maxdeviant
Copy link
Member Author

A couple of things:

  1. I'm having trouble running the tests locally. I tried spago test, but the tests fail:
Starting test action...
::set-env name=testkey::test
::set-output name=testoutput::test
::add-mask::testoutput
::add-path::/test/path
::error::Input required and not supplied: testinput
::echo::off
::debug::Testing debug
::error::Testing error
::warning::Testing warning
Testing info
::group::testgroup
::endgroup::
::save-state name=teststate::test
::group::testGroup
In testGroup
::debug::isExplicit: 
::debug::explicit? false
::error::Expected RUNNER_TOOL_CACHE to be defined
Done running test action.
::endgroup::
No errors in restoreCache
No errors in ToolCache
[command]/usr/bin/touch test.txt
[command]/bin/pwd
/Users/maxdeviant/projects/purescript-github-actions-toolkit
[command]/bin/pwd -L
/Users/maxdeviant/projects/purescript-github-actions-toolkit
No errors in io
[command]/bin/pwd -L
/Users/maxdeviant/projects/purescript-github-actions-toolkit
No errors in exec
[error] Tests failed: exit code: 1

I presume there's something I'm missing?

  1. @actions/glob exposes the following function that returns an AsyncGenerator<string, void> which I'm not sure how to type in PureScript:
  /**
   * Returns files and directories matching the glob patterns.
   *
   * Order of the results is not guaranteed.
   */
  globGenerator(): AsyncGenerator<string, void>

Any thoughts?

@colinwahl
Copy link
Member

colinwahl commented Oct 15, 2020

@maxdeviant Thanks for working on this!

You're not the only one who couldn't figure out how to run it locally :D Since the github-actions-toolkit library expects to be run in a github workflow, it's hard to run it locally. I tried https://github.com/nektos/act but couldn't get it to work. I eventually just went with the suggestion in https://docs.github.com/en/free-pro-team@latest/actions/creating-actions/creating-a-javascript-action#example-using-a-private-action to test this out - it'll run the test on push to a branch or pull request. Sadly it doesn't run on forks for some reason, but I can see that the tests are passing for your latest commit (the check next to the commit hash).

I know it's not ideal to have to push to the PR to see if tests are working, but we'll squash-and-merge so it should be ok.

As for the AsyncGenerator... I'm not sure how to type this either. I can look into it more tomorrow, but here's what I found out from a bit of digging:

The docs are kind of lacking for AsyncGenerator, from what I can tell from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference. We could try using the docs from Generator and assuming that the Async just means they are async functions instead of regular functions. That might get us somewhere.
If that is true, then I think we could have an opaque type and something like
next :: AsyncGenerator -> Aff { done :: Boolean, value :: String }
return :: AsyncGenerator -> { done :: Boolean, value :: String }
throw :: AsyncGenerator -> Error -> Aff { done :: Boolean, value :: String }

Edit: I found a few more docs that seem to indicate something like this would work:
https://github.com/microsoft/TypeScript/blob/344dba8809e82ff74b9616c872fa5a781c264d42/src/lib/es2018.asyncgenerator.d.ts
https://github.com/microsoft/TypeScript/blob/237b6f61f645680143b326a5b58b15acc216aa4b/src/lib/es2015.iterable.d.ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Implement bindings to the @actions/glob package
2 participants