zeta-chain / protocol-contracts

Protocol contracts implementing the core logic of the protocol, deployed on ZetaChain and on connected chains
MIT License
68 stars 55 forks source link

Foundry in Hardhat breaks the build during npm publish #240

Closed fadeev closed 2 months ago

fadeev commented 2 months ago

This line in HH config requires forge to be installed.

https://github.com/zeta-chain/protocol-contracts/blob/8f89b49bb936010d7bce8e8b2014d6031c152ae2/hardhat.config.ts#L12

However, in the npm publish workflow we don't make sure that forge is available.

https://github.com/zeta-chain/protocol-contracts/blob/8f89b49bb936010d7bce8e8b2014d6031c152ae2/.github/workflows/publish-npm.yaml

Which breaks the build, so that not all artifacts are produced:

Run yarn publish --new-version ${GITHUB_REF#refs/tags/v} --tag latest --no-git-tag-version
yarn publish v1.22.22
[1/4] Bumping version...
info Current version: 0.0.[8](https://github.com/zeta-chain/protocol-contracts/actions/runs/9994777787/job/27626102405#step:6:9)
info New version: 8.0.0
[2/4] Logging in...
[3/4] Publishing...
$ yarn build
yarn run v1.22.22
$ yarn compile && npx del-cli dist abi && npx tsc || true && npx del-cli './dist/typechain-types/**/*.js' && npx cpx './data/**/*' dist/data && npx cpx './artifacts/contracts/**/*' ./abi && npx del-cli './abi/**/*.dbg.json'
$ npx hardhat compile --force
Error in plugin hardhat-foundry: Couldn't run `forge`. Please check that your foundry installation is correct.

HardhatFoundryError: Couldn't run `forge`. Please check that your foundry installation is correct.
    at buildForgeExecutionError (/home/runner/work/protocol-contracts/protocol-contracts/node_modules/@nomicfoundation/hardhat-foundry/src/foundry.ts:115:14)
    at runCmdSync (/home/runner/work/protocol-contracts/protocol-contracts/node_modules/@nomicfoundation/hardhat-foundry/src/foundry.ts:[9](https://github.com/zeta-chain/protocol-contracts/actions/runs/9994777787/job/27626102405#step:6:10)1:25)
    at getForgeConfig (/home/runner/work/protocol-contracts/protocol-contracts/node_modules/@nomicfoundation/hardhat-foundry/src/foundry.ts:31:21)
    at /home/runner/work/protocol-contracts/protocol-contracts/node_modules/@nomicfoundation/hardhat-foundry/src/index.ts:36:39
    at loadConfigAndTasks (/home/runner/work/protocol-contracts/protocol-contracts/node_modules/hardhat/src/internal/core/config/config-loading.ts:123:5)
    at main (/home/runner/work/protocol-contracts/protocol-contracts/node_modules/hardhat/src/internal/cli/cli.ts:218:62)
    at Object.<anonymous> (/home/runner/work/protocol-contracts/protocol-contracts/node_modules/hardhat/src/internal/cli/cli.ts:474:1)
    at Module._compile (node:internal/modules/cjs/loader:1364:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1422:[10](https://github.com/zeta-chain/protocol-contracts/actions/runs/9994777787/job/27626102405#step:6:11))
    at Module.load (node:internal/modules/cjs/loader:[12](https://github.com/zeta-chain/protocol-contracts/actions/runs/9994777787/job/27626102405#step:6:13)03:32)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Done in 9.57s.
success Published.
[4/4] Revoking token...
info Not revoking login token, specified via config file.
Done in [13](https://github.com/zeta-chain/protocol-contracts/actions/runs/9994777787/job/27626102405#step:6:14).32s.

But it still publishes to npm as if everything is fine:

https://github.com/zeta-chain/protocol-contracts/actions/runs/9994777787/job/27626102405