Manual Build - Fellowship #70
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
name: Manual Build - Fellowship | |
env: | |
SUBWASM_VERSION: 0.20.0 | |
TOML_CLI_VERSION: 0.2.4 | |
on: | |
workflow_dispatch: | |
inputs: | |
image: | |
description: The SRTOOL image to use use | |
default: paritytech/srtool | |
srtool_tag: | |
description: The SRTOOL tag to use | |
default: 1.77.0 | |
required: false | |
repo: | |
description: The repo to be used to build runtimes from | |
default: polkadot-fellows/runtimes | |
required: false | |
ref: | |
description: The ref to be used for the repo | |
default: main | |
required: false | |
cache: | |
description: By default, caching will be used but you can turn it off here if you provide 'false' | |
default: true | |
schedule: | |
- cron: "00 04 * * 1" | |
jobs: | |
find-runtimes: | |
name: Scan repo ${{ inputs.repo }} ${{ inputs.ref }} | |
outputs: | |
runtime: ${{ steps.get_runtimes_list.outputs.runtime }} | |
commit_hash: ${{ steps.get_commit_hash.outputs.commit_hash }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout the srtool repo | |
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 | |
with: | |
fetch-depth: 0 | |
path: srtool | |
- name: Checkout repo ${{ inputs.repo }} | |
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 | |
with: | |
repository: ${{ inputs.repo }} | |
ref: ${{ inputs.ref }} | |
fetch-depth: 0 | |
path: fellows-runtimes | |
- name: Get commit hash for ${{ inputs.repo }} ${{ inputs.ref }} | |
id: get_commit_hash | |
working-directory: fellows-runtimes | |
run: | | |
echo "commit_hash=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | |
- name: Cache runtimes list for ${{ steps.get_commit_hash.outputs.commit_hash }} | |
id: cache_runtimes_list | |
if: inputs.cache == 'true' | |
uses: actions/cache@v3 | |
with: | |
key: runtimes-list-${{ steps.get_commit_hash.outputs.commit_hash }} | |
path: | | |
fellows-runtimes/runtimes_list.json | |
- name: Install tooling | |
if: ${{ steps.cache_runtimes_list.outputs.cache-hit != 'true' }} | |
run: | | |
URL=https://github.com/chevdor/toml-cli/releases/download/v${{ env.TOML_CLI_VERSION }}/toml_linux_amd64_v${{ env.TOML_CLI_VERSION }}.deb | |
curl -L $URL --output toml.deb | |
sudo dpkg -i toml.deb | |
toml --version; jq --version | |
- name: Scan runtimes | |
if: ${{ steps.cache_runtimes_list.outputs.cache-hit != 'true' }} | |
run: | | |
. ./srtool/scripts/lib.sh | |
echo "Github workspace: ${{ github.workspace }}" | |
echo "Current folder: $(pwd)"; ls -al | |
cd fellows-runtimes; ls -al | |
MATRIX=$(find_runtimes | tee runtimes_list.json) | |
echo $MATRIX | |
- name: Get runtimes list | |
id: get_runtimes_list | |
run: | | |
cd fellows-runtimes; ls -al | |
MATRIX=$(cat runtimes_list.json) | |
echo $MATRIX | |
echo "runtime=$MATRIX" >> $GITHUB_OUTPUT | |
build: | |
name: Build ${{ matrix.chain }} ${{ inputs.ref }} | |
needs: | |
- find-runtimes | |
strategy: | |
fail-fast: false | |
matrix: ${{ fromJSON(needs.find-runtimes.outputs.runtime) }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Cache ${{ matrix.chain }} runtime for ${{ needs.find-runtimes.outputs.commit_hash }} | |
id: cache_runtime | |
if: inputs.cache == 'true' | |
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 #v3.3.2 | |
with: | |
key: ${{ matrix.chain }}-${{ needs.find-runtimes.outputs.commit_hash }} | |
path: | | |
fellows-runtimes/${{ matrix.runtime_dir }}/target/srtool/release/wbuild/${{ matrix.chain }}-runtime | |
- name: Checkout | |
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 | |
if: ${{ steps.cache_runtime.outputs.cache-hit != 'true' }} | |
with: | |
repository: ${{ inputs.repo }} | |
ref: ${{ inputs.ref }} | |
fetch-depth: 0 | |
path: fellows-runtimes | |
- name: Srtool build | |
id: srtool_build | |
if: ${{ steps.cache_runtime.outputs.cache-hit != 'true' }} | |
uses: chevdor/srtool-actions@v0.9.2 | |
with: | |
workdir: fellows-runtimes | |
chain: ${{ matrix.chain }} | |
runtime_dir: ${{ matrix.runtime_dir }} | |
image: ${{ github.event.inputs.image }} | |
tag: ${{ github.event.inputs.srtool_tag }} | |
# This is done to allow caching | |
- name: Store build artifacts to disk | |
id: cache_digest | |
if: ${{ steps.cache_runtime.outputs.cache-hit != 'true' }} | |
working-directory: fellows-runtimes | |
run: | | |
cached_output=${{ matrix.runtime_dir }}/target/srtool/release/wbuild/${{ matrix.chain }}-runtime/ | |
digest_file=${cached_output}/${{ matrix.chain }}-srtool-digest.json | |
echo '${{ steps.srtool_build.outputs.json }}' | jq > ${digest_file} | |
cat ${digest_file} | |
echo "digest_file=$digest_file" >> "$GITHUB_OUTPUT" | |
- name: Retrieve WASM paths | |
id: get_values | |
run: | | |
runtime_package=${{ matrix.chain }}-runtime | |
runtime_filename=${runtime_package//-/_} | |
wasm="${{ matrix.runtime_dir }}/target/srtool/release/wbuild/${runtime_package}/${runtime_filename}.compact.wasm" | |
wasm_compressed="${{ matrix.runtime_dir }}/target/srtool/release/wbuild/${runtime_package}/${runtime_filename}.compact.compressed.wasm" | |
# we need wasm and wasm_compressed | |
echo "wasm=$wasm" >> "$GITHUB_OUTPUT" | |
echo "wasm_compressed=$wasm_compressed" >> "$GITHUB_OUTPUT" | |
- name: Summary | |
working-directory: fellows-runtimes | |
run: | | |
cached_output=${{ matrix.runtime_dir }}/target/srtool/release/wbuild/${{ matrix.chain }}-runtime/ | |
digest_file=${cached_output}/${{ matrix.chain }}-srtool-digest.json | |
ls -al ${digest_file} | |
cat ${digest_file} | |
echo "WASM location: ${{ steps.get_values.outputs.wasm }}" | |
echo "WASM Compressed location: ${{ steps.get_values.outputs.wasm_compressed }}" | |
# 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@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0 | |
with: | |
name: ${{ matrix.chain }}-runtime | |
path: | | |
fellows-runtimes/${{ steps.get_values.outputs.wasm }} | |
fellows-runtimes/${{ steps.get_values.outputs.wasm_compressed }} | |
fellows-runtimes/${{ 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 | |
working-directory: fellows-runtimes | |
run: | | |
subwasm info ${{ steps.get_values.outputs.wasm }} | |
subwasm info ${{ steps.get_values.outputs.wasm_compressed }} | |
subwasm --json info ${{ steps.get_values.outputs.wasm }} > ${{ matrix.chain }}-info.json | |
subwasm --json info ${{ steps.get_values.outputs.wasm_compressed }} > ${{ matrix.chain }}-info_compressed.json | |
- name: Extract the metadata | |
working-directory: fellows-runtimes | |
run: | | |
subwasm meta ${{ steps.get_values.outputs.wasm }} | |
subwasm --json meta ${{ steps.get_values.outputs.wasm }} > ${{ matrix.chain }}-metadata.json | |
- name: Check the metadata diff | |
working-directory: fellows-runtimes | |
run: | | |
subwasm diff ${{ steps.get_values.outputs.wasm }} --chain-b ${{ matrix.chain }} | tee ${{ matrix.chain }}-diff.txt | |
- name: Archive Subwasm results | |
uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0 | |
with: | |
name: ${{ matrix.chain }}-runtime | |
path: | | |
fellows-runtimes/${{ matrix.chain }}-info.json | |
fellows-runtimes/${{ matrix.chain }}-info_compressed.json | |
fellows-runtimes/${{ matrix.chain }}-metadata.json | |
fellows-runtimes/${{ matrix.chain }}-diff.txt |