-
Notifications
You must be signed in to change notification settings - Fork 53
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
LF-12061 Run healthcheck on new network #985
Open
mirooon
wants to merge
14
commits into
main
Choose a base branch
from
lf-12061-run-healthcheck-on-new-network
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
14 commits
Select commit
Hold shift + click to select a range
43ea772
Added healthCheck for new network deployment git action
mirooon ac0fda9
Updated healthCheckForNewNetworkDeployment github action and healthCh…
mirooon e394dcf
Changed var names
mirooon 3c5aa69
Merge branch 'main' into lf-12061-run-healthcheck-on-new-network
mirooon 7fe2ded
test
mirooon 76126d4
changed networks
mirooon ba4c2b1
health check fo new network deployment action adjustments
mirooon 28c65ea
temp comment
mirooon 899cce9
test
mirooon 89844f7
test
mirooon 04a17ea
c
mirooon 16891e2
d
mirooon 522c3ec
fix
mirooon 8198e2d
Merge branch 'main' into lf-12061-run-healthcheck-on-new-network
mirooon 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
104 changes: 104 additions & 0 deletions
104
.github/workflows/healthCheckForNewNetworkDeployment.yml
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,104 @@ | ||
name: Health Check for New Network Deployment | ||
|
||
on: | ||
pull_request: | ||
types: [opened, synchronize, reopened, ready_for_review] | ||
paths: | ||
- 'config/networks.json' | ||
|
||
jobs: | ||
check-new-network-health: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Check if config/networks.json was changed in this branch | ||
id: check-file-change | ||
run: | | ||
if git diff --name-only origin/main...HEAD | grep -q "config/networks.json"; then | ||
echo "config/networks.json has been modified in this branch" | ||
echo "CONTINUE=true" >> $GITHUB_ENV | ||
else | ||
echo "No changes in config/networks.json detected in this branch" | ||
echo "CONTINUE=false" >> $GITHUB_ENV | ||
fi | ||
|
||
- name: Detect Newly Added Networks | ||
if: env.CONTINUE == 'true' | ||
id: detect-changes | ||
run: | | ||
echo "Comparing config/networks.json with the previous commit..." | ||
git fetch origin main --depth=1 || echo "No previous commit found." | ||
|
||
if git show origin/main:config/networks.json > /dev/null 2>&1; then | ||
OLD_NETWORKS=$(git show origin/main:config/networks.json | jq 'keys') | ||
else | ||
echo "No previous networks.json found, assuming all networks are new." | ||
OLD_NETWORKS="[]" | ||
fi | ||
|
||
NEW_NETWORKS=$(jq 'keys' config/networks.json) | ||
|
||
echo "New Networks: $NEW_NETWORKS" | ||
|
||
ADDED_NETWORKS=$(jq -n --argjson old "$OLD_NETWORKS" --argjson new "$NEW_NETWORKS" '$new - $old') | ||
|
||
if [[ "$ADDED_NETWORKS" == "[]" ]]; then | ||
echo "No new networks detected." | ||
echo "SKIP_CHECK=true" >> $GITHUB_ENV | ||
else | ||
echo "New networks detected: $ADDED_NETWORKS" | ||
echo "added_networks=$(echo $ADDED_NETWORKS | jq -c .)" >> $GITHUB_ENV | ||
fi | ||
|
||
- name: Validate Network Deployment Files | ||
if: env.CONTINUE == 'true' && env.SKIP_CHECK != 'true' | ||
run: | | ||
echo "Validating required files for new networks..." | ||
for network in $(echo $added_networks | jq -r '.[]'); do | ||
echo "🔍 Checking files for network: $network" | ||
|
||
# Check if network exists in _targetState.json | ||
if ! jq -e 'has("'"$network"'")' script/deploy/_targetState.json > /dev/null; then | ||
echo "❌ Error: Network '$network' not found in script/deploy/_targetState.json" | ||
exit 1 | ||
fi | ||
|
||
# Check if deployments/{network}.json file exists | ||
if [[ ! -f "deployments/$network.json" ]]; then | ||
echo "❌ Error: Missing deployment file: deployments/$network.json" | ||
exit 1 | ||
fi | ||
done | ||
|
||
- name: Install Bun | ||
if: env.CONTINUE == 'true' && env.SKIP_CHECK != 'true' | ||
uses: oven-sh/setup-bun@v1 | ||
with: | ||
bun-version: latest | ||
|
||
- name: Install Foundry (provides cast) | ||
if: env.CONTINUE == 'true' && env.SKIP_CHECK != 'true' | ||
uses: foundry-rs/foundry-toolchain@v1 | ||
|
||
- name: Install dependencies | ||
if: env.CONTINUE == 'true' && env.SKIP_CHECK != 'true' | ||
run: bun install | ||
|
||
- name: Run Health Checks on New Networks | ||
if: env.CONTINUE == 'true' && env.SKIP_CHECK != 'true' | ||
run: | | ||
echo "Running health check for new networks..." | ||
set -e | ||
for network in $(echo $added_networks | jq -r '.[]'); do | ||
echo "🔍 Checking network: $network" | ||
if bun run script/deploy/healthCheck.ts --network "$network"; then | ||
echo "✅ $network is fine." | ||
else | ||
echo "❌ Health check failed for $network. Exiting..." | ||
exit 1 | ||
fi | ||
done |
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.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would suggest to move the install bits before the code logic....like first set up the environment, then execute code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I put deps installation part after validating whether everything is needed, convinced that this could save some resources for this action. Since it's a small action, the impact is minimal I know. The validation code is actually larger than the logic part cuz we only run healthCheck after it, which might make it seem a bit odd. I can change it if needed! Wdyt?