-
Notifications
You must be signed in to change notification settings - Fork 25
ci: Add Hardhat tooling integration test #516
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
Open
elle-j
wants to merge
10
commits into
main
Choose a base branch
from
lj/ci-hardhat
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
57ca1ff
Add erc20 hardhat project.
elle-j 832e7d5
Add hardhat integration workflow.
elle-j 0bb694b
Move solc version to env.
elle-j f4b3903
Merge branch 'main' into lj/ci-hardhat
elle-j 80cc69a
Update config.
elle-j 165f252
Merge branch 'main' into lj/ci-hardhat
elle-j c96d36a
Reuse the build from differential tests.
elle-j 642b14a
Move inline script into sh file.
elle-j c01275c
Update script name.
elle-j 018d733
Add workflow comment.
elle-j File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| # Tests compilation and E2E integration with hardhat-polkadot, but not runtime correctness. | ||
|
|
||
| name: Hardhat Integration | ||
|
|
||
| on: | ||
| workflow_call: | ||
|
|
||
| env: | ||
| # Workflow-internal hardhat envs are prefixed with `CI_` to not conflict with the | ||
| # `HARDHAT_*` namespace, which hardhat itself will interpret for its configuration. | ||
| CI_HARDHAT_PROJECT_ROOT: tooling-projects/hardhat/erc20 | ||
|
|
||
| jobs: | ||
| use-hardhat: | ||
| runs-on: ubuntu-24.04 | ||
| steps: | ||
| - name: Checkout revive | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Download resolc Binary | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| name: resolc-x86_64-unknown-linux-musl | ||
| path: resolc-bin | ||
|
|
||
| - name: Export resolc Path | ||
| run: | | ||
| chmod +x resolc-bin/resolc-x86_64-unknown-linux-musl | ||
| # This env is used by `hardhat.config.js`. | ||
| echo "RESOLC_PATH=$(pwd)/resolc-bin/resolc-x86_64-unknown-linux-musl" >> $GITHUB_ENV | ||
|
|
||
| - name: Set Up Node.js | ||
| uses: actions/setup-node@v6 | ||
| with: | ||
| node-version: "24" | ||
|
|
||
| - name: Install Project Dependencies | ||
| working-directory: ${{ env.CI_HARDHAT_PROJECT_ROOT }} | ||
| run: npm ci | ||
|
|
||
| - name: Compile Project | ||
| working-directory: ${{ env.CI_HARDHAT_PROJECT_ROOT }} | ||
| run: npx hardhat compile | ||
|
|
||
| - name: Verify Output | ||
| working-directory: ${{ env.CI_HARDHAT_PROJECT_ROOT }} | ||
| run: bash verify-compiler-output.sh |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| // SPDX-License-Identifier: MIT | ||
| // Compatible with OpenZeppelin Contracts ^5.0.0 | ||
| pragma solidity ^0.8.22; | ||
|
|
||
| import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; | ||
| import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol"; | ||
|
|
||
| contract MyToken is ERC20, Ownable { | ||
| constructor(address initialOwner) | ||
| ERC20("MyToken", "MTK") | ||
| Ownable(initialOwner) | ||
| {} | ||
|
|
||
| function mint(address to, uint256 amount) public onlyOwner { | ||
| _mint(to, amount); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| require("@nomicfoundation/hardhat-toolbox"); | ||
| require("@parity/hardhat-polkadot"); | ||
|
|
||
| const RESOLC_PATH_ENV_NAME = "RESOLC_PATH"; | ||
|
|
||
| function getEnv(name) { | ||
| const value = process.env[name]; | ||
| if (!value) { | ||
| throw new Error(`Required environment variable '${name}' is missing`); | ||
| } | ||
|
|
||
| return value; | ||
| } | ||
|
|
||
| /** @type {import('hardhat/config').HardhatUserConfig} */ | ||
| module.exports = { | ||
| solidity: "0.8.35", | ||
| resolc: { | ||
| compilerSource: "binary", | ||
| settings: { | ||
| resolcPath: getEnv(RESOLC_PATH_ENV_NAME), | ||
| optimizer: { | ||
| enabled: true, | ||
| parameters: "z" | ||
| }, | ||
| }, | ||
| }, | ||
| networks: { | ||
| hardhat: { | ||
| polkadot: true | ||
| }, | ||
| }, | ||
| }; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.