-
Notifications
You must be signed in to change notification settings - Fork 3
(WIP) feat: scenarios based testing #71
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
Closed
Closed
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
820b67f
introduce: initial scenarios
redpanda-f f0fdab5
feat: githooks, ADVANCED_README
redpanda-f 803aeb9
rename: foc-start-test to foc-devnet-test
redpanda-f 930d7eb
add: fixes
redpanda-f d077ef5
add: support for latestCommit and latestTag
redpanda-f e6bedf0
fix: scenarios
redpanda-f f7452f6
fix: test_basic_balances
redpanda-f ba87369
fix: ensure_foundry was in wrong location
redpanda-f c28437c
feat: latestCommit and latestTag takes a branch optionally
redpanda-f 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,7 @@ | ||
| #!/usr/bin/env bash | ||
| # Installs the repo's git hooks by pointing core.hooksPath at .githooks/ | ||
| set -euo pipefail | ||
| REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)" | ||
| git -C "$REPO_ROOT" config core.hooksPath .githooks | ||
| chmod +x "$REPO_ROOT"/.githooks/* | ||
| echo "✓ Git hooks installed (.githooks/)" |
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,108 @@ | ||
| #!/usr/bin/env bash | ||
| # ───────────────────────────────────────────────────────────── | ||
| # pre-commit hook for foc-devnet | ||
| # | ||
| # Checks staged files before each commit: | ||
| # - Rust: cargo fmt, cargo clippy | ||
| # - Shell: shfmt, shellcheck, executable bit | ||
| # | ||
| # Install: bash .githooks/install.sh | ||
| # Skip once: git commit --no-verify | ||
| # | ||
| # Auto-fix mode (formats code and re-stages): | ||
| # FIX=1 git commit | ||
| # ───────────────────────────────────────────────────────────── | ||
| set -euo pipefail | ||
|
|
||
| FIX="${FIX:-0}" | ||
|
|
||
| RED='\033[0;31m' | ||
| GREEN='\033[0;32m' | ||
| YELLOW='\033[0;33m' | ||
| BLUE='\033[0;34m' | ||
| NC='\033[0m' | ||
|
|
||
| FAIL=0 | ||
|
|
||
| pass() { printf "${GREEN}✓${NC} %s\n" "$1"; } | ||
| fail() { printf "${RED}✗${NC} %s\n" "$1"; FAIL=1; } | ||
| skip() { printf "${YELLOW}⊘${NC} %s (skipped — tool not found)\n" "$1"; } | ||
| fixed() { printf "${BLUE}⟳${NC} %s (auto-fixed & re-staged)\n" "$1"; } | ||
|
|
||
| # Collect staged files | ||
| STAGED=$(git diff --cached --name-only --diff-filter=ACM) | ||
|
|
||
| # ── Rust checks ────────────────────────────────────────────── | ||
| STAGED_RS=$(echo "$STAGED" | grep '\.rs$' || true) | ||
| HAS_RS=$(echo "$STAGED_RS" | grep -c '\.rs$' || true) | ||
| if [[ $HAS_RS -gt 0 ]]; then | ||
| if command -v cargo &>/dev/null; then | ||
| if cargo fmt --all -- --check &>/dev/null; then | ||
| pass "cargo fmt" | ||
| elif [[ "$FIX" == "1" ]]; then | ||
| cargo fmt --all | ||
| echo "$STAGED_RS" | xargs -r git add | ||
| fixed "cargo fmt" | ||
| else | ||
| fail "cargo fmt — run 'cargo fmt' or FIX=1 git commit" | ||
| fi | ||
|
|
||
| if cargo clippy --all-targets --all-features -- -D warnings &>/dev/null; then | ||
| pass "cargo clippy" | ||
| else | ||
| fail "cargo clippy — fix warnings before committing" | ||
| fi | ||
| else | ||
| skip "cargo (Rust checks)" | ||
| fi | ||
| fi | ||
|
|
||
| # ── Shell checks ───────────────────────────────────────────── | ||
| STAGED_SH=$(echo "$STAGED" | grep '\.sh$' || true) | ||
| if [[ -n "$STAGED_SH" ]]; then | ||
| # Executable bit | ||
| for f in $STAGED_SH; do | ||
| if [[ -f "$f" && ! -x "$f" ]]; then | ||
| if [[ "$FIX" == "1" ]]; then | ||
| chmod +x "$f" | ||
| git add "$f" | ||
| fixed "${f} +x" | ||
| else | ||
| fail "${f} is not executable — run 'chmod +x ${f}'" | ||
| fi | ||
| fi | ||
| done | ||
|
|
||
| # shfmt | ||
| if command -v shfmt &>/dev/null; then | ||
| if shfmt -d -i 2 -bn $STAGED_SH &>/dev/null; then | ||
| pass "shfmt" | ||
| elif [[ "$FIX" == "1" ]]; then | ||
| shfmt -w -i 2 -bn $STAGED_SH | ||
| echo "$STAGED_SH" | xargs -r git add | ||
| fixed "shfmt" | ||
| else | ||
| fail "shfmt — run 'shfmt -w -i 2 -bn <file>' or FIX=1 git commit" | ||
| fi | ||
| else | ||
| skip "shfmt" | ||
| fi | ||
|
|
||
| # SC — no auto-fix available | ||
| if command -v shellcheck &>/dev/null; then | ||
| if shellcheck -S warning $STAGED_SH &>/dev/null; then | ||
| pass "shellcheck" | ||
| else | ||
| fail "shellcheck — run 'shellcheck -S warning <file>' to see issues" | ||
| fi | ||
| else | ||
| skip "shellcheck" | ||
| fi | ||
| fi | ||
|
|
||
| # ── Result ─────────────────────────────────────────────────── | ||
| if [[ $FAIL -ne 0 ]]; then | ||
| echo "" | ||
| printf "${RED}Pre-commit checks failed.${NC} Fix issues above or skip with: git commit --no-verify\n" | ||
| exit 1 | ||
| fi |
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 |
|---|---|---|
|
|
@@ -2,4 +2,5 @@ target/ | |
| contracts/MockUSDFC/lib/ | ||
| contracts/MockUSDFC/broadcast/ | ||
| artifacts/ | ||
| .vscode/ | ||
| .vscode/ | ||
| *__pycache__/ | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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.
What is the value of adding githhooks if we can't rely on them being installed and we're running these checks in CI anyways? Does it speed up developement? As this is basically duplicating what is setu in CI, lets add comments explaining why we're doing this.
Uh oh!
There was an error while loading. Please reload this page.
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.
On my system, it fixes before commits, things like fmt and others. These do not strictly duplicate CI, but there is an argument here. We can instead deduplicate and run the same script with FIX=0 and FIX=1 I guess.