Ten*_*eff 25 github yarnpkg github-actions
我有一个 Yarn monorepo(工作区),有 2 个包:后端(Node.js/TypeScript)和前端(React/Typescript)。
\n/package.json(已修剪)
{\n "workspaces": [\n "backend",\n "frontend"\n ],\n}\nRun Code Online (Sandbox Code Playgroud)\n我正在尝试添加与 GitHub Actions 的持续集成,并尝试使用它actions/cache@v2来缓存 Yarn 缓存目录和所有项目'node_modules目录
.github/workflows/CI.yml(已修剪)
steps:\n - uses: actions/checkout@v2\n\n - name: Get yarn cache directory path\n id: yarn-cache-dir-path\n run: |\n echo "::set-output name=dir::$(yarn cache dir)"\n echo "::set-output name=version::$(yarn -v)"\n\n - name: Use Node.js ${{ matrix.node-version }}\n uses: actions/setup-node@v2\n with:\n node-version: ${{ matrix.node-version }}\n\n - uses: actions/cache@v2\n with:\n path: |\n ${{ steps.yarn-cache-dir-path.outputs.dir }}\n '**/node_modules'\n '**/.eslintcache'\n key: ${{ runner.os }}-yarn-${{ steps.yarn-cache-dir-path.outputs.version }}-${{ hashFiles('**/yarn.lock') }}\n\n - name: Install packages\n run: yarn install --frozen-lockfile\nRun Code Online (Sandbox Code Playgroud)\n我收到缓存已存储并在连续运行中重新使用:
\nkey: Linux-yarn-1.22.10-143fef95c7228810cf502305eff3be1cbc468dc8a3e0b153a4311c0250aaef6f\nReceived 158645465 of 175422681 (90.4%), 151.3 MBs/sec\nReceived 175422681 of 175422681 (100.0%), 138.1 MBs/sec\nCache Size: ~167 MB (175422681 B)\n/usr/bin/tar --use-compress-program zstd -d -xf /home/runner/work/_temp/08363700-9a23-447e-a80e-6f3dbec6068f/cache.tzst -P -C /home/runner/work/path\nCache restored successfully\nCache restored from key: Linux-yarn-1.22.10-143fef95c7228810cf502305eff3be1cbc468dc8a3e0b153a4311c0250aaef6f\nRun Code Online (Sandbox Code Playgroud)\n但yarn仍尝试解决依赖关系:
yarn install --frozen-lockfile\nshell: /usr/bin/bash -e {0}\nyarn install v1.22.10\n[1/4] Resolving packages...\n[2/4] Fetching packages...\ninfo fsevents@2.3.2: The platform "linux" is incompatible with this module.\ninfo "fsevents@2.3.2" is an optional dependency and failed compatibility check. Excluding it from installation.\ninfo fsevents@2.3.1: The platform "linux" is incompatible with this module.\ninfo "fsevents@2.3.1" is an optional dependency and failed compatibility check. Excluding it from installation.\ninfo fsevents@1.2.13: The platform "linux" is incompatible with this module.\ninfo "fsevents@1.2.13" is an optional dependency and failed compatibility check. Excluding it from installation.\n[3/4] Linking dependencies...\n.....\n[4/4] Building fresh packages...\nDone in 40.07s.\nRun Code Online (Sandbox Code Playgroud)\n我的期望是它应该像在我的本地计算机上一样工作:
\n$ yarn --frozen-lockfile\nyarn install v1.22.10\n[1/4] Resolving packages...\nsuccess Already up-to-date.\n\xe2\x9c\xa8 Done in 0.72s.\nRun Code Online (Sandbox Code Playgroud)\n我能否以某种方式改进我的配置以满足预期结果或预期的 GitHub Actions 行为?
\n更新:尝试使用以下路径时:
\n path: |\n '**/node_modules'\n '**/.eslintcache'\nRun Code Online (Sandbox Code Playgroud)\n或者:
\n path: |\n 'node_modules'\n '*/node_modules'\n '**/.eslintcache'\nRun Code Online (Sandbox Code Playgroud)\n缓存大小为 22 B。可能不匹配任何node_modules匹配
Ten*_*eff 24
经过大量的试验和错误,从s 中删除引号path似乎已经解决了问题。并且缓存的大小几乎增加了一倍
- uses: actions/cache@v2
id: yarn-cache
with:
path: |
**/node_modules
**/.eslintcache
${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
Run Code Online (Sandbox Code Playgroud)
Run actions/cache@v2
Received 213909504 of 305669200 (70.0%), 203.6 MBs/sec
Received 305669200 of 305669200 (100.0%), 185.6 MBs/sec
Cache Size: ~292 MB (305669200 B)
/usr/bin/tar --use-compress-program zstd -d -xf /home/runner/work/_temp/2e2d2a1d-04d7-44c3-829e-ec4e8faf394b/cache.tzst -P -C /home/runner/work/path
Cache restored successfully
Cache restored from key: Linux-yarn-143fef95c7228810cf502305eff3be1cbc468dc8a3e0b153a4311c0250aaef6f
Run Code Online (Sandbox Code Playgroud)
Run yarn install --frozen-lockfile
yarn install v1.22.10
[1/4] Resolving packages...
success Already up-to-date.
Done in 0.96s.
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
24677 次 |
| 最近记录: |