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

Error: Cannot find module '@actions/core' #3

Closed
rgarrigue opened this issue May 25, 2020 · 6 comments
Closed

Error: Cannot find module '@actions/core' #3

rgarrigue opened this issue May 25, 2020 · 6 comments

Comments

@rgarrigue
Copy link

Hi there

I'm using https://github.com/nektos/act for local crafting / debuguing of my GitHub Actions.

It's πŸ’₯ 'ing like this

[Tests/tests] ⭐  Run Setup git credentials
[Tests/tests]   ☁  git clone 'https://github.com/fusion-engineering/setup-git-credentials' # ref=v2
[Tests/tests]   🐳  docker cp src=/home/remy/.cache/act/fusion-engineering-setup-git-credentials@v2 dst=/actions/
| internal/modules/cjs/loader.js:985
|   throw err;
|   ^
| 
| Error: Cannot find module '@actions/core'
| Require stack:
| - /actions/fusion-engineering-setup-git-credentials@v2/lib/main.js
|     at Function.Module._resolveFilename (internal/modules/cjs/loader.js:982:15)
|     at Function.Module._load (internal/modules/cjs/loader.js:864:27)
|     at Module.require (internal/modules/cjs/loader.js:1044:19)
|     at require (internal/modules/cjs/helpers.js:77:18)
|     at Object.<anonymous> (/actions/fusion-engineering-setup-git-credentials@v2/lib/main.js:18:27)
|     at Module._compile (internal/modules/cjs/loader.js:1158:30)
|     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
|     at Module.load (internal/modules/cjs/loader.js:1002:32)
|     at Function.Module._load (internal/modules/cjs/loader.js:901:14)
|     at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12) {
|   code: 'MODULE_NOT_FOUND',
|   requireStack: [
|     '/actions/fusion-engineering-setup-git-credentials@v2/lib/main.js'
|   ]
| }

Can you give me an hint about what went wrong ?

If you want to reproduce, I'm using act 0.2.8 (~ latest) with the command act -P ubuntu-latest=nektos/act-environments-ubuntu:18.04 -s GIT_CREDENTIALS=https://me:mytoken@github.com (warning, this docker image is ~18G big) and here's my workflow

name: Tests

on:
  push:
    tags:
      - "*"

jobs:
  tests:

    runs-on: ubuntu-latest
    strategy:
      matrix:
        python: [3.7]

    steps:
      - uses: actions/checkout@v2

      - name: Setup Python
        uses: actions/setup-python@v2
        with:
          python-version: ${{ matrix.python }}

      - name: Cache pip
        uses: actions/cache@master
        with:
          path: ~/.cache/pip
          key: ${{ runner.os }}-pip
          restore-keys: |
            ${{ runner.os }}-pip

      - name: Install Tox
        run: pip install tox

      - name: Cache Tox
        uses: actions/cache@master
        with:
          path: ~/.tox
          key: ${{ runner.os }}-tox-${{ hashFiles('**/tox.ini') }}
          restore-keys: |
            ${{ runner.os }}-tox-

      - name: Install Tox
        run: pip install tox

      - name: Setup git credentials
        uses: fusion-engineering/setup-git-credentials@v2
        with:
          credentials: ${{secrets.GIT_CREDENTIALS}}

      - name: Run Tox
        run: tox
@o0Ignition0o
Copy link

Hey there :)

Might be totally wrong here, but I happen to reproduce the issue on act, but not when I run the action in a CI/CD pipeline.

It seems to be related to this known bug.

I'm going to play with it a bit and hopefully figure out a dirty workaround, but it probably won't be fun

@de-vri-es
Copy link
Owner

Alright, I'm interested to know if you find a solution. But if I gather correctly it is a problem with nektos/act that affects other actions too, rather than a problem with setup-git-credentials?

@o0Ignition0o
Copy link

o0Ignition0o commented Jun 21, 2020

Not sure if the PR will be accepted, but nektos/act#288 should hopefully fix it :)

It seems like a docker cp actually reads the .gitignore and refuses to copy git ignored files, which is... unfortunate given we need node_modules to run things, and node_modules are often in a .gitignore file ^^'

So long story short, it's probably affecting a lot of act users on various repos, but I'm no CI/CD veteran so I can't say for sure ^^

@de-vri-es
Copy link
Owner

Thanks for investigating!

Your analysis makes sense. The node_modules folder is ignored so that dependency aren't checked in to git, but if they're excluded from the docker container that is certainly a problem.

Sound to me like docker is doing something questionable here, especially since there doesn't seem to be an opt-out from this behavior [1].

Considering that there is no feasible work-around that we can implement on our side, I'm closing this issue here. Let's hope nektos/act#288 lands soon.

Thanks again for investigating, and thanks for sending a fix to act :)

[1] https://docs.docker.com/engine/reference/commandline/cp/#options

@o0Ignition0o
Copy link

o0Ignition0o commented Jun 23, 2020

just FYI the act pull request landed, so I hope it helps :)
If you wanna try again @rgarrigue, please add an install git step before as shown in this test, and if it doesn't work please shoot me a dm maybe I can help :)

@de-vri-es
Copy link
Owner

Awesome, thanks for letting us know :) And nice to see a test with setup-git-credentials in there too ❀️

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

3 participants