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

Can't install npm dependencies #86

Closed
finleygn opened this issue Feb 20, 2020 · 10 comments · Fixed by #98
Closed

Can't install npm dependencies #86

finleygn opened this issue Feb 20, 2020 · 10 comments · Fixed by #98

Comments

@finleygn
Copy link

I've been trying to get my github actions working locally with act (really cool tool btw) but I can't seem to get npm working.

Heres an example workflow to show the problem:

name: Test Somethin

on:
  pull_request:
    branches:
      - develop

jobs:
  do-stuff:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v1
        with:
          node-version: 12
          registry-url: https://registry.npmjs.org/

      - name: Install Dependencies
        run: npm install
        env:
          NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

Running command act -j do-stuff -s NPM_TOKEN=XXXX_XXXX_XXXX
I get this output

[Test Somethin/do-stuff] ⭐  Run actions/checkout@v2
[Test Somethin/do-stuff]   ✅  Success - actions/checkout@v2
[Test Somethin/do-stuff] ⭐  Run actions/setup-node@v1
[Test Somethin/do-stuff]   ☁  git clone 'https://github.com/actions/setup-node' # ref=v1
[Test Somethin/do-stuff]   🐳  docker pull node:12-alpine
[Test Somethin/do-stuff]   🐳  docker run image=node:12-alpine entrypoint=[] cmd=["node" "/github/home//setup-node985111831/dist/index.js"]
[Test Somethin/do-stuff]   💬  ::debug::isExplicit:
[Test Somethin/do-stuff]   💬  ::debug::explicit? false
[Test Somethin/do-stuff]   💬  ::debug::evaluating 0 versions
[Test Somethin/do-stuff]   💬  ::debug::match not found
[Test Somethin/do-stuff]   💬  ::debug::evaluating 378 versions
[Test Somethin/do-stuff]   💬  ::debug::matched: v12.16.1
[Test Somethin/do-stuff]   💬  ::debug::isExplicit: 12.16.1
[Test Somethin/do-stuff]   💬  ::debug::explicit? true
[Test Somethin/do-stuff]   💬  ::debug::checking cache: /home/actions/cache/node/12.16.1/x64
[Test Somethin/do-stuff]   💬  ::debug::not found
[Test Somethin/do-stuff]   💬  ::debug::Downloading https://nodejs.org/dist/v12.16.1/node-v12.16.1-linux-x64.tar.gz
[Test Somethin/do-stuff]   💬  ::debug::Downloading /home/actions/temp/1a31fd1a-a499-4e30-9d38-531f090e84b2
[Test Somethin/do-stuff]   💬  ::debug::download complete
[Test Somethin/do-stuff]   💬  ::debug::Caching tool node 12.16.1 x64
[Test Somethin/do-stuff]   💬  ::debug::source dir: /home/actions/temp/692cf33e-d4ab-4040-a505-f1e4bd026f89/node-v12.16.1-linux-x64
[Test Somethin/do-stuff]   💬  ::debug::destination /home/actions/cache/node/12.16.1/x64
[Test Somethin/do-stuff]   💬  ::debug::finished caching tool
[Test Somethin/do-stuff]   ⚙  ::add-path:: /home/actions/cache/node/12.16.1/x64/bin
[Test Somethin/do-stuff]   💬  ::debug::Setting auth in /github/workspace/.npmrc
[Test Somethin/do-stuff]   ⚙  ::set-env:: NPM_CONFIG_USERCONFIG=/github/workspace/.npmrc
[Test Somethin/do-stuff]   ⚙  ::set-env:: NODE_AUTH_TOKEN=XXXXX-XXXXX-XXXXX-XXXXX
[Test Somethin/do-stuff]   ✅  Success - actions/setup-node@v1
[Test Somethin/do-stuff] ⭐  Run Install Dependencies
[Test Somethin/do-stuff]   🐳  docker pull ubuntu:18.04
[Test Somethin/do-stuff]   🐳  docker run image=ubuntu:18.04 entrypoint=[] cmd=["bash" "--noprofile" "--norc" "-eo" "pipefail" "/github/home/.temp-script-262291398"]
[Test Somethin/do-stuff]   ❌  Failure - Install Dependencies
Error: exit with `FAILURE`: 127

In the verbose output the verbose output says npm: command not found which causes the exit.


I thought maybe it was the same issue as #85 but after following @davidalger's steps the output was the same. (I'm also on macOS)

@fwilhe
Copy link

fwilhe commented Feb 20, 2020

Have you tried configuring another image? I had some (limited) success with act -P ubuntu-latest=node:12. Might also depend on if you rely on the default node version or use the setup node action.

I'm wondering about the default home dir /github/workspace. Is this a leftover from the "old" actions? My understanding is that the "new" ones use /home/actions.

@fwilhe
Copy link

fwilhe commented Feb 20, 2020

Interesting thing: In this repo https://github.com/SAP/project-piper-action

this job works

  units:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - run: npm ci
    - run: npm test

but this does not

  dist-is-up-to-date:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - run: npm ci
    - run: npm run package
    - run: git diff --name-only --exit-code

It seems to fail in installing packages, I don't understand why.

@finleygn
Copy link
Author

If the Github action docs are up to date /github/workspace should be fine
https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners#filesystems-on-github-hosted-runners

there was an update to the readme recently (b48a0ef) saying to use the image ubuntu-latest=nektos/act-environments-ubuntu:18.04 so will try that and see how it goes

@finleygn
Copy link
Author

image
👏

Thanks for the image idea @fwilhe.

@finleygn
Copy link
Author

Although if there is a solution for a more lightweight image that would be cool as the install took about an hour ;-;

@KingDarBoja
Copy link

WARNING - this image is >18GB

If you don't have fast internet, this is gonna take way more than 1 hour 😆

@cplee
Copy link
Contributor

cplee commented Feb 21, 2020

I think the issue is actually how I implemented the containers around steps that use actions. There is a separate step used for run steps and uses steps...this means anything you do in the uses step isn't necessarily available in the later run step.

In your case, setup-node installs NodeJS in a separate container from the npm install step.

I'm guessing this is a misunderstanding on my part about how GitHub Actions works...is it your understanding that the uses steps should NOT run in a separate container?

cplee added a commit that referenced this issue Feb 21, 2020
@finleygn
Copy link
Author

not entirely sure but it was my understanding that uses steps can persist stuff

looking through https://github.com/actions/setup-go it seems like it just interacts directly with the runner?

@cplee
Copy link
Contributor

cplee commented Feb 21, 2020

Alright, I have a plan:

  • Each job will get 1 container created and will just use cat for ENTRYPOINT
  • Each step will result in a docker exec into that job container
  • The job container will have a volume created for /github path that will be shared with the one-off containers

What's a one-off container? Some steps will NOT run in the job container:

  • Any step with uses: docker://..... will have a one-off container with the job volume attached
  • Any step with uses: action/name where action/name has an action.yaml with runs.using == 'docker' will have a one-off container with the job volume attached

Will work on this in coming days on branch https://github.com/nektos/act/tree/ISS-86

@finleygn
Copy link
Author

looks solid

thanks a bunch :)

@cplee cplee mentioned this issue Feb 25, 2020
@cplee cplee closed this as completed in #98 Feb 25, 2020
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 a pull request may close this issue.

4 participants