Is GitHub Actions caching the ~/.npm directory effective?

I used the cache for the npm directory and it didn’t work as expected.

I tested it with packages up to the 100th most popular Npm ranking, but I couldn’t see much difference in time with npm ci.

cache enabled: 48s 40s 26s 27s
cashe disabled: 35s 30s 38s 51s

The repository is as follows.

The workflow is as follows.

name: インストールキャッシュテスト (install cache test)
    name: インストールキャッシュテスト( install cache test)
    runs-on: ubuntu-latest
      - name: リポジトリのチェックアウト( repos checkout )
        uses: actions/checkout@v2
      - name: npmパッケージをキャッシュ ( cache npm package )
        uses: actions/cache@v2
          path: ~/.npm
          key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
          restore-keys: |
            ${{ runner.os }}-npm-
      - name: npmインストール (npm install )
        run: npm ci

Is there something wrong with my workflow? Or is there a reason why it doesn’t speed up?

Looks good to me. Did you try npm install instead of npm ci?

There is also a caching limit of 5GB per repo. Maybe you’re hitting that.