Skip to content
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

start preparing build-runtime job #127

Merged
merged 49 commits into from
Jun 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
2addf30
Start moving things around
girazoki Jun 13, 2023
856d0eb
Dancebox introduction
girazoki Jun 13, 2023
50ac383
few cosmetic changesd
girazoki Jun 14, 2023
e08fa26
start preparing build-runtime job
girazoki Jun 19, 2023
ee42c02
start testing
girazoki Jun 19, 2023
af3afba
Add job
girazoki Jun 19, 2023
0e78b6a
modify rust toolchain to see if that passes
girazoki Jun 19, 2023
6a30336
Revert "modify rust toolchain to see if that passes"
girazoki Jun 19, 2023
ca74e20
Merge remote-tracking branch 'origin/master' into girazoki-runtime-jobs
girazoki Jun 19, 2023
c15e675
fix
girazoki Jun 19, 2023
fbc0ab1
fmt
girazoki Jun 19, 2023
558a13a
tools to publish wasm
girazoki Jun 19, 2023
4bc7ba8
Merge remote-tracking branch 'origin/master' into girazoki-dancebox-i…
girazoki Jun 19, 2023
5b7a417
Merge remote-tracking branch 'origin/girazoki-dancebox-introduction' …
girazoki Jun 19, 2023
87d8a7a
remove publish runtime
girazoki Jun 19, 2023
35c1c36
Merge remote-tracking branch 'origin/girazoki-dancebox-introduction' …
girazoki Jun 19, 2023
30aa8a4
modify tools
girazoki Jun 19, 2023
5c34ca8
trigger on push
girazoki Jun 19, 2023
8d134df
fmt
girazoki Jun 19, 2023
3fc4826
tsconfig
girazoki Jun 19, 2023
0e6b022
github-utils
girazoki Jun 19, 2023
577c91c
wip
girazoki Jun 19, 2023
9010fce
try-with-tags
girazoki Jun 20, 2023
7d02e19
revert and put it in correct place
girazoki Jun 20, 2023
081f89f
use new tag
girazoki Jun 20, 2023
f23dd44
Merge remote-tracking branch 'origin/master' into girazoki-dancebox-i…
girazoki Jun 20, 2023
3715c36
build runtime remove
girazoki Jun 20, 2023
0954ad8
dummycollator for full node
girazoki Jun 20, 2023
319ff62
Merge remote-tracking branch 'origin/girazoki-dancebox-introduction' …
girazoki Jun 20, 2023
7919413
add back build runtime
girazoki Jun 20, 2023
0d66e30
dancebox for orchestrator
girazoki Jun 20, 2023
859192d
revert back
girazoki Jun 20, 2023
bcbf86e
get back to dispatch flow
girazoki Jun 21, 2023
a832dce
npm for pnpm
girazoki Jun 21, 2023
1537e23
trigger to see if it works
girazoki Jun 21, 2023
c88f3e3
Revert "npm for pnpm"
girazoki Jun 21, 2023
751421b
Revert "Revert "npm for pnpm""
girazoki Jun 21, 2023
4129cc2
Revert "Revert "Revert "npm for pnpm"""
girazoki Jun 21, 2023
c6b4ce1
workflow dispatch
girazoki Jun 21, 2023
c27f6b7
fail job if docker image for sr-tool is not found
girazoki Jun 22, 2023
a475dc9
Comments on actions
girazoki Jun 22, 2023
4995b75
Merge remote-tracking branch 'origin/master' into girazoki-runtime-jobs
girazoki Jun 22, 2023
9fff59f
trigger on push
girazoki Jun 22, 2023
51d867b
rename
girazoki Jun 22, 2023
ad70101
Update cargo lock
girazoki Jun 22, 2023
5997334
Revert "trigger on push"
girazoki Jun 22, 2023
6401985
Merge remote-tracking branch 'origin/master' into girazoki-runtime-jobs
girazoki Jun 22, 2023
76bed86
remove pnpm
girazoki Jun 22, 2023
87169b6
fix yml
girazoki Jun 22, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
154 changes: 154 additions & 0 deletions .github/workflows/publish-runtime.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
name: Publish Runtime Draft

# The code (like generate-release-body) will be taken from the tag versions, not master
on:
workflow_dispatch:
inputs:
from:
description: tag (ex. runtime-53) to retrieve commit diff from
required: true
to:
description: tag (ex. runtime-155) to generate release note and srtool runtimes from
required: true

jobs:
####### Build runtimes with srtool #######

setup-scripts:
runs-on: self-hosted
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changing to use label instead of generic self-hosted will be easier for maintenance

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, we have an issue for that already. But will do a PR changing all those at once.

