首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >为“硬帽子”项目设置CI Github操作

为“硬帽子”项目设置CI Github操作
EN

Ethereum用户
提问于 2022-04-07 15:16:03
回答 1查看 1.1K关注 0票数 1

我有一个草帽项目,并希望添加使用github操作的CI工作流。这是我的github存储库。https://github.com/kimiro34/ens-registry-setup

.github/workflow/main.yml文件如下所示

代码语言:javascript
运行
复制
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文件。

代码语言:javascript
运行
复制
{
  "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操作来测试我的硬件项目吗?

EN

回答 1

Ethereum用户

发布于 2022-09-28 20:15:03

您可以同时运行node:startdeploy命令。

尝试以下几点:

代码语言:javascript
运行
复制
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
票数 1
EN
页面原文内容由Ethereum提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://ethereum.stackexchange.com/questions/125695

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档