🐎

wsl環境でgithub actionsを試す

2025/01/16に公開

github actions実行ファイルをつくったはいいけど、ちゃんとできているか試したいけどgithub.comで動作確認を何度もしたくない...
というわけでローカル環境でテストします

環境

windows
wlsにdocker engineがインストール済み
ubuntuにdocker engineをインストールする方法と同じようにインストールしました。
https://docs.docker.com/engine/install/ubuntu/#install-using-the-repository

インストール

wsl環境にログイン後、actをインストール
https://nektosact.com/introduction.html

> curl -OL https://github.com/nektos/act/releases/download/v0.2.70/act_Linux_x86_64.tar.gz

解凍

> tar -zxvf act_Linux_x86_64.tar.gz
> curl -OL https://github.com/nektos/act/releases/download/v0.2.70/act_Linux_x86_64.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100 7075k  100 7075k    0     0  1610k      0  0:00:04  0:00:04 --:--:-- 2046k
> ls -l
total 7148
-rw-r--r--  1 root root 7245419 Dec 27 14:36 act_Linux_x86_64.tar.gz
> tar -zxvf act_Linux_x86_64.tar.gz
LICENSE
README.md
act

actが実行できることを確認

> ./act --version
act version 0.2.70

ためす

eslintチェックのために作成したワークフローを動かしてみます。
リモートリポジトリを作成していないため、オプションwatchを指定して
最後のstepsまで実行させます。
実行時、ディレクトリは対象プロジェクト(.githubフォルダがあるディレクトリ)にします。

> cd ~/test/sandbox/my-app
> ../../../act -W .github/workflows/lint.yml --watch

初回時のみダウンロードするイメージサイズを選択します。

$  ../../../act -W ~/test/sandbox/my-app/.github/workflows/lint.yml
INFO[0000] Using docker host 'unix:///var/run/docker.sock', and daemon socket 'unix:///var/run/docker.sock' 
? Please choose the default image you want to use with act:
  - Large size image: ca. 17GB download + 53.1GB storage, you will need 75GB of free disk space, snapshots of GitHub Hosted Runners without snap and pulled docker images
  - Medium size image: ~500MB, includes only necessary tools to bootstrap actions and aims to be compatible with most actions
  - Micro size image: <200MB, contains only NodeJS required to bootstrap actions, doesn't work with all actions

