-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14278 from smartcontractkit/ccip/capabilities-deb…
…ug-contracts-fmt Merge CCIP V1.6 [CCIP-2946]
- Loading branch information
Showing
233 changed files
with
27,890 additions
and
20,149 deletions.
There are no files selected for viewing
This file contains 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,5 @@ | ||
--- | ||
"chainlink": minor | ||
--- | ||
|
||
#updated move latest capabilities code from ccip repo to chainlink repo [CCIP-2946] |
This file contains 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 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 |
---|---|---|
|
@@ -107,3 +107,5 @@ override*.toml | |
.venv/ | ||
|
||
ocr_soak_report.csv | ||
|
||
vendor/* |
This file contains 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 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,5 @@ | ||
--- | ||
'@chainlink/contracts': minor | ||
--- | ||
|
||
#updated move latest ccip contracts code from ccip repo to chainlink repo [CCIP-2946] |
This file contains 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,37 @@ | ||
# Husky git hooks | ||
The folder contains [husky](https://github.com/typicode/husky) git hooks that automate pre-commit and pre-push commands. | ||
|
||
## Setup | ||
|
||
Create an `.env` file in this folder to enable hooks: | ||
|
||
```sh | ||
# Can be left blank to compile everything | ||
FOUNDRY_PROFILE=ccip | ||
HUSKY_ENABLE_PUSH_HOOKS=true | ||
HUSKY_ENABLE_COMMIT_HOOKS=true | ||
UPSTREAM_BRANCH=origin/ccip-develop | ||
``` | ||
|
||
```sh | ||
# Automatically ran after pnpm install | ||
pnpm prepare | ||
``` | ||
|
||
### Script procedure | ||
|
||
The setup is done via the `prepare.sh` script, which installs husky and enables the hooks. | ||
|
||
The prepare step is skipped if we are in CI. This is checked via the `CI=true` flag, which is always set to true on GitHub actions. | ||
|
||
## Hooks & Scripts | ||
|
||
### Pre-commit | ||
Runs [lint-staged](https://github.com/lint-staged/lint-staged), which automatically detects `.sol` file changes and applies `forge fmt` only on the changed files. | ||
|
||
Configured in `package.json` in the `lint-staged` field. | ||
|
||
### Pre-push | ||
Runs forge build, test, solhint and optionally suggests to generate snapshots and wrappers. | ||
|
||
Due to a [git workflow limitation](https://stackoverflow.com/questions/21334493/git-commit-in-pre-push-hook), generating wrappers & snapshots requires resubmitting the push (via `--no-verify` or by skiping the snapshot / wrappers). |
This file contains 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,14 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
source contracts/.husky/.env | ||
|
||
# Only run hook on enabled | ||
if ! [[ $HUSKY_ENABLE_COMMIT_HOOKS == "true" && -n $UPSTREAM_BRANCH ]]; then | ||
exit 0 | ||
fi | ||
|
||
cd contracts | ||
|
||
# Run lint steps | ||
pnpm lint-staged -v |
This file contains 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 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
source contracts/.husky/.env | ||
|
||
# Only run hook on enabled | ||
if ! [[ $HUSKY_ENABLE_PUSH_HOOKS == "true" && -n $UPSTREAM_BRANCH ]]; then | ||
exit 0 | ||
fi | ||
|
||
# Skip on no changes | ||
current_branch=$(git branch --show-current) | ||
changes_root=$(git diff --name-only $UPSTREAM_BRANCH...$current_branch -- "contracts/") | ||
|
||
if ! [[ -n $changes_root ]]; then | ||
echo "Pre-push hook for contracts skipped - no changes detected" | ||
exit 0 | ||
fi | ||
|
||
cd contracts | ||
|
||
FOUNDRY_PROFILE=$FOUNDRY_PROFILE forge build | ||
FOUNDRY_PROFILE=$FOUNDRY_PROFILE forge test | ||
pnpm solhint | ||
|
||
# Skip interactive commands if interactive mode (/dev/tty) is unavailable | ||
# https://stackoverflow.com/a/69088164 | ||
if sh -c ": >/dev/tty" >/dev/null 2>/dev/null; then | ||
read -n1 -p "Re-generate snapshots & wrappers? (Y/n)" snapshot_answer < /dev/tty | ||
echo $snapshot_answer | ||
|
||
if [ "$snapshot_answer" != "${snapshot_answer#[Yy]}" ] ;then | ||
# Create gas snapshot & commit gas snapshot | ||
make snapshot | ||
make wrappers | ||
|
||
git add ./gas-snapshots | ||
git add ../core/gethwrappers | ||
|
||
# Check if commit is successful (non-empty) | ||
if git commit -m "chore: update gas snapshots and wrappers"; then | ||
# The commit is not included - need to push again (https://stackoverflow.com/questions/21334493/git-commit-in-pre-push-hook) | ||
printf "\033[0;31m Snapshot commit created - run git push again \033[1;33m(skip snapshot, or use the --no-verify push option)\n" | ||
exit 1 | ||
fi | ||
fi | ||
fi |
This file contains 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,19 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
# Detect if in CI to skip hooks | ||
# https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables | ||
if [[ $CI == "true" ]]; then | ||
exit 0 | ||
fi | ||
|
||
# Skip hooks creation if unconfigured | ||
if ! [ -f .husky/.env ]; then | ||
printf "\033[1;33mNo .env file found in contracts/.husky, skipping hooks setup.\e[0m\n" | ||
exit 0 | ||
fi | ||
|
||
cd ../ | ||
chmod +x ./contracts/.husky/*.sh | ||
pnpm husky ./contracts/.husky | ||
echo "Husky hooks prepared." |
This file contains 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,20 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
# Determine the current branch | ||
current_branch=$(git branch --show-current) | ||
upstream_branch="origin/ccip-develop" | ||
|
||
# Compare the directory against the upstream branch | ||
changes_root=$(git diff --name-only $upstream_branch...$current_branch -- ".changeset") | ||
|
||
if ! [ -n "$changes_root" ]; then | ||
printf "\033[1;33mRoot changeset changes not found, Consider running pnpm changeset in the root directory if there is significant off-chain impact.\e[0m\n" | ||
fi | ||
|
||
changes_contracts=$(git diff --name-only $upstream_branch...$current_branch -- "contracts/.changeset") | ||
|
||
if ! [ -n "$changes_contracts" ]; then | ||
printf "\033[0;31mContracts changeset changes not found, Make sure to run & commit \033[1;33mpnpm changeset\033[0;31m in the contracts directory.\n" | ||
exit 1 | ||
fi |
This file contains 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 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
Oops, something went wrong.