我有一个草帽项目,并希望添加使用github操作的CI工作流。这是我的github存储库。https://github.com/kimiro34/ens-registry-setup
.github/workflow/main.yml
文件如下所示
name: Node.js CI
on:
push:
branches: [main]
pull_request:
branches: [main]
env:
NETWORK: $NETWORK
RPC_URL_ZNX_TESTNET: $RPC_URL_ZNX_TESTNET
RPC_URL_ZNX_MAINNET: $RPC_URL_ZNX_MAINNET
MNEMONIC: $MNEMONIC
ROPSTEN_URL: $ROPSTEN_URL
jobs:
start-hardhat-node:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.x]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- run: npm install
- run: npm run node:start
- run: npm run test
这是我的package.json
文件。
{
"name": "hardhat-project",
"scripts": {
"node:start": "npx hardhat node",
"test": "npx hardhat test --network localhost",
"ci": "scripts/test.sh",
"compile": "npx hardhat compile",
"deploy": "npx hardhat run --network deploy scripts/deploy.ts",
"deploy:hardhat": "npx hardhat run --network localhost scripts/deploy.ts"
},
"devDependencies": {},
"dependencies": {
"@nomiclabs/hardhat-ethers": "^2.0.5",
"@nomiclabs/hardhat-etherscan": "^3.0.3",
"@nomiclabs/hardhat-waffle": "^2.0.3",
"@typechain/ethers-v5": "^7.2.0",
"@typechain/hardhat": "^2.3.1",
"@types/chai": "^4.3.0",
"@types/mocha": "^9.1.0",
"@types/node": "^12.20.47",
"@typescript-eslint/eslint-plugin": "^4.33.0",
"@typescript-eslint/parser": "^4.33.0",
"chai": "^4.3.6",
"dotenv": "^10.0.0",
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.5.0",
"eslint-config-standard": "^16.0.3",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^3.4.1",
"eslint-plugin-promise": "^5.2.0",
"ethereum-waffle": "^3.4.4",
"ethers": "^5.6.2",
"hardhat-gas-reporter": "^1.0.8",
"prettier": "^2.6.2",
"prettier-plugin-solidity": "^1.0.0-beta.13",
"solhint": "^3.3.7",
"solidity-coverage": "^0.7.20",
"ts-node": "^10.7.0",
"typechain": "^5.2.0",
"typescript": "^4.6.3",
"hardhat": "^2.9.3",
"@ensdomains/ens-contracts": "^0.0.11",
"eth-ens-namehash": "^2.0.8"
}
}
问题是在运行npm run node:start
cmd npm run test
从不启动之后。我指的是目前的状况。https://github.com/kimiro34/ens-registry-setup/actions https://github.com/kimiro34/ens-registry-setup/runs/5870753222?check_套间_focus=true
我理解这是因为运行'npx节点‘的npm run node:start
运行的是本地块链,它不会停止。
所以可以使用github操作来测试我的硬件项目吗?
发布于 2022-09-28 20:15:03
您可以同时运行node:start
和deploy
命令。
尝试以下几点:
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install packages
uses: actions/setup-node@v3
with:
node-version: '18.x'
- run: yarn --ignore-scripts
shell: bash
- name: Create local node and deploy
run: |
yarn hardhat node &
yarn hardhat run scripts/deploy.ts --network localhost
- name: Run Tests
run: yarn hardhat test
https://ethereum.stackexchange.com/questions/125695
复制相似问题