scaffold-eth-2
scaffold-eth-2 copied to clipboard
gh-actions fails for foundry
Is there an existing issue for this?
- [X] I have looked through the existing issues
Current Behavior
When using a project built with "npx create-eth@latest" and the selected option for "What solidity framework do you want to use" is "Foundry", then any time successfully push commit to GitHub, the Git Hooks will fail on the step "Run hardhat node, deploy contracts (& generate contracts typescript output)".
Expected Behavior
When pushing a commit to GitHub while using a project built from "npx create-eth@latest" and Foundry is the selected Solidity Framework, then the Git Hooks should succeed in deploying a local foundry chain and deploy contracts (& generate contracts typescript output).
Steps To Reproduce
- Go to: https://scaffoldeth.io/.
- Open CLI.
- Run command "npx create-eth@latest" from "https://scaffoldeth.io" in CLI.
- In CLI, enter any project name.
- In CLI, Select "Foundry" as the selected Solidity Framework.
- In CLI, Select "yes" to Install packages.
- Wait for packages to install, and observe the created project files on your local machine.
- Clone an empty repository from Github to local machine.
- Move the created project files from local machine into the local empty repository.
- Observe changes, commit changes, push changes.
- Wait for Git hooks to be ran on Github.com. Should fail.
Anything else?
You can see my current implementation in my own project here: https://github.com/ATXDAO/reputation-and-roles-monorepo/actions/runs/6869607334/job/18682721792
No. 8 and 9 are not necessary, change the GitHub URL directly from the project rather than copying the whole files into another folder After having your project dependencies installed run "git remote set-url origin new.git.url/here"
Thanks for reporting this @Hotmanics !
You are right! Since the GitHub action env doesn't have anvil / forge installed, it can't init the local node + deploy contracts
I think the solution might be to use https://github.com/marketplace/actions/foundry-toolchain on the projects using the foundry template.
I'm using npx create-eth@latest
with foundry option for the current Chainlink hackathon, and experienced these errors as well.
I ended up coming up with some hacky work-around for the build stage that was also failing (unmet dependency from another package).
- essentially, had to manually edit the yarn.lock file with this small change added from https://github.com/timolins/react-hot-toast/pull/262, as the underlying package hasn't closed this old PR yet.
I do have the CI lint stage fully passing and working with foundry now though.
Do you want me to open a PR with my changes made?
I do have the CI lint stage fully passing and working with foundry now though.
That's great. I saw that you added foundry toolchain.
It'd be great if you could make a PR. Take a look at the CLI branch and the docs for devs, which explain a bit how to contribute to the CLI branch (it's trickier than contributing to main
since we are using a template engine)
I ended up coming up with some hacky work-around for the build stage that was also failing (unmet dependency from another package). essentially, had to manually edit the yarn.lock file with this small change added from https://github.com/timolins/react-hot-toast/pull/262, as the underlying package hasn't closed this old PR yet.
Never happened before to me (but similar ones did happen). Since we don't have a yarn.lock file on the CLI branch (it'd depend on the CLI user selection), the solution could be to lock the dep in package.json file (eg. 2.0.0 instead of ~2.0.0).
If you open a PR we can assist you there too!
Thanks @Hampton-Black !!
Thanks for reporting this @Hotmanics !
You are right! Since the GitHub action env doesn't have anvil / forge installed, it can't init the local node + deploy contracts
I think the solution might be to use https://github.com/marketplace/actions/foundry-toolchain on the projects using the foundry template.
Attempting to do this...
I added
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
- name: Run tests
run: forge test -vvv
- name: Run snapshot
run: forge snapshot
to the lint.yaml
file and that works perfectly fine!
however when I try
- name: Run hardhat node, deploy contracts (& generate contracts typescript output)
run: yarn chain & yarn deploy
It errors out when looking for an etherscan environment variable (obviously, since .env files do not get pushed to github). Not sure on the best plan of action there...?
Additionally, modifying the command to be
- name: Run hardhat node, deploy contracts (& generate contracts typescript output)
run: yarn chain
leaves the check stuck in a never-ending check that never progresses to the next job.
Anyone have any suggestions for this?
Hey @Hotmanics !
You could do something like (got it from @Hampton-Black repo):
- name: Run foundry node, deploy contracts (& generate contracts typescript output)
env:
ETHERSCAN_API_KEY: ${{ secrets.ETHERSCAN_API_KEY }}
run: yarn chain & yarn deploy
id: build
Where you specify the env variable there (using GitHub secrets in this case). I guess you could even have a random/fake API KEY (so it won't complain) since this is just deploying it on the local chain that spins for checking the linting.
Let us know how it goes! Thanks.
Sorry I haven't done the PR yet for this.
I'm still planning to, but might have to wait until after the hackathon is finished (next weekend).
Hey @Hotmanics !
You could do something like (got it from @Hampton-Black repo):
- name: Run foundry node, deploy contracts (& generate contracts typescript output) env: ETHERSCAN_API_KEY: ${{ secrets.ETHERSCAN_API_KEY }} run: yarn chain & yarn deploy id: build
Where you specify the env variable there (using GitHub secrets in this case). I guess you could even have a random/fake API KEY (so it won't complain) since this is just deploying it on the local chain that spins for checking the linting.
Let us know how it goes! Thanks.
Seems to of fixed the issue regarding the env variable thank you.
But now getting stuck for HOURS on the yarn chain aspect. You can check my failed job run here: https://github.com/ATXDAO/reputation-and-roles-monorepo/actions/runs/7035555721/job/19146198098
Sorry I haven't done the PR yet for this.
I'm still planning to, but might have to wait until after the hackathon is finished (next weekend).
will be eagerly anticipating this and glad to help push it forward however I can.
Hey @Hampton-Black, please let us know if you need any help / stuck with cli
branch also this DEVELOPER-GUIDE.md might be helpful, but yeah please feel free to drop any issues/doubts 🙌
Might need some help.
I have it splitting up the github workflow files how I want now, but I'm getting errors with initializing the repo now via the CLI tool.
Here's my fork: https://github.com/Hampton-Black/scaffold-eth-2/tree/607-gh-actions-lint-split
and a sample actions pipeline: https://github.com/Hampton-Black/cli-test-5/actions/runs/7304157195
I think its better if we keep it simple for the first PR.
We don't want to split job as I see in https://github.com/Hampton-Black/cli-test-5/actions/runs/7304157195, Actually we want to run frontend lint after yarn deploy
(since this generate necessary types for frontend ).
So for initial draft PR:
-
Copy our current
main
branchlint.yaml
insidetemplates/extensions/hardhat/.github/workflows
-
Copy this foundry version
lint.yaml
insidetemplates/extensions/foundry/.github/workflows
next we can iterate on created PR, Thanks @Hampton-Black 🙌
Completed at https://github.com/scaffold-eth/create-eth/pull/38