在 git 集线器操作中使用 elm-test
Using elm-test in a git hub action
我想使用 git 集线器操作来测试和构建我的 elm 包,每当将提交推送到主分支时,我的操作 .yml
文件如下所示
name: CI
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Elm environment
uses: JorelAli/setup-elm@v1
with:
# Version of Elm to use. E.g. 0.19.1
elm-version: 0.19.1
- run: |
sudo npm install -g elm-test # this fails
elm-test
elm make
为了测试我想使用 elm-test
可以通过 npm
安装但是命令 sudo npm install -g elm-test
失败
/usr/local/bin/elm-test -> /usr/local/lib/node_modules/elm-test/bin/elm-test
> elmi-to-json@1.3.0 install /usr/local/lib/node_modules/elm-test/node_modules/elmi-to-json
> binwrap-install
ERR Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/elm-test/node_modules/elmi-to-json/unpacked_bin'
at Object.mkdirSync (fs.js:823:3)
at /usr/local/lib/node_modules/elm-test/node_modules/binwrap/binstall.js:46:10
at new Promise (<anonymous>)
at untgz (/usr/local/lib/node_modules/elm-test/node_modules/binwrap/binstall.js:21:10)
at binstall (/usr/local/lib/node_modules/elm-test/node_modules/binwrap/binstall.js:11:12)
at install (/usr/local/lib/node_modules/elm-test/node_modules/binwrap/install.js:20:10)
at Object.install (/usr/local/lib/node_modules/elm-test/node_modules/binwrap/index.js:14:14)
at Object.<anonymous> (/usr/local/lib/node_modules/elm-test/node_modules/binwrap/bin/binwrap-install:18:9)
at Module._compile (internal/modules/cjs/loader.js:955:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10)
at Module.load (internal/modules/cjs/loader.js:811:32)
at Function.Module._load (internal/modules/cjs/loader.js:723:14)
at Function.Module.runMain (internal/modules/cjs/loader.js:1043:10)
at internal/main/run_main_module.js:17:11 {
errno: -13,
syscall: 'mkdir',
code: 'EACCES',
path: '/usr/local/lib/node_modules/elm-test/node_modules/elmi-to-json/unpacked_bin'
}
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.2 (node_modules/elm-test/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! elmi-to-json@1.3.0 install: `binwrap-install`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the elmi-to-json@1.3.0 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/runner/.npm/_logs/2020-02-03T17_50_06_232Z-debug.log
关于如何在 git 集线器操作中安装 elm-test
有什么建议吗?
编辑:
没有 sudo
错误变为
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! syscall access
npm ERR! path /usr/local/lib/node_modules
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR! [Error: EACCES: permission denied, access '/usr/local/lib/node_modules'] {
npm ERR! stack: "Error: EACCES: permission denied, access '/usr/local/lib/node_modules'",
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'access',
npm ERR! path: '/usr/local/lib/node_modules'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/runner/.npm/_logs/2020-02-04T13_41_34_534Z-debug.log
感谢@glennsl,我找到了一个解决方案:指定 npm 在全局安装包的位置。
由于运行该操作的运行器无法访问 /usr/local/lib
npm 无法在全局级别安装任何东西。
解决方案(如 here 所述)是创建一个文件夹作为 “全局” 安装文件夹并配置 npm 以使用它。还需要将新文件夹添加到PATH
环境变量中。
所以我的 yml
文件现在看起来像这样
name: CI
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Elm environment
uses: JorelAli/setup-elm@v1
with:
# Version of Elm to use. E.g. 0.19.1
elm-version: 0.19.1
- run: |
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
PATH=~/.npm-global/bin:$PATH
npm install -g elm-test
elm-test
elm make
感谢@toastal 的评论,我找到了另一个解决方案。那就是使用npm
设置一个package.json
文件,然后用命令
添加elm-test
作为依赖
npm install -D elm-test
您可能还想将 node_modules
添加到 .gitignore
以忽略 npm
的安装文件夹。
然后在 yml
文件中,您可以 运行 安装命令 npm install
和 elm-test
。
然后你可以用
调用它
./node_modules/elm-test/bin/elm-test
我的 yml
文件现在看起来像这样
name: Tests
on: [push]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Elm environment
uses: JorelAli/setup-elm@v1
with:
# Version of Elm to use. E.g. 0.19.1
elm-version: 0.19.1
- name: install npm dependencies
run: npm install
- name: Test
run: ./node_modules/elm-test/bin/elm-test
- name: check documentation
run: |
elm make --docs=docs.json
rm docs.json
我想使用 git 集线器操作来测试和构建我的 elm 包,每当将提交推送到主分支时,我的操作 .yml
文件如下所示
name: CI
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Elm environment
uses: JorelAli/setup-elm@v1
with:
# Version of Elm to use. E.g. 0.19.1
elm-version: 0.19.1
- run: |
sudo npm install -g elm-test # this fails
elm-test
elm make
为了测试我想使用 elm-test
可以通过 npm
安装但是命令 sudo npm install -g elm-test
失败
/usr/local/bin/elm-test -> /usr/local/lib/node_modules/elm-test/bin/elm-test
> elmi-to-json@1.3.0 install /usr/local/lib/node_modules/elm-test/node_modules/elmi-to-json
> binwrap-install
ERR Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/elm-test/node_modules/elmi-to-json/unpacked_bin'
at Object.mkdirSync (fs.js:823:3)
at /usr/local/lib/node_modules/elm-test/node_modules/binwrap/binstall.js:46:10
at new Promise (<anonymous>)
at untgz (/usr/local/lib/node_modules/elm-test/node_modules/binwrap/binstall.js:21:10)
at binstall (/usr/local/lib/node_modules/elm-test/node_modules/binwrap/binstall.js:11:12)
at install (/usr/local/lib/node_modules/elm-test/node_modules/binwrap/install.js:20:10)
at Object.install (/usr/local/lib/node_modules/elm-test/node_modules/binwrap/index.js:14:14)
at Object.<anonymous> (/usr/local/lib/node_modules/elm-test/node_modules/binwrap/bin/binwrap-install:18:9)
at Module._compile (internal/modules/cjs/loader.js:955:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10)
at Module.load (internal/modules/cjs/loader.js:811:32)
at Function.Module._load (internal/modules/cjs/loader.js:723:14)
at Function.Module.runMain (internal/modules/cjs/loader.js:1043:10)
at internal/main/run_main_module.js:17:11 {
errno: -13,
syscall: 'mkdir',
code: 'EACCES',
path: '/usr/local/lib/node_modules/elm-test/node_modules/elmi-to-json/unpacked_bin'
}
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.2 (node_modules/elm-test/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! elmi-to-json@1.3.0 install: `binwrap-install`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the elmi-to-json@1.3.0 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/runner/.npm/_logs/2020-02-03T17_50_06_232Z-debug.log
关于如何在 git 集线器操作中安装 elm-test
有什么建议吗?
编辑:
没有 sudo
错误变为
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! syscall access
npm ERR! path /usr/local/lib/node_modules
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR! [Error: EACCES: permission denied, access '/usr/local/lib/node_modules'] {
npm ERR! stack: "Error: EACCES: permission denied, access '/usr/local/lib/node_modules'",
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'access',
npm ERR! path: '/usr/local/lib/node_modules'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/runner/.npm/_logs/2020-02-04T13_41_34_534Z-debug.log
感谢@glennsl,我找到了一个解决方案:指定 npm 在全局安装包的位置。
由于运行该操作的运行器无法访问 /usr/local/lib
npm 无法在全局级别安装任何东西。
解决方案(如 here 所述)是创建一个文件夹作为 “全局” 安装文件夹并配置 npm 以使用它。还需要将新文件夹添加到PATH
环境变量中。
所以我的 yml
文件现在看起来像这样
name: CI
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Elm environment
uses: JorelAli/setup-elm@v1
with:
# Version of Elm to use. E.g. 0.19.1
elm-version: 0.19.1
- run: |
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
PATH=~/.npm-global/bin:$PATH
npm install -g elm-test
elm-test
elm make
感谢@toastal 的评论,我找到了另一个解决方案。那就是使用npm
设置一个package.json
文件,然后用命令
elm-test
作为依赖
npm install -D elm-test
您可能还想将 node_modules
添加到 .gitignore
以忽略 npm
的安装文件夹。
然后在 yml
文件中,您可以 运行 安装命令 npm install
和 elm-test
。
然后你可以用
./node_modules/elm-test/bin/elm-test
我的 yml
文件现在看起来像这样
name: Tests
on: [push]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Elm environment
uses: JorelAli/setup-elm@v1
with:
# Version of Elm to use. E.g. 0.19.1
elm-version: 0.19.1
- name: install npm dependencies
run: npm install
- name: Test
run: ./node_modules/elm-test/bin/elm-test
- name: check documentation
run: |
elm make --docs=docs.json
rm docs.json