Default image and other options can be changed manually in /home/original/.config/act/actrc (please refer to https://github.com/nektos/act#configuration for additional information about file structure) Micro

実行結果

INFO[0000] Using docker host 'unix:///var/run/docker.sock', and daemon socket 'unix:///var/run/docker.sock' 
WARN[0000] unable to get git repo (githubInstance: github.com; remoteName: origin, repoPath: /home/original/test/sandbox/my-app): remote not found 
[my-app lint check/build] 🚀  Start image=node:16-buster-slim
[my-app lint check/build]   🐳  docker pull image=node:16-buster-slim platform= username= forcePull=true
[my-app lint check/build]   🐳  docker create image=node:16-buster-slim platform= entrypoint=["tail" "-f" "/dev/null"] cmd=[] network="host"
[my-app lint check/build]   🐳  docker run image=node:16-buster-slim platform= entrypoint=["tail" "-f" "/dev/null"] cmd=[] network="host"
[my-app lint check/build]   🐳  docker exec cmd=[node --no-warnings -e console.log(process.execPath)] user= workdir=
[my-app lint check/build] unable to get git repo (githubInstance: github.com; remoteName: origin, repoPath: /home/original/test/sandbox/my-app): remote not found
[my-app lint check/build] unable to get git repo (githubInstance: github.com; remoteName: origin, repoPath: /home/original/test/sandbox/my-app): remote not found
[my-app lint check/build] unable to get git repo (githubInstance: github.com; remoteName: origin, repoPath: /home/original/test/sandbox/my-app): remote not found
[my-app lint check/build]   ☁  git clone 'https://github.com/actions/setup-node' # ref=v4
[my-app lint check/build] unable to get git repo (githubInstance: github.com; remoteName: origin, repoPath: /home/original/test/sandbox/my-app): remote not found
[my-app lint check/build] unable to get git repo (githubInstance: github.com; remoteName: origin, repoPath: /home/original/test/sandbox/my-app): remote not found
[my-app lint check/build] unable to get git repo (githubInstance: github.com; remoteName: origin, repoPath: /home/original/test/sandbox/my-app): remote not found
[my-app lint check/build] unable to get git repo (githubInstance: github.com; remoteName: origin, repoPath: /home/original/test/sandbox/my-app): remote not found
[my-app lint check/build] unable to get git repo (githubInstance: github.com; remoteName: origin, repoPath: /home/original/test/sandbox/my-app): remote not found
[my-app lint check/build] unable to get git repo (githubInstance: github.com; remoteName: origin, repoPath: /home/original/test/sandbox/my-app): remote not found
[my-app lint check/build] ⭐ Run Main checkout
[my-app lint check/build] unable to get git repo (githubInstance: github.com; remoteName: origin, repoPath: /home/original/test/sandbox/my-app): remote not found
[my-app lint check/build] unable to get git repo (githubInstance: github.com; remoteName: origin, repoPath: /home/original/test/sandbox/my-app): remote not found
[my-app lint check/build]   🐳  docker cp src=/home/original/test/sandbox/my-app/. dst=/home/original/test/sandbox/my-app
[my-app lint check/build]   ✅  Success - Main checkout
[my-app lint check/build] unable to get git repo (githubInstance: github.com; remoteName: origin, repoPath: /home/original/test/sandbox/my-app): remote not found
[my-app lint check/build] unable to get git repo (githubInstance: github.com; remoteName: origin, repoPath: /home/original/test/sandbox/my-app): remote not found
[my-app lint check/build] unable to get git repo (githubInstance: github.com; remoteName: origin, repoPath: /home/original/test/sandbox/my-app): remote not found
[my-app lint check/build] unable to get git repo (githubInstance: github.com; remoteName: origin, repoPath: /home/original/test/sandbox/my-app): remote not found
[my-app lint check/build] unable to get git repo (githubInstance: github.com; remoteName: origin, repoPath: /home/original/test/sandbox/my-app): remote not found
[my-app lint check/build] ⭐ Run Main set up Node.js
[my-app lint check/build] unable to get git repo (githubInstance: github.com; remoteName: origin, repoPath: /home/original/test/sandbox/my-app): remote not found
[my-app lint check/build] unable to get git repo (githubInstance: github.com; remoteName: origin, repoPath: /home/original/test/sandbox/my-app): remote not found
[my-app lint check/build] unable to get git repo (githubInstance: github.com; remoteName: origin, repoPath: /home/original/test/sandbox/my-app): remote not found
[my-app lint check/build]   🐳  docker cp src=/home/original/.cache/act/actions-setup-node@v4/ dst=/var/run/act/actions/actions-setup-node@v4/
[my-app lint check/build]   🐳  docker exec cmd=[/usr/local/bin/node /var/run/act/actions/actions-setup-node@v4/dist/setup/index.js] user= workdir=
[my-app lint check/build]   💬  ::debug::isExplicit: 
[my-app lint check/build]   💬  ::debug::explicit? false
[my-app lint check/build]   💬  ::debug::isExplicit: 20.18.1
[my-app lint check/build]   💬  ::debug::explicit? true
[my-app lint check/build]   💬  ::debug::evaluating 1 versions
[my-app lint check/build]   💬  ::debug::matched: 20.18.1
[my-app lint check/build]   💬  ::debug::checking cache: /opt/hostedtoolcache/node/20.18.1/x64
[my-app lint check/build]   💬  ::debug::Found tool in cache node 20.18.1 x64
| Found in cache @ /opt/hostedtoolcache/node/20.18.1/x64
[my-app lint check/build]   ❓  ::group::Environment details
| node: v20.18.1
| npm: 10.8.2
| yarn: 1.22.19
[my-app lint check/build]   ❓  ::endgroup::
[my-app lint check/build]   ❓ add-matcher /run/act/actions/actions-setup-node@v4/.github/tsc.json
[my-app lint check/build]   ❓ add-matcher /run/act/actions/actions-setup-node@v4/.github/eslint-stylish.json
[my-app lint check/build]   ❓ add-matcher /run/act/actions/actions-setup-node@v4/.github/eslint-compact.json
[my-app lint check/build]   ✅  Success - Main set up Node.js
[my-app lint check/build]   ⚙  ::set-output:: node-version=v20.18.1
[my-app lint check/build]   ⚙  ::add-path:: /opt/hostedtoolcache/node/20.18.1/x64/bin
[my-app lint check/build] unable to get git repo (githubInstance: github.com; remoteName: origin, repoPath: /home/original/test/sandbox/my-app): remote not found
[my-app lint check/build] unable to get git repo (githubInstance: github.com; remoteName: origin, repoPath: /home/original/test/sandbox/my-app): remote not found
[my-app lint check/build] unable to get git repo (githubInstance: github.com; remoteName: origin, repoPath: /home/original/test/sandbox/my-app): remote not found
[my-app lint check/build] unable to get git repo (githubInstance: github.com; remoteName: origin, repoPath: /home/original/test/sandbox/my-app): remote not found
[my-app lint check/build] unable to get git repo (githubInstance: github.com; remoteName: origin, repoPath: /home/original/test/sandbox/my-app): remote not found
[my-app lint check/build] ⭐ Run Main install npm package
[my-app lint check/build] unable to get git repo (githubInstance: github.com; remoteName: origin, repoPath: /home/original/test/sandbox/my-app): remote not found
[my-app lint check/build] unable to get git repo (githubInstance: github.com; remoteName: origin, repoPath: /home/original/test/sandbox/my-app): remote not found
[my-app lint check/build] unable to get git repo (githubInstance: github.com; remoteName: origin, repoPath: /home/original/test/sandbox/my-app): remote not found
[my-app lint check/build] unable to get git repo (githubInstance: github.com; remoteName: origin, repoPath: /home/original/test/sandbox/my-app): remote not found
[my-app lint check/build]   🐳  docker exec cmd=[bash -e /var/run/act/workflow/2] user= workdir=
| 
| added 376 packages, and audited 377 packages in 52s
| 
| 144 packages are looking for funding
|   run `npm fund` for details
| 
| 1 moderate severity vulnerability
| 
| To address all issues, run:
|   npm audit fix --force
| 
| Run `npm audit` for details.
[my-app lint check/build]   ✅  Success - Main install npm package
[my-app lint check/build] unable to get git repo (githubInstance: github.com; remoteName: origin, repoPath: /home/original/test/sandbox/my-app): remote not found
[my-app lint check/build] unable to get git repo (githubInstance: github.com; remoteName: origin, repoPath: /home/original/test/sandbox/my-app): remote not found
[my-app lint check/build] unable to get git repo (githubInstance: github.com; remoteName: origin, repoPath: /home/original/test/sandbox/my-app): remote not found
[my-app lint check/build] unable to get git repo (githubInstance: github.com; remoteName: origin, repoPath: /home/original/test/sandbox/my-app): remote not found
[my-app lint check/build] unable to get git repo (githubInstance: github.com; remoteName: origin, repoPath: /home/original/test/sandbox/my-app): remote not found
[my-app lint check/build] ⭐ Run Main lint check
[my-app lint check/build] unable to get git repo (githubInstance: github.com; remoteName: origin, repoPath: /home/original/test/sandbox/my-app): remote not found
[my-app lint check/build] unable to get git repo (githubInstance: github.com; remoteName: origin, repoPath: /home/original/test/sandbox/my-app): remote not found
[my-app lint check/build] unable to get git repo (githubInstance: github.com; remoteName: origin, repoPath: /home/original/test/sandbox/my-app): remote not found
[my-app lint check/build] unable to get git repo (githubInstance: github.com; remoteName: origin, repoPath: /home/original/test/sandbox/my-app): remote not found
[my-app lint check/build]   🐳  docker exec cmd=[bash -e /var/run/act/workflow/3] user= workdir=
| 
| > my-app@0.1.0 lint
| > next lint
| 
| Attention: Next.js now collects completely anonymous telemetry regarding usage.
| This information is used to shape Next.js' roadmap and prioritize features.
| You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:
| https://nextjs.org/telemetry
| 
| 
| ./src/app/layout.tsx
| 1:31  Error: Strings must use singlequote.  @stylistic/quotes
| 1:37  Error: Extra semicolon.  @stylistic/semi
| 2:35  Error: Strings must use singlequote.  @stylistic/quotes
| 2:53  Error: Extra semicolon.  @stylistic/semi
| 3:8  Error: Strings must use singlequote.  @stylistic/quotes
| 3:23  Error: Extra semicolon.  @stylistic/semi
| 6:13  Error: Strings must use singlequote.  @stylistic/quotes
| 7:13  Error: Strings must use singlequote.  @stylistic/quotes
| 8:3  Error: Extra semicolon.  @stylistic/semi
| 11:13  Error: Strings must use singlequote.  @stylistic/quotes
| 12:13  Error: Strings must use singlequote.  @stylistic/quotes
| 13:3  Error: Extra semicolon.  @stylistic/semi
| 16:10  Error: Strings must use singlequote.  @stylistic/quotes
| 17:16  Error: Strings must use singlequote.  @stylistic/quotes
| 18:2  Error: Extra semicolon.  @stylistic/semi
| 23:29  Error: Unexpected separator (;).  @stylistic/member-delimiter-style
| 33:4  Error: Extra semicolon.  @stylistic/semi
| 
| ./src/app/page.tsx
| 1:19  Error: Strings must use singlequote.  @stylistic/quotes
| 1:31  Error: Extra semicolon.  @stylistic/semi
| 17:35  Error: `{" "}` must be placed on a new line  @stylistic/jsx-one-expression-per-line
| 17:36  Error: Strings must use singlequote.  @stylistic/quotes
| 100:4  Error: Extra semicolon.  @stylistic/semi
| 
| info  - Need to disable some ESLint rules? Learn more here: https://nextjs.org/docs/app/api-reference/config/eslint#disabling-rules
[my-app lint check/build]   ❌  Failure - Main lint check
[my-app lint check/build] exitcode '1': failure
[my-app lint check/build] unable to get git repo (githubInstance: github.com; remoteName: origin, repoPath: /home/original/test/sandbox/my-app): remote not found
[my-app lint check/build] unable to get git repo (githubInstance: github.com; remoteName: origin, repoPath: /home/original/test/sandbox/my-app): remote not found
[my-app lint check/build] unable to get git repo (githubInstance: github.com; remoteName: origin, repoPath: /home/original/test/sandbox/my-app): remote not found
[my-app lint check/build] unable to get git repo (githubInstance: github.com; remoteName: origin, repoPath: /home/original/test/sandbox/my-app): remote not found
[my-app lint check/build] unable to get git repo (githubInstance: github.com; remoteName: origin, repoPath: /home/original/test/sandbox/my-app): remote not found
[my-app lint check/build] 🏁  Job failed
[my-app lint check/build] unable to get git repo (githubInstance: github.com; remoteName: origin, repoPath: /home/original/test/sandbox/my-app): remote not found
Error: Job 'build' failed

すべてのstepsが処理できました。

補足

github actionsは基本リモートリポジトリがあること前提のため、
リモートリポジトリがないプロジェクトに対してactを実行するとエラーメッセージが出るようです。

unable to get git repo (githubInstance: github.com; remoteName: origin, repoPath: /home/original/test/sandbox/my-app): remote not found

Discussion