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)
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.
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.
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

:clap:
Thanks for the image idea @fwilhe.
Although if there is a solution for a more lightweight image that would be cool as the install took about an hour ;-;
WARNING - this image is >18GB
If you don't have fast internet, this is gonna take way more than 1 hour ๐
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?
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?
Alright, I have a plan:
cat for ENTRYPOINTdocker exec into that job container/github path that will be shared with the one-off containersWhat's a one-off container? Some steps will NOT run in the job container:
uses: docker://..... will have a one-off container with the job volume attacheduses: action/name where action/name has an action.yaml with runs.using == 'docker' will have a one-off container with the job volume attachedWill work on this in coming days on branch https://github.com/nektos/act/tree/ISS-86
looks solid
thanks a bunch :)