TL;DR
自分が利用しているNode.jsのバージョンが、actions/node-versions
でまだ対応されていたかったことによるようです。
18系だとキャッシュされました。
状況
個人開発しているプロジェクトのCIを設定するにあたり、Node.jsのインストールが必要だったので、setup-node
のアクションを利用しました。
# 自分が作成したワークフローファイルより抜粋 name: Install Node.js uses: actions/setup-node@v3 with: node-version: '19.4'
ただ、setup-node
のREADMEにはOptionally downloading and caching distribution of the requested Node.js version, and adding it to the PATH
という記載があるものの、
実行のたびにNode.jsのキャッシュが見つからずにダウンロードしていたので、なぜキャッシュが使えていないのだろう?を調査しました。
// 実行ログ Run actions/setup-node@v3 /usr/bin/docker exec f7656153548b0c0c871c87f547a809d02cea3ae16dbd0ba4734738022cf761da sh -c "cat /etc/*release | grep ^ID" ##[debug]ID=debian ##[debug]Running JavaScript Action with default external tool: node16 ##[debug]isExplicit: ##[debug]explicit? false ##[debug]isExplicit: 14.21.2 ##[debug]explicit? true ##[debug]isExplicit: 16.19.0 ##[debug]explicit? true ##[debug]isExplicit: 18.13.0 ##[debug]explicit? true ##[debug]evaluating 3 versions ##[debug]match not found Attempting to download 19.4... ##[debug]No manifest cached ##[debug]Getting manifest from actions/node-versions@main ##[debug]set auth ##[debug]check 18.13.0 satisfies 19.4 ##[debug]check 18.12.1 satisfies 19.4 ##[debug]check 18.12.0 satisfies 19.4 // 中略 ##[debug]check 8.1.0 satisfies 19.4 ##[debug]check 8.0.0 satisfies 19.4 ##[debug]check 6.17.1 satisfies 19.4 Not found in manifest. Falling back to download directly from Node ##[debug]evaluating 555 versions ##[debug]matched: v19.4.0 Acquiring 19.4.0 - x64 from https://nodejs.org/dist/v19.4.0/node-v19.4.0-linux-x64.tar.gz ##[debug]Downloading https://nodejs.org/dist/v19.4.0/node-v19.4.0-linux-x64.tar.gz // 以下略
結論
自分が利用しているNode.jsのバージョンが19.4だったことに起因していました。
取得元となっているactions/node-versions
側で、まだ対応されていないバージョンのようです。
調査内容
ログに
##[debug]Getting manifest from actions/node-versions@main
が出ていたのでmanifestの取得箇所を確認してみると、actions/node-versions
から取得していそうです。(該当箇所)
private getManifest(): Promise<tc.IToolRelease[]> { core.debug('Getting manifest from actions/node-versions@main'); return tc.getManifestFromRepo( 'actions', 'node-versions', this.nodeInfo.auth, 'main' ); }
そこでactions/node-versions
を見に行くと、18.13.0が最新で、バージョン19にはまだ対応していませんでした。
自分が利用している19.4はactions/node-versions
から取得できないことにより、都度https://nodejs.org/dist/v19.4.0/node-v19.4.0-linux-x64.tar.gzからダウンロードする形になっていたようでした。
バージョン18を指定して実行してみると、キャッシュが取得され、実行時間も短くなりました。
// 実行ログ Run actions/setup-node@v3 /usr/bin/docker exec c32933f9e63a5f41642ba7d0ce44bc6929286d7f1bbddf57c64c26b562e4ef3f sh -c "cat /etc/*release | grep ^ID" ##[debug]ID=debian ##[debug]Running JavaScript Action with default external tool: node16 ##[debug]isExplicit: ##[debug]explicit? false ##[debug]isExplicit: 14.21.2 ##[debug]explicit? true ##[debug]isExplicit: 16.19.0 ##[debug]explicit? true ##[debug]isExplicit: 18.13.0 ##[debug]explicit? true ##[debug]evaluating 3 versions ##[debug]matched: 18.13.0 ##[debug]checking cache: /__t/node/18.13.0/x64 ##[debug]Found tool in cache node 18.13.0 x64 Found in cache @ /__t/node/18.13.0/x64 ::group::Environment details Environment details ##[add-matcher]/__w/_actions/actions/setup-node/v3/.github/tsc.json ##[debug]Added matchers: 'tsc'. Problem matchers scan action output for known warning or error strings and report these inline. ##[add-matcher]/__w/_actions/actions/setup-node/v3/.github/eslint-stylish.json ##[debug]Added matchers: 'eslint-stylish'. Problem matchers scan action output for known warning or error strings and report these inline. ##[add-matcher]/__w/_actions/actions/setup-node/v3/.github/eslint-compact.json ##[debug]Added matchers: 'eslint-compact'. Problem matchers scan action output for known warning or error strings and report these inline. ##[debug]Node Action run completed with exit code 0 ##[debug]Set output node-version = v18.13.0 ##[debug]Finishing: Install Node.js