This repository was archived by the owner on Dec 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Post contract size diff to parent PR #16
Merged
Merged
Changes from all commits
Commits
Show all changes
97 commits
Select commit
Hold shift + click to select a range
7fc45cb
Installation has been moved to docker container
cmichi bc722e9
Output markdown table
cmichi 8e51331
Experiment with comment posting
cmichi 7ec4402
Experiment with comment posting
cmichi 2942307
Fix `curl`
cmichi a8de6fb
Fix token
cmichi 77a8945
Fix token
cmichi 49709ae
Fix path
cmichi 1be5be4
Fix path
cmichi b00898b
Fix path
cmichi 9fa28e4
Fix body
cmichi 5870eb8
Remove for testing unnecessary jobs
cmichi f20a0f2
Fix JSON
cmichi 4108d49
Post comparison results
cmichi 4ab0f0b
Fix `tr`
cmichi 901175f
Install jq
cmichi 0eca1ba
Install jq
cmichi 8f7a247
Debug jq execution
cmichi be3aa64
Fix quoting issues
cmichi f13829c
Fix quoting issues
cmichi 89adf32
Fix posting
cmichi ac65d89
Add debug output
cmichi 93875a5
Fix indentation
cmichi 9dec06e
Build correct uri
cmichi 3322dd0
Fix filename
cmichi 3b73fe5
Fix var
cmichi e272581
Debug url
cmichi 01735e6
Fix url
cmichi c506b5d
Fix url
cmichi e9e1396
Fix url
cmichi 6d1d457
Use raw
cmichi 2480e3d
Update verb
cmichi b9f0fb6
Improve comment
cmichi 2ce86b0
Improve comment
cmichi f0781bb
Improve comment
cmichi 3a34b4b
Prettify comment
cmichi 34606df
Improve readability
cmichi 6500284
Improve readability
cmichi ea7f3f0
Improve readability
cmichi 10e3b60
Fix syntax
cmichi aa98892
Fix syntax
cmichi 80de5ec
Fix syntax
cmichi bc1e9aa
Fix syntax
cmichi 49b6c03
Fix md
cmichi 011494d
Fix md
cmichi cd35543
Output total size as well
cmichi 995609e
Update text
cmichi c4aff3a
Update command
cmichi db95af9
Update command
cmichi e5282ac
Fix syntax
cmichi dc9d178
Fix syntax
cmichi 77f39df
Fix syntax
cmichi f763dfc
Fix syntax
cmichi 179fa9f
Fix syntax
cmichi e4cac50
Fix syntax
cmichi 3a9352f
Fix syntax
cmichi fa0612f
Prettify output
cmichi 6a330bd
Sort everything
cmichi 7868764
Fix typos and grammar
cmichi 1a8e135
Prettify code and remove fixed `TRGR_REF`
cmichi d610022
Revert "Remove for testing unnecessary jobs"
cmichi f30c673
Improve script
cmichi 0a9093e
Only compare if necessary
cmichi 9fc6ada
Fix grammar
cmichi f474d66
Improve script readability
cmichi a1391ed
Revert me: Temporarily disable tests
cmichi 4295120
Fix syntax
cmichi bd1a27c
Fix valid variant
cmichi c6fe6a5
Fix valid variant
cmichi 6f842e7
Revert "Revert me: Temporarily disable tests"
cmichi ab6a123
Ensure unique entries
cmichi b1ffe78
Format numbers
cmichi b25ae4f
Remove xargs
cmichi 49aaf79
Use awk
cmichi 2a06a7e
Fix parsing
cmichi ffc0954
Fix syntax
cmichi b2665ff
Fix syntax
cmichi 98148ef
Format numbers
cmichi f3ab434
Strip out no-changes
cmichi 75970d0
Improve displaying
cmichi febb11a
Improve displaying
cmichi 35308c9
Rename job
cmichi aefc56a
Move logic to script
cmichi 48f1fdb
Fix order
cmichi becf1eb
Handle multi-lines
cmichi d52a8f6
Handle indentation correctly
cmichi d23fc9a
Improve text
cmichi 780c17c
Improve text
cmichi 3f68d7a
Fix text
cmichi b3047ba
Improve script
cmichi 63d0118
Fix url
cmichi 04540ac
Update .scripts/evaluate-examples-size-changes.sh
ed6f0a5
Update .scripts/evaluate-examples-size-changes.sh
39eb682
Update .scripts/evaluate-examples-size-changes.sh
14b7475
Update .scripts/evaluate-examples-size-changes.sh
484816a
Improve naming
cmichi 1edd192
Add comment
cmichi 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 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,77 @@ | ||
#!/bin/bash | ||
|
||
# Evaluates size changes of the ink! examples and posts the results | ||
# as a comment on GitHub. | ||
# | ||
# Usage: | ||
# ./evaluate-examples-size-changes.sh \ | ||
# <path_to_baseline.csv> <path_to_size_change.csv> \ | ||
# <github_url_to_comments_of_pr> | ||
|
||
set -eux | ||
|
||
BASELINE_FILE=$1 | ||
COMPARISON_FILE=$2 | ||
PR_COMMENTS_URL=$3 | ||
|
||
echo "$BASELINE_FILE will be compared to $COMPARISON_FILE" | ||
|
||
csv-comparator $BASELINE_FILE $COMPARISON_FILE | \ | ||
sort | \ | ||
awk -F"," '{printf "`%s`,%.2f K,%.2f K\n", $1, $2, $3}' | \ | ||
# prepend a plus in front of all positive numbers | ||
sed --regexp-extended 's/^([0-9])/,+\1/g' | \ | ||
sed --regexp-extended 's/,([0-9])/,+\1/g' | \ | ||
tee pure-contract-size-diff.csv | ||
|
||
# Append the original optimized size (i.e. not the delta) to the end of each line | ||
cat $COMPARISON_FILE | \ | ||
sort | uniq | \ | ||
egrep --only-matching ', [0-9]+\.[0-9]+$' | \ | ||
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. I wonder if maybe we should install |
||
awk -F", " '{printf ",%.2f K\n", $2}' | \ | ||
tee total-optimized-size.csv | ||
|
||
paste -d "" pure-contract-size-diff.csv total-optimized-size.csv | tee combined.csv | ||
|
||
echo " ,Δ Original Size,Δ Optimized Size,Total Optimized Size" | tee contract-size-diff.csv | ||
cat combined.csv | sed 's/+0.00 K//g' | tee --append contract-size-diff.csv | ||
csv2md --pretty < contract-size-diff.csv | tee contract-size-diff.md | ||
|
||
# Replace `\n` so that it works propely when submitted to the GitHub API. | ||
# Also align the table text right. | ||
cat contract-size-diff.md | \ | ||
sed 's/---|/---:|/g' | \ | ||
sed --regexp-extended 's/(-+)\:/:\1/' | \ | ||
sed 's/$/\\n/g' | \ | ||
tr -d '\n' | \ | ||
tee contract-size-diff-newlines.md | ||
COMMENT=$(cat contract-size-diff-newlines.md) | ||
|
||
# If there is already a comment by the user `paritytech-ci` in the ink! PR which triggered | ||
# this run, then we can just edit this comment (using `PATCH` instead of `POST`). | ||
POSSIBLY_COMMENT_URL=$(curl --silent $PR_COMMENTS_URL | \ | ||
jq -r ".[] | select(.user.login == \"paritytech-ci\") | .url" | \ | ||
head -n1 | ||
) | ||
echo $POSSIBLY_COMMENT_URL | ||
|
||
VERB="POST" | ||
if [ ! -z "$POSSIBLY_COMMENT_URL" ]; then | ||
VERB="PATCH"; | ||
PR_COMMENTS_URL="$POSSIBLY_COMMENT_URL" | ||
fi | ||
|
||
echo $VERB | ||
echo $PR_COMMENTS_URL | ||
|
||
UPDATED=$(TZ='Europe/Berlin' date) | ||
CC_VERSION=$(cargo-contract --version | egrep --only-matching "cargo-contract [^-]*") | ||
curl -X ${VERB} ${PR_COMMENTS_URL} \ | ||
-H "Cookie: logged_in=no" \ | ||
-H "Authorization: token ${GITHUB_TOKEN}" \ | ||
-H "Content-Type: application/json; charset=utf-8" \ | ||
-d $"{ \ | ||
\"body\": \"## 🦑 📈 ink! Example Contracts ‒ Size Change Report 📉 🦑\\n \ | ||
These are the results of building the \`examples/*\` contracts from this branch with \`$CC_VERSION\`. \\n\\n\ | ||
${COMMENT}\n\n[Link to the run](https://gitlab.parity.io/parity/ink-waterfall/-/pipelines/${CI_PIPELINE_ID}) | Last update: ${UPDATED}\" \ | ||
}" |
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's this doing? My regex brain is too smol
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.
Prepends a plus in front of positive numbers. Yeah we could definitely move all of this into
csv-comparator
. I added a comment as well.