-
Notifications
You must be signed in to change notification settings - Fork 3
feat(deploy): add shared check-published-deploy-constants script #238
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,60 @@ | ||||||||||||||||||||||||||||||||||||||||
| #!/usr/bin/env bash | ||||||||||||||||||||||||||||||||||||||||
| # SPDX-License-Identifier: LicenseRef-DCL-1.0 | ||||||||||||||||||||||||||||||||||||||||
| # SPDX-FileCopyrightText: Copyright (c) 2020 Rain Open Source Software Ltd | ||||||||||||||||||||||||||||||||||||||||
| # | ||||||||||||||||||||||||||||||||||||||||
| # Checks that every version published to the soldeer registry for a given | ||||||||||||||||||||||||||||||||||||||||
| # package has a full suite of pinned deploy constants in the specified Solidity | ||||||||||||||||||||||||||||||||||||||||
| # file. For each published version and each constant prefix, asserts that both | ||||||||||||||||||||||||||||||||||||||||
| # a DEPLOYED_ADDRESS_<ver> and DEPLOYED_CODEHASH_<ver> constant exist (where | ||||||||||||||||||||||||||||||||||||||||
| # <ver> is the version string with dots replaced by underscores). | ||||||||||||||||||||||||||||||||||||||||
| # | ||||||||||||||||||||||||||||||||||||||||
| # Usage: | ||||||||||||||||||||||||||||||||||||||||
| # check-published-deploy-constants <soldeer-package> <deploy-lib-path> <prefix> [<prefix> ...] | ||||||||||||||||||||||||||||||||||||||||
| # | ||||||||||||||||||||||||||||||||||||||||
| # Arguments: | ||||||||||||||||||||||||||||||||||||||||
| # soldeer-package soldeer package name to query (e.g. "raindex") | ||||||||||||||||||||||||||||||||||||||||
| # deploy-lib-path path to the Solidity file holding the constants | ||||||||||||||||||||||||||||||||||||||||
| # prefix... one or more constant name prefixes | ||||||||||||||||||||||||||||||||||||||||
| # | ||||||||||||||||||||||||||||||||||||||||
| # Output (always exits 0): | ||||||||||||||||||||||||||||||||||||||||
| # OK every published version has its full constant suite | ||||||||||||||||||||||||||||||||||||||||
| # MISSING: <names> one or more expected constants are absent | ||||||||||||||||||||||||||||||||||||||||
| # SKIP: <reason> the registry could not be reached (nothing verified) | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| set -euo pipefail | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| if [ "$#" -lt 3 ]; then | ||||||||||||||||||||||||||||||||||||||||
| printf 'Usage: check-published-deploy-constants <soldeer-package> <deploy-lib-path> <prefix> [<prefix>...]\n' >&2 | ||||||||||||||||||||||||||||||||||||||||
| exit 1 | ||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| package="$1" | ||||||||||||||||||||||||||||||||||||||||
| lib="$2" | ||||||||||||||||||||||||||||||||||||||||
| shift 2 | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| versions=$( | ||||||||||||||||||||||||||||||||||||||||
| curl -fsS "https://api.soldeer.xyz/api/v1/revision?project_name=${package}" 2>/dev/null \ | ||||||||||||||||||||||||||||||||||||||||
| | grep -oE '"version":"[0-9][0-9.]*"' | cut -d'"' -f4 | sort -u | ||||||||||||||||||||||||||||||||||||||||
| ) || true | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| if [ -z "$versions" ]; then | ||||||||||||||||||||||||||||||||||||||||
| printf 'SKIP: could not fetch published soldeer versions' | ||||||||||||||||||||||||||||||||||||||||
| exit 0 | ||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+35
to
+42
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win Don't collapse parse failures into a connectivity Because Proposed fix-versions=$(
- curl -fsS "https://api.soldeer.xyz/api/v1/revision?project_name=${package}" 2>/dev/null \
- | grep -oE '"version":"[0-9][0-9.]*"' | cut -d'"' -f4 | sort -u
-) || true
-
-if [ -z "$versions" ]; then
+response=$(curl -fsS "https://api.soldeer.xyz/api/v1/revision?project_name=${package}" 2>/dev/null) || {
printf 'SKIP: could not fetch published soldeer versions'
exit 0
-fi
+}
+
+versions=$(
+ printf '%s' "$response" \
+ | grep -oE '"version":"[0-9][0-9.]*"' \
+ | cut -d'"' -f4 \
+ | sort -u
+)📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| missing="" | ||||||||||||||||||||||||||||||||||||||||
| for v in $versions; do | ||||||||||||||||||||||||||||||||||||||||
| suffix=$(printf '%s' "$v" | tr . _) | ||||||||||||||||||||||||||||||||||||||||
| for p in "$@"; do | ||||||||||||||||||||||||||||||||||||||||
| for kind in ADDRESS CODEHASH; do | ||||||||||||||||||||||||||||||||||||||||
| name="${p}_${kind}_${suffix}" | ||||||||||||||||||||||||||||||||||||||||
| grep -qE "constant ${name} =" "$lib" || missing="${missing} ${name}" | ||||||||||||||||||||||||||||||||||||||||
| done | ||||||||||||||||||||||||||||||||||||||||
| done | ||||||||||||||||||||||||||||||||||||||||
| done | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| if [ -n "$missing" ]; then | ||||||||||||||||||||||||||||||||||||||||
| printf 'MISSING:%s' "$missing" | ||||||||||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||||||||||
| printf 'OK' | ||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||
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.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Keep the CLI contract success-only here too.
The linked issue/PR contract says callers should only see
OK,MISSING, orSKIPand a zero exit status.exit 1adds a fourth behavior that can break consumers wiring this into CI.Proposed fix
📝 Committable suggestion
🤖 Prompt for AI Agents