-
Notifications
You must be signed in to change notification settings - Fork 53
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
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 856d0eb
Dancebox introduction
girazoki 50ac383
few cosmetic changesd
girazoki e08fa26
start preparing build-runtime job
girazoki ee42c02
start testing
girazoki af3afba
Add job
girazoki 0e78b6a
modify rust toolchain to see if that passes
girazoki 6a30336
Revert "modify rust toolchain to see if that passes"
girazoki ca74e20
Merge remote-tracking branch 'origin/master' into girazoki-runtime-jobs
girazoki c15e675
fix
girazoki fbc0ab1
fmt
girazoki 558a13a
tools to publish wasm
girazoki 4bc7ba8
Merge remote-tracking branch 'origin/master' into girazoki-dancebox-i…
girazoki 5b7a417
Merge remote-tracking branch 'origin/girazoki-dancebox-introduction' …
girazoki 87d8a7a
remove publish runtime
girazoki 35c1c36
Merge remote-tracking branch 'origin/girazoki-dancebox-introduction' …
girazoki 30aa8a4
modify tools
girazoki 5c34ca8
trigger on push
girazoki 8d134df
fmt
girazoki 3fc4826
tsconfig
girazoki 0e6b022
github-utils
girazoki 577c91c
wip
girazoki 9010fce
try-with-tags
girazoki 7d02e19
revert and put it in correct place
girazoki 081f89f
use new tag
girazoki f23dd44
Merge remote-tracking branch 'origin/master' into girazoki-dancebox-i…
girazoki 3715c36
build runtime remove
girazoki 0954ad8
dummycollator for full node
girazoki 319ff62
Merge remote-tracking branch 'origin/girazoki-dancebox-introduction' …
girazoki 7919413
add back build runtime
girazoki 0d66e30
dancebox for orchestrator
girazoki 859192d
revert back
girazoki bcbf86e
get back to dispatch flow
girazoki a832dce
npm for pnpm
girazoki 1537e23
trigger to see if it works
girazoki c88f3e3
Revert "npm for pnpm"
girazoki 751421b
Revert "Revert "npm for pnpm""
girazoki 4129cc2
Revert "Revert "Revert "npm for pnpm"""
girazoki c6b4ce1
workflow dispatch
girazoki c27f6b7
fail job if docker image for sr-tool is not found
girazoki a475dc9
Comments on actions
girazoki 4995b75
Merge remote-tracking branch 'origin/master' into girazoki-runtime-jobs
girazoki 9fff59f
trigger on push
girazoki 51d867b
rename
girazoki ad70101
Update cargo lock
girazoki 5997334
Revert "trigger on push"
girazoki 6401985
Merge remote-tracking branch 'origin/master' into girazoki-runtime-jobs
girazoki 76bed86
remove pnpm
girazoki 87169b6
fix yml
girazoki 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
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 | ||
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 |
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,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 | ||
} |
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,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(); |
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.
changing to use label instead of generic self-hosted will be easier for maintenance
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.
yes, we have an issue for that already. But will do a PR changing all those at once.