steps:
## Use scripts and tools from current branch
- uses: actions/checkout@v3
girazoki marked this conversation as resolved.
Show resolved Hide resolved
- name: Upload scripts
uses: actions/upload-artifact@v3
with:
name: original-scripts
path: scripts
- name: Upload tools
uses: actions/upload-artifact@v3
with:
name: original-tools
path: tools

build-srtool-runtimes:
needs: ["setup-scripts"]
runs-on: self-hosted
strategy:
matrix:
chain: ["dancebox"]
srtool_image:
- purestake/srtool
srtool_image_tag:
- 1.69.0
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.inputs.to }}
- name: Download original scripts
uses: actions/download-artifact@v3
with:
name: original-scripts
path: original-scripts
- name: Build & Push purestake/srtool image
if: github.repository == 'moondance-labs/tanssi'
run: |
docker pull "${{ matrix.srtool_image }}:${{ matrix.srtool_image_tag }}" && image_exists=true || image_exists=false

if [[ $image_exists = "false" ]]; then
girazoki marked this conversation as resolved.
Show resolved Hide resolved
exit 1
else
echo skiping build "${{ matrix.srtool_image }}:${{ matrix.srtool_image_tag }}", image already exists
fi
- name: Build runtime using "${{ matrix.srtool_image }}:${{ matrix.srtool_image_tag }}"
id: srtool_build
env:
GH_WORKFLOW_MATRIX_CHAIN: ${{ matrix.chain }}
GH_WORKFLOW_MATRIX_SRTOOL_IMAGE: ${{ matrix.srtool_image }}
GH_WORKFLOW_MATRIX_SRTOOL_IMAGE_TAG: ${{ matrix.srtool_image_tag }}
run: |
chmod u+x ./original-scripts/build-runtime-srtool.sh
./original-scripts/build-runtime-srtool.sh
- name: Summary
run: |
echo '${{ steps.srtool_build.outputs.json }}' | jq . > ${{ matrix.chain }}-srtool-digest.json
cat ${{ matrix.chain }}-srtool-digest.json
cp ${{ steps.srtool_build.outputs.wasm_compressed }} ${{ matrix.chain }}-runtime.compact.compressed.wasm
- name: Archive Artifacts for ${{ matrix.chain }}
uses: actions/upload-artifact@v2
with:
name: ${{ matrix.chain }}-runtime
path: |
${{ matrix.chain }}-runtime.compact.compressed.wasm
${{ matrix.chain }}-srtool-digest.json


####### Prepare the release draft #######
publish-draft-release:
runs-on: ubuntu-latest
needs: ["setup-scripts", "build-srtool-runtimes"]
outputs:
release_url: ${{ steps.create-release.outputs.html_url }}
asset_upload_url: ${{ steps.create-release.outputs.upload_url }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.event.inputs.to }}
fetch-depth: 0
- name: Download dancebox runtime
uses: actions/download-artifact@v3.0.2
with:
name: dancebox-runtime
path: build
- name: Use Node.js 18.x
uses: actions/setup-node@v3
with:
node-version: 18.x
- name: Download Original Tools
uses: actions/download-artifact@v3
with:
name: original-tools
path: original-tools
- name: Generate release body
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
id: generate-release-body
working-directory: original-tools
run: |
yarn
yarn -s run ts-node github/generate-runtimes-body.ts --owner "${{ github.repository_owner }}" --repo "$(basename ${{ github.repository }})" --from "${{ github.event.inputs.from }}" --to "${{ github.event.inputs.to }}" --srtool-report-folder '../build/' > ../body.md - name: Get runtime version
- name: Get runtime version
id: get-runtime-ver
run: |
runtime_dancebox_ver="$(cat ./runtime/dancebox/src/lib.rs | grep -o 'spec_version: [0-9]*' | tail -1 | grep -o '[0-9]*')"
echo "runtime_dancebox_ver=$runtime_dancebox_ver" >> $GITHUB_OUTPUT
mv build/dancebox-runtime.compact.compressed.wasm dancebox-runtime-${runtime_dancebox_ver}.wasm
mv build/dancebox-srtool-digest.json dancebox-runtime-${runtime_dancebox_ver}-srtool-digest.json
- name: Create draft release
id: create-release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.event.inputs.to }}
release_name: Runtime ${{ github.event.inputs.to }}
body_path: body.md
draft: true
- name: Upload dancebox wasm
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create-release.outputs.upload_url }}
asset_path: dancebox-runtime-${{ steps.get-runtime-ver.outputs.runtime_dancebox_ver }}.wasm
asset_name: dancebox-runtime-${{ steps.get-runtime-ver.outputs.runtime_dancebox_ver }}.wasm
asset_content_type: application/octet-stream
- name: Upload dancebox srtool digest
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create-release.outputs.upload_url }}
asset_path: dancebox-runtime-${{ steps.get-runtime-ver.outputs.runtime_dancebox_ver }}-srtool-digest.json
asset_name: dancebox-runtime-${{ steps.get-runtime-ver.outputs.runtime_dancebox_ver }}.srtool-digest.json
asset_content_type: application/json
44 changes: 44 additions & 0 deletions scripts/build-runtime-srtool.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@

# CARGO_NET_GIT_FETCH_WITH_CLI=true and --entrypoint /srtool/entrypoint.sh
# are required to allow srtool to fetch from github private repositories

# self-hosted runner uses user `maintenance` to match srtool `builder` user 1001
# $(~/srtool/uid-gid-mapping.sh 1001 | xargs) is used to map the user and group

# Docker command to generate JSON blob of the runtime
CMD="docker run \
-i \
--rm \
$(~/srtool/uid-gid-mapping.sh 1001 | xargs) \
-e CARGO_NET_GIT_FETCH_WITH_CLI=true \
-e PACKAGE=${GH_WORKFLOW_MATRIX_CHAIN}-runtime \
-e RUNTIME_DIR=runtime/${GH_WORKFLOW_MATRIX_CHAIN} \
-v ${PWD}:/build \
-v /home/${USER}/srtool/.ssh:/home/builder/.ssh \
-v /home/${USER}/srtool/entrypoint.sh:/srtool/entrypoint.sh \
--entrypoint /srtool/entrypoint.sh \
${GH_WORKFLOW_MATRIX_SRTOOL_IMAGE}:${GH_WORKFLOW_MATRIX_SRTOOL_IMAGE_TAG} \
build --app --json -cM"

# Here we run the command and stream the output (JSON blob) to a variable
stdbuf -oL $CMD | {
while IFS= read -r line
do
echo ║ $line
JSON="$line"
done

echo "json=$JSON" >> $GITHUB_OUTPUT

PROP=`echo $JSON | jq -r .runtimes.compact.prop`
echo "proposal_hash=$PROP" >> $GITHUB_OUTPUT

WASM=`echo $JSON | jq -r .runtimes.compact.wasm`
echo "wasm=$WASM" >> $GITHUB_OUTPUT

Z_WASM=`echo $JSON | jq -r .runtimes.compressed.wasm`
echo "wasm_compressed=$Z_WASM" >> $GITHUB_OUTPUT

IPFS=`echo $JSON | jq -r .runtimes.compact.ipfs`
echo "ipfs=$IPFS" >> $GITHUB_OUTPUT
}
83 changes: 83 additions & 0 deletions tools/github/generate-release-body.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import { Octokit } from "octokit";
import yargs from "yargs";
import { getCommitAndLabels, getCompareLink } from "./github-utils";

const BINARY_CHANGES_LABEL = "B5-clientnoteworthy";
const BREAKING_CHANGES_LABEL = "D2-breaksapi";

function capitalize(s) {
return s[0].toUpperCase() + s.slice(1);
}

async function main() {
const argv = yargs(process.argv.slice(2))
.usage("Usage: npm run ts-node github/generate-release-body.ts [args]")
.version("1.0.0")
.options({
from: {
type: "string",
describe: "previous tag to retrieve commits from",
required: true,
},
to: {
type: "string",
describe: "current tag being drafted",
required: true,
},
owner: {
type: "string",
describe: "Repository owner (Ex: moondance-labs)",
required: true,
},
repo: {
type: "string",
describe: "Repository name (Ex: dancebox)",
required: true,
},
})
.demandOption(["from", "to"])
.help().argv;

const octokit = new Octokit({
auth: process.env.GITHUB_TOKEN || undefined,
});

const previousTag = argv.from;
const newTag = argv.to;

const moduleLinks = ["substrate", "polkadot", "cumulus", "frontier"].map((repoName) => ({
name: repoName,
link: getCompareLink(repoName, previousTag, newTag),
}));

const { prByLabels } = await getCommitAndLabels(
octokit,
argv.owner,
argv.repo,
previousTag,
newTag
);
const filteredPr = prByLabels[BINARY_CHANGES_LABEL] || [];

const printPr = (pr) => {
if (pr.labels.includes(BREAKING_CHANGES_LABEL)) {
return "⚠️ " + pr.title + " (#" + pr.number + ")";
} else {
return pr.title + " (#" + pr.number + ")";
}
};

const template = `
## Changes

${filteredPr.map((pr) => `* ${printPr(pr)}`).join("\n")}

## Dependency changes

Tanssi: https://github.com/${argv.owner}/${argv.repo}/compare/${previousTag}...${newTag}
${moduleLinks.map((modules) => `${capitalize(modules.name)}: ${modules.link}`).join("\n")}
`;
console.log(template);
}

main();
Loading