-
Notifications
You must be signed in to change notification settings - Fork 5.4k
One justfile to run them all
#7369
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
Merged
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
7116df4
first version of the justfile
xunilrj 051c586
first version of the justfile
xunilrj 1778c17
update README.md
xunilrj c11b48a
fix typo
xunilrj 4326b52
removing unecessary shebangs
xunilrj cebd394
Merge branch 'master' into xunilrj/justfile
tritao 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
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,48 @@ | ||
| [group('ci')] | ||
| [confirm("Do you want to install cargo-sort, cargo-generate and cargo-udeps from crates.io?")] | ||
| install-ci-check: | ||
| cargo install cargo-sort | ||
| cargo install cargo-generate | ||
| cargo install cargo-udeps | ||
|
|
||
| [group('ci')] | ||
| ci-check: | ||
| bash ./ci_checks.sh | ||
|
|
||
| [group('automation')] | ||
| [confirm("Do you want to bump all fuel maintained dependencies?")] | ||
| update-fuel-dependencies: | ||
| bash ./update_fuel_dependencies.sh | ||
|
|
||
| [group('automation')] | ||
| [confirm("Do you want to automatically update contractIds in this repo?")] | ||
| update-contract-ids: | ||
| bash ./test/update-contract-ids.sh | ||
|
|
||
| [group('benchmark')] | ||
| benchmark: | ||
| bash ./benchmark.sh | ||
|
|
||
| [group('benchmark')] | ||
| benchmark-tests: | ||
| bash ./test/bench.sh | ||
|
|
||
| [group('benchmark')] | ||
| collect-gas-usage: | ||
| cargo r -p test --release -- --verbose --forc-test-only | ./scripts/compare-gas-usage/extract-gas-usage.sh | ||
|
|
||
| [group('build')] | ||
| build-prism: | ||
| cd ./scripts/prism && ./build.sh | ||
|
|
||
| [group('build')] | ||
| build-highlightjs: | ||
| cd ./scripts/highlightjs && ./build.sh | ||
|
|
||
| [group('build')] | ||
| generate-sway-lib-std: | ||
| cd ./sway-lib-std && ./generate.sh | ||
|
|
||
| [group('test')] | ||
| test-forc-fmt-check-panic: | ||
| cd ./scripts/formatter && ./forc-fmt-check-panic.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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| `bisect-forc.sh` will automatically run `forc bisect` searching for a different behaviour between two commits. | ||
|
|
||
| The script accepts three arguments: | ||
|
|
||
| ``` | ||
| bisect-forc.sh sway_project test 30s | ||
| ``` | ||
| 1 - First argument is the sway project that will be compiled over and over until a different behavior is found; | ||
| 2 - The second argument is which forc subcommand will be used. It defaults to `build`. | ||
|
|
||
| So, `forc` will be run as: | ||
|
|
||
| ``` | ||
| > forc <SECONDARGUMENT> --path <FIRSTARGUMENT> | ||
| ``` | ||
|
|
||
| 3 - The third argument is a sleep that is taken between compilations to avoid notebooks enter into thermal throttle mode, or that weaker machines become unusable. Default to zero. |
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,162 @@ | ||
| #! /bin/bash | ||
|
|
||
| PROJ=$1 | ||
| SLEEP_BETWEEN=$3 | ||
| CACHE="$HOME/.cache/sway-bench" | ||
|
|
||
| NC='\033[0m' | ||
| BOLD_GREEN="\033[1;32m" | ||
| BOLD_RED='\033[1;31m' | ||
| BOLD_WHITE='\033[1;97m' | ||
|
|
||
| # $1 = commit hash | ||
| compile_and_cp_to_cache() { | ||
| if [ ! -f "$CACHE/$1" ]; then | ||
| if [[ -n $SLEEP_BETWEEN ]]; then | ||
| sleep "$SLEEP_BETWEEN" | ||
| fi | ||
| cargo b --release &>> /dev/null | ||
| cp target/release/forc "$CACHE/$1" &>> /dev/null | ||
| fi | ||
| } | ||
|
|
||
| run_cargo() { | ||
| if [ "$2" = "" ]; then | ||
| bash -c "$CACHE/$CACHENAME build --path $PROJ" &>> /dev/null | ||
| echo "$?" | ||
| else | ||
| bash -c "$CACHE/$CACHENAME $2 --path $PROJ" &>> /dev/null | ||
| echo "$?" | ||
| fi | ||
| } | ||
|
|
||
| INITIAL_COMMIT="$(git show -s --format='%H' HEAD)" | ||
| END_COMMIT="" | ||
|
|
||
| echo "Forc command will be:" | ||
| if [ "$2" = "" ]; then | ||
| echo "> forc build --path $PROJ" | ||
| else | ||
| echo "> forc $2 --path $PROJ" | ||
| fi | ||
|
|
||
| echo "Starting the search at: " | ||
| echo -n " " | ||
| git log -1 --oneline | ||
|
|
||
| echo -n "Running: " | ||
|
|
||
| CACHENAME="$(git show -s --format='%as-%ct-%H' HEAD)" | ||
| compile_and_cp_to_cache "$CACHENAME" | ||
| INITIAL_COMPILATION_STATUS=$(run_cargo) | ||
|
|
||
| if [ "$INITIAL_COMPILATION_STATUS" = "0" ]; then | ||
| echo -e " ${BOLD_GREEN}Ok${NC}" | ||
| echo "" | ||
| echo "Searching the newest version which compilation was failing." | ||
| else | ||
| echo -e " ${BOLD_RED}Failed${NC}" | ||
| echo "" | ||
| echo "Searching the newest version which compilation was succeeding." | ||
| fi | ||
|
|
||
|
|
||
| for HASH in `git log --format="%H" --tags --no-walk`; do | ||
| git checkout "$HASH" &>> /dev/null | ||
| git checkout . &>> /dev/null | ||
|
|
||
| git log -1 --oneline | ||
|
|
||
| CACHENAME="$(git show -s --format='%as-%ct-%H' HEAD)" | ||
| compile_and_cp_to_cache "$CACHENAME" | ||
| LAST_STATUS=$(run_cargo) | ||
| if [ "$INITIAL_COMPILATION_STATUS" != "$LAST_STATUS" ]; then | ||
| echo -e "^^^^^^^^^ ${BOLD_WHITE}This version result is different!${NC}" | ||
| break | ||
| fi | ||
| done | ||
|
|
||
| END_COMMIT="$(git show -s --format='%H' HEAD)" | ||
|
|
||
| echo "" | ||
| echo -e "${BOLD_WHITE}Starting bisect between: ${NC}$INITIAL_COMMIT..$END_COMMIT" | ||
|
|
||
| git checkout $INITIAL_COMMIT &>> /dev/null | ||
|
|
||
| git bisect start &>> /dev/null | ||
| git bisect new $INITIAL_COMMIT &>> /dev/null | ||
| git bisect old $END_COMMIT &>> /dev/null | ||
|
|
||
| while : | ||
| do | ||
| #echo "-----------------------" | ||
| #git --no-pager bisect visualize --oneline | ||
|
|
||
| git bisect next | grep "is the first new commit" &>> /dev/null | ||
| if [ "$LAST_STATUS" = "0" ]; then | ||
| FIRST_COMMIT="$(git bisect next 2>&1 | head -n 1 | cut -f1 -d" ")" | ||
| git checkout "$FIRST_COMMIT" &>> /dev/null | ||
| break | ||
| fi | ||
|
|
||
| git bisect next | grep "Bisecting" | ||
| if [ "$LAST_STATUS" != "0" ]; then | ||
| break | ||
| fi | ||
|
|
||
| git checkout . &>> /dev/null | ||
|
|
||
| CACHENAME="$(git show -s --format='%as-%ct-%H' HEAD)" | ||
| compile_and_cp_to_cache "$CACHENAME" | ||
| LAST_STATUS=$(run_cargo) | ||
| if [ "$LAST_STATUS" = "$INITIAL_COMPILATION_STATUS" ]; then | ||
| git bisect new &>> /dev/null | ||
| else | ||
| git bisect old &>> /dev/null | ||
| fi | ||
| done | ||
|
|
||
| FOUND_COMMIT="$(git show -s --format='%H' HEAD)" | ||
|
|
||
| echo -e "${BOLD_GREEN}Found!${NC} - ${FOUND_COMMIT}" | ||
| echo "" | ||
|
|
||
|
|
||
| # check this commit has the same behaviour | ||
| echo -n "checking the found commit has the same behaviour as the initial commit..." | ||
|
|
||
| CACHENAME="$(git show -s --format='%as-%ct-%H' HEAD)" | ||
| compile_and_cp_to_cache "$CACHENAME" | ||
| LAST_STATUS=$(run_cargo) | ||
|
|
||
| if [ "$INITIAL_COMPILATION_STATUS" != "$LAST_STATUS" ]; then | ||
| echo -e " ${BOLD_RED}Unexpected exit code${NC}" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo -e " ${BOLD_GREEN}Ok${NC}" | ||
|
|
||
| ## check the previous commit has the inverse | ||
| echo -n "checking the previous commit has the inverse behaviour as the initial commit..." | ||
|
|
||
| git checkout HEAD~1 &>> /dev/null | ||
| PREVIOUS_COMMIT="$(git show -s --format='%H' HEAD)" | ||
| CACHENAME="$(git show -s --format='%as-%ct-%H' HEAD)" | ||
| compile_and_cp_to_cache "$CACHENAME" | ||
| LAST_STATUS=$(run_cargo) | ||
|
|
||
| if [ "$INITIAL_COMPILATION_STATUS" = "$LAST_STATUS" ]; then | ||
| echo -e " ${BOLD_RED}Unexpected exit code${NC}" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo -e " ${BOLD_GREEN}Ok${NC}" | ||
|
|
||
| echo "" | ||
|
|
||
| git checkout . &>> /dev/null | ||
| git bisect reset &>> /dev/null | ||
|
|
||
| git checkout "$FOUND_COMMIT" &>> /dev/null | ||
| echo "This is the commit that changed the compiler behavior" | ||
| git log -1 --oneline |
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,26 @@ | ||
| #!/bin/bash | ||
|
|
||
| # This script extracts full test names and test gas usage from a `forc test` output. | ||
| # Usage: `forc test | test_gas_usage.sh`. | ||
|
|
||
| current_suite="" | ||
| results=() | ||
|
|
||
| while IFS= read -r line; do | ||
| # printf 'Line: %s\n' "$line" | ||
|
|
||
| if [[ $line =~ ^tested\ --\ ([^[:space:]]+) ]]; then | ||
| current_suite="${BASH_REMATCH[1]}" | ||
| fi | ||
| # printf 'Suite: %s\n' "$current_suite" | ||
|
|
||
| if [[ $line =~ ^[[:space:]]*test[[:space:]]([^\ ]+)[[:space:]]\.\.\.[[:space:]].*,[[:space:]]([0-9]+)[[:space:]]gas\) ]]; then | ||
| test_name="${BASH_REMATCH[1]}" | ||
| # printf 'Test: %s\n' "$test_name" | ||
| gas="${BASH_REMATCH[2]}" | ||
| # printf 'Gas: %s\n' "$gas" | ||
| results+=("${current_suite}::${test_name},${gas}") | ||
| fi | ||
| done | ||
|
|
||
| printf '%s\n' "${results[@]}" | sort |
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,38 @@ | ||
| #!/bin/bash | ||
|
|
||
| # This script compares test gas usage from two outputs of the `test_gas_usage.sh` script. | ||
| # The result of the comparison can be printed either as a Markdown table or a CSV file. | ||
| # Usage: `compare_test_gas_usage.sh <before>.csv <after>.csv [MD|CSV]`. | ||
|
|
||
| #!/bin/bash | ||
|
|
||
| #!/bin/bash | ||
xunilrj marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| if [ "$#" -lt 2 ] || [ "$#" -gt 3 ]; then | ||
| echo "Usage: $0 <before>.csv <after>.csv [MD|CSV]" | ||
| exit 1 | ||
| fi | ||
|
|
||
| before_file="$1" | ||
| after_file="$2" | ||
| output_format="${3:-MD}" | ||
|
|
||
| if [ "$output_format" == "CSV" ]; then | ||
| echo "Test,Before,After,Percentage" | ||
| else | ||
| echo "| Test | Before | After | Percentage |" | ||
| echo "|------|--------|-------|------------|" | ||
| fi | ||
|
|
||
| paste -d, "$before_file" "$after_file" | while IFS=',' read -r test1 before test2 after; do | ||
| if [ "$before" != "$after" ]; then | ||
| diff=$((before - after)) | ||
| percent=$(LC_NUMERIC=C awk -v d="$diff" -v b="$before" 'BEGIN { printf "%.2f", (d / b) * 100 }') | ||
|
|
||
| if [ "$output_format" == "CSV" ]; then | ||
| echo "$test1,$before,$after,$percent" | ||
| else | ||
| echo "| $test1 | $before | $after | $percent% |" | ||
| fi | ||
| fi | ||
| done | ||
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.
Uh oh!
There was an error while loading. Please reload this page.