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

local js action fails (uses: ./) #185

Closed
helaili opened this issue Apr 3, 2020 · 4 comments · Fixed by #371
Closed

local js action fails (uses: ./) #185

helaili opened this issue Apr 3, 2020 · 4 comments · Fixed by #371
Labels
area/workflow Relating to workflow definitions kind/bug Something isn't working
Projects

Comments

@helaili
Copy link

helaili commented Apr 3, 2020

When developing a new JS action, I like to create a workflow within the same repo so I can test various use cases. In such a case, I reference the local action with - uses: ./ as defined in the documentation

on: [push]
jobs:
  hello_world_job:
    runs-on: ubuntu-latest
    name: A job to say hello
    steps:
      - name: Checkout
        uses: actions/checkout@v2
      - uses: ./
        with:
          who-to-greet: 'Mona the Octocat'

Unfortunately, it fails with the following error:

internal/modules/cjs/loader.js:628
|     throw err;
|     ^
| 
| Error: Cannot find module '/github/workspace/aws-instance-ripper/index.js'
|     at Function.Module._resolveFilename (internal/modules/cjs/loader.js:625:15)
|     at Function.Module._load (internal/modules/cjs/loader.js:527:27)
|     at Function.Module.runMain (internal/modules/cjs/loader.js:839:10)
|     at internal/main/run_main_module.js:17:11 {
|   code: 'MODULE_NOT_FOUND',
|   requireStack: []
| }

It does work if I move the action code in an action subfolder and use it with - uses: ./action.

This can be reproduced with the sample hello-world-javascript-action, you just need to add a basic workflow.

@cplee cplee changed the title local js action fails local js action fails (uses: ./) Apr 16, 2020
@cplee cplee added area/workflow Relating to workflow definitions kind/bug Something isn't working labels Apr 16, 2020
@cplee cplee added this to To do in Roadmap Apr 16, 2020
@cplee cplee moved this from To do to Ready to Work in Roadmap Apr 23, 2020
@rdlf0
Copy link

rdlf0 commented May 10, 2020

Hey, I had the same issue, but already posted my solution in #228. You need to provide the path parameter to the actions/checkout action in order to get the correct path when the code is copied to the container.

@macdaddyaz
Copy link

Sorry if this belongs in a new issue, but I'm experiencing a very similar problem in a similar situation. I'll be glad to open a new issue, if that would be better....

It looks like act is not resolving relative paths within local actions the same way that GitHub Actions does.

For instance, I have a workflow referencing a local action....

      - name: Auth0 deployment
        uses: ./.github/actions/auth0-deploy

And my action.yml file in that directory looks like this:

name: auth0-deploy
inputs:
  prod-branch:
    description: Name of the branch to consider "production". Default is "master".
    required: false
runs:
  using: node12
  main: 'dist/index.js'

When I run locally, I get the same kind of stack trace:

| internal/modules/cjs/loader.js:628
|     throw err;
|     ^
| 
| Error: Cannot find module '/github/workspace/dist/index.js'
|     at Function.Module._resolveFilename (internal/modules/cjs/loader.js:625:15)
|     at Function.Module._load (internal/modules/cjs/loader.js:527:27)
|     at Function.Module.runMain (internal/modules/cjs/loader.js:839:10)
|     at internal/main/run_main_module.js:17:11 {
|   code: 'MODULE_NOT_FOUND',
|   requireStack: []
| }

However, this configuration is valid per the GHA documentation, and the workflow runs successfully on GitHub. act should be resolving my action's main script to /github/workspace/.github/actions/auth0-deploy/dist/index.js, instead of just /github/workspace/dist/index.js.

@github-actions
Copy link
Contributor

Issue is stale and will be closed in 7 days unless there is new activity

@github-actions github-actions bot added the stale label Aug 23, 2020
Roadmap automation moved this from Ready to Work to Done Aug 31, 2020
@JerkyTreats
Copy link

Can this be reopened? I've confirmed this use case breaks for me:

      - name: checkout foo
        uses: actions/checkout@v2
        path: .github/actions/foo

      - name: use foo
        uses: ./.github/actions/foo

Gets

Error: open /path/to/users/pwd/.github/actions/foo/action.yaml: no such file or directory

should resolve to

github/workspace/.github/actions/foo/action.yaml

@cplee cplee reopened this Sep 14, 2020
Roadmap automation moved this from Done to In progress Sep 14, 2020
@cplee cplee removed the stale label Sep 14, 2020
jromero added a commit to jromero/act that referenced this issue Sep 25, 2020
Fixes nektos#185

Signed-off-by: Javier Romero <root@jromero.codes>
jromero added a commit to jromero/act that referenced this issue Sep 28, 2020
Fixes nektos#185

Signed-off-by: Javier Romero <root@jromero.codes>
jromero added a commit to jromero/act that referenced this issue Sep 28, 2020
Fixes nektos#185

Signed-off-by: Javier Romero <root@jromero.codes>
Roadmap automation moved this from In progress to Done Sep 29, 2020
cplee pushed a commit that referenced this issue Sep 29, 2020
Fixes #185

Signed-off-by: Javier Romero <root@jromero.codes>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/workflow Relating to workflow definitions kind/bug Something isn't working
Projects
Roadmap
  
Done
Development

Successfully merging a pull request may close this issue.

5 participants