-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added a script for cleaning up commits
and the srtool
- Loading branch information
Showing
2 changed files
with
132 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
name: Srtool build | ||
|
||
env: | ||
SUBWASM_VERSION: 0.20.0 | ||
|
||
on: | ||
pull_request: | ||
types: [opened, edited, synchronize] | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build: | ||
if: "contains(github.event.pull_request.title, 'Release')" | ||
name: Build ${{ matrix.chain }} ${{ github.event.inputs.ref }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
chain: ["amplitude", "pendulum"] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.event.inputs.ref }} | ||
fetch-depth: 0 | ||
|
||
- name: Srtool build | ||
id: srtool_build | ||
uses: chevdor/[email protected] | ||
with: | ||
chain: ${{ matrix.chain }} | ||
runtime_dir: runtime/${{ matrix.chain }} | ||
# this is important to avoid build fail. See https://github.com/paritytech/srtool/issues/62 | ||
tag: 1.66.1 | ||
- name: Summary | ||
run: | | ||
echo '${{ steps.srtool_build.outputs.json }}' | jq > ${{ matrix.chain }}-srtool-digest.json | ||
cat ${{ matrix.chain }}-srtool-digest.json | ||
echo "Runtime location: ${{ steps.srtool_build.outputs.wasm }}" | ||
# it takes a while to build the runtime, so let's save the artifact as soon as we have it | ||
- name: Archive Artifacts for ${{ matrix.chain }} | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: ${{ matrix.chain }}-runtime | ||
path: | | ||
${{ steps.srtool_build.outputs.wasm }} | ||
${{ steps.srtool_build.outputs.wasm_compressed }} | ||
${{ matrix.chain }}-srtool-digest.json | ||
# We now get extra information thanks to subwasm, | ||
- name: Install subwasm ${{ env.SUBWASM_VERSION }} | ||
run: | | ||
wget https://github.com/chevdor/subwasm/releases/download/v${{ env.SUBWASM_VERSION }}/subwasm_linux_amd64_v${{ env.SUBWASM_VERSION }}.deb | ||
sudo dpkg -i subwasm_linux_amd64_v${{ env.SUBWASM_VERSION }}.deb | ||
subwasm --version | ||
- name: Show Runtime information | ||
run: | | ||
subwasm info ${{ steps.srtool_build.outputs.wasm }} | ||
subwasm info ${{ steps.srtool_build.outputs.wasm_compressed }} | ||
subwasm --json info ${{ steps.srtool_build.outputs.wasm }} > ${{ matrix.chain }}-info.json | ||
subwasm --json info ${{ steps.srtool_build.outputs.wasm_compressed }} > ${{ matrix.chain }}-info_compressed.json | ||
- name: Extract the metadata | ||
run: | | ||
subwasm meta ${{ steps.srtool_build.outputs.wasm }} | ||
subwasm --json meta ${{ steps.srtool_build.outputs.wasm }} > ${{ matrix.chain }}-metadata.json | ||
- name: Archive Subwasm results | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: ${{ matrix.chain }}-runtime-${{ github.sha }} | ||
path: | | ||
${{ matrix.chain }}-info.json | ||
${{ matrix.chain }}-info_compressed.json | ||
${{ matrix.chain }}-metadata.json | ||
${{ matrix.chain }}-diff.txt |
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,56 @@ | ||
#!/bin/bash | ||
|
||
chosenRuntime="$1" | ||
## forcefully set to lowercase | ||
chosenRuntime=$( echo "$chosenRuntime" | tr -s '[:upper:]' '[:lower:]') | ||
|
||
|
||
## list of runtimes available | ||
runtimesList=("foucoco" "amplitude" "pendulum") | ||
|
||
excludeRuntimes='' | ||
## will make comparison case-insensitive | ||
for runtime in "${runtimesList[@]}"; do | ||
## exclude runtimes that is NOT chosen | ||
if [[ "$runtime" != "$chosenRuntime" ]]; then | ||
if [ -z "${excludeRuntimes}" ]; then | ||
excludeRuntimes=$runtime | ||
else | ||
excludeRuntimes="$excludeRuntimes|$runtime" | ||
fi | ||
fi | ||
done | ||
|
||
if [ -z "${excludeRuntimes}" ]; then | ||
echo "unsupported runtime "$chosenRuntime | ||
exit | ||
fi | ||
|
||
## get the latest tag of this runtime | ||
lastVersionName=$(git describe --abbrev=0 --tags --always `git rev-list --tags` | grep -i "$chosenRuntime*" -m 1) | ||
echo "last version: "$lastVersionName | ||
|
||
## extract the version number of the version | ||
lastVersionNumber=$(echo $lastVersionName | sed 's/[^0-9]*//g') | ||
newVersionName=$chosenRuntime-release-$((lastVersionNumber+1)) | ||
echo "new version: "$newVersionName | ||
fileName="commits_for_"$newVersionName | ||
|
||
## remove the file if existed | ||
if test -f $fileName; then | ||
rm $fileName | ||
fi | ||
|
||
## get the commits since the last tag | ||
latestCommitOfLastVersion=$(git log $lastVersionName --oneline --max-count=1 | cut -c1-7) | ||
|
||
if [ -z "${latestCommitOfLastVersion}" ]; then | ||
echo "last version is up to date." | ||
exit | ||
fi | ||
|
||
## only list commits related to this runtime and the general code changes | ||
## save to file commits_for_<chosen_runtime>-release-<new version number>.txt | ||
git log $latestCommitOfLastVersion..origin --oneline | grep -i -Ev "$excludeRuntimes" |cut -c1-7 >> $fileName | ||
|
||
|