Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-actions fails for foundry #607

Closed
1 task done
JacobHomanics opened this issue Nov 14, 2023 · 13 comments
Closed
1 task done

gh-actions fails for foundry #607

JacobHomanics opened this issue Nov 14, 2023 · 13 comments
Labels
bug Something isn't working cli foundry

Comments

@JacobHomanics
Copy link
Contributor

Is there an existing issue for this?

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

  1. Go to: https://scaffoldeth.io/.
  2. Open CLI.
  3. Run command "npx create-eth@latest" from "https://scaffoldeth.io" in CLI.
  4. In CLI, enter any project name.
  5. In CLI, Select "Foundry" as the selected Solidity Framework.
  6. In CLI, Select "yes" to Install packages.
  7. Wait for packages to install, and observe the created project files on your local machine.
  8. Clone an empty repository from Github to local machine.
  9. Move the created project files from local machine into the local empty repository.
  10. Observe changes, commit changes, push changes.
  11. 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

@KcPele
Copy link
Contributor

KcPele commented Nov 15, 2023

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"

@carletex
Copy link
Member

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.

@carletex carletex added foundry cli bug Something isn't working labels Nov 15, 2023
@Hampton-Black
Copy link

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).

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?

@carletex
Copy link
Member

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 timolins/react-hot-toast#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 !!

@JacobHomanics
Copy link
Contributor Author

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?

@carletex
Copy link
Member

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.

@Hampton-Black
Copy link

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).

@JacobHomanics
Copy link
Contributor Author

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

@JacobHomanics
Copy link
Contributor Author

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.

@technophile-04
Copy link
Collaborator

technophile-04 commented Dec 17, 2023

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 🙌

@Hampton-Black
Copy link

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

@technophile-04
Copy link
Collaborator

technophile-04 commented Dec 23, 2023

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:

  1. Copy our current main branch lint.yaml inside templates/extensions/hardhat/.github/workflows

  2. Copy this foundry version lint.yaml inside templates/extensions/foundry/.github/workflows

next we can iterate on created PR, Thanks @Hampton-Black 🙌

@technophile-04 technophile-04 changed the title bug: Git Hooks fail on "Run hardhat node, deploy contracts (& generate contracts typescript output)" when running foundry cli project gh-actions fails for foundry May 2, 2024
@technophile-04
Copy link
Collaborator

Completed at scaffold-eth#38

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working cli foundry
Projects
None yet
Development

No branches or pull requests

5 participants