-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test runtime migrations against a snapshot
- Loading branch information
Showing
1 changed file
with
151 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,151 @@ | ||
name: Runtime Upgrade | ||
|
||
on: | ||
pull_request: | ||
branches: [main, testnet] | ||
|
||
env: | ||
RUNNER_VM_NAME: github-runner-$GITHUB_RUN_ID | ||
|
||
jobs: | ||
setup: | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Set-Up | ||
run: | | ||
sudo apt-get update | ||
sudo apt install -y cmake pkg-config libssl-dev git build-essential clang libclang-dev curl protobuf-compiler | ||
- name: Configure rustc version | ||
run: | | ||
source ci/env | ||
echo "RUSTC_VERSION=$RUSTC_VERSION" >> $GITHUB_ENV | ||
- name: Install Rust toolchain | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: ${{ env.RUSTC_VERSION }} | ||
target: wasm32-unknown-unknown | ||
profile: minimal | ||
override: true | ||
- uses: Swatinem/rust-cache@v2 | ||
|
||
- name: Build SUT | ||
uses: actions-rs/cargo@v1 | ||
with: | ||
command: build | ||
args: --release --features try-runtime | ||
|
||
- name: Upload creditcoin-node binary | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: creditcoin-node | ||
path: target/release/creditcoin-node | ||
|
||
deploy-github-runner: | ||
runs-on: ubuntu-20.04 | ||
needs: setup | ||
outputs: | ||
runner_vm_name: ${{ steps.runner-vm-name.outputs.runner_vm_name }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Install azure-cli | ||
run: | | ||
sudo apt remove azure-cli -y && sudo apt autoremove -y | ||
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash | ||
sudo apt install -y jq | ||
az version | ||
- name: Authorize hosted-runner | ||
run: | | ||
mkdir -p ~/.ssh/ | ||
ssh-keygen -q -t rsa -N '' -f ~/.ssh/id_rsa | ||
cat ~/.ssh/id_rsa.pub >> .github/authorized_keys | ||
- name: Evaluate runner VM name | ||
id: runner-vm-name | ||
run: | | ||
# WARNING: using env.RUNNER_VM_NAME directly in job outputs above | ||
# doesn't evaluate the $GITHUB_RUN_ID reference | ||
echo "runner_vm_name=${{ env.RUNNER_VM_NAME }}" >> $GITHUB_OUTPUT | ||
- name: Provision VM | ||
if: env.LC_GITHUB_REPO_ADMIN_TOKEN | ||
run: | | ||
echo "INFO: From ENVs: RUNNER_VM_NAME=${{ env.RUNNER_VM_NAME }}" | ||
echo "INFO: From Step: RUNNER_VM_NAME=${{ steps.runner-vm-name.outputs.runner_vm_name }}" | ||
az login --service-principal --username "${{ secrets.AZURE_APP_ID }}" --password "${{ secrets.AZURE_APP_PASSWORD }}" --tenant "${{ secrets.AZURE_TENANT_ID }}" | ||
## az account set -s "${{ secrets.AZURE_SUBSCRIPTION_ID }}" | ||
# RG Creditcoin-Test is in WestUS and the CPU quota is already full | ||
# that's why specify a different region here | ||
az deployment group create -g 'Creditcoin-Test' -f .github/runner.bicep \ | ||
--parameters location=westus3 --parameters vmName=${{ env.RUNNER_VM_NAME }} > output.json | ||
# provision the GitHub Runner binary on the VM | ||
# passing additional ENV values | ||
SSH_USER_AT_HOSTNAME=$(cat output.json | jq -r '.properties.outputs.sshUserAtHostname.value') | ||
echo "INFO: $SSH_USER_AT_HOSTNAME" | ||
export LC_RUNNER_VM_NAME="${{ env.RUNNER_VM_NAME }}" | ||
cat ./scripts/provision-github-runner.sh | ssh \ | ||
-o SendEnv=LC_GITHUB_REPO_ADMIN_TOKEN,LC_RUNNER_VM_NAME -o StrictHostKeyChecking=no $SSH_USER_AT_HOSTNAME | ||
env: | ||
LC_GITHUB_REPO_ADMIN_TOKEN: ${{ secrets.GH_REPO_ADMIN_TOKEN }} | ||
|
||
|
||
test-duration: | ||
# see https://gist.github.com/jonico/a94d03cac7a858e0613926d9f1bc7f2b | ||
runs-on: [ self-hosted, "${{ needs.deploy-github-runner.outputs.runner_vm_name }}" ] | ||
needs: | ||
- deploy-github-runner | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Download benchmark binary | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: creditcoin-node | ||
path: target/release | ||
|
||
- name: Restore executable permissions | ||
run: | | ||
chmod a+x ./target/release/creditcoin-node | ||
- name: Download try-runtime snapshots data for Creditcoin | ||
run: | | ||
# TODO: use mainnet/testnet based on target branch for the PR | ||
curl --silent https://creditcoinblockchain.blob.core.windows.net/latestblocks/creditcoin-2.0-mainnet-try-runtime-snapshot-12-19-22.tar.gz > snapshot.tar.gz | ||
mkdir /var/tmp/blockchain-snapshot | ||
tar -xzvf ./snapshot.tar.gz -C /var/tmp/blockchain-snapshot | ||
- name: Try-runtime migrations | ||
run: | | ||
./target/release/creditcoin-node try-runtime --dev --no-spec-check-panic on-runtime-upgrade \ | ||
snap --snapshot-path /var/tmp/blockchain-snapshot/creditcoin-2.0-mainnet-try-runtime-snapshot-12-19-22. | ||
remove-github-runner: | ||
runs-on: ubuntu-20.04 | ||
needs: test-duration | ||
if: always() | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Install azure-cli | ||
run: | | ||
sudo apt remove azure-cli -y && sudo apt autoremove -y | ||
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash | ||
az version | ||
- name: Remove VM | ||
run: | | ||
echo "INFO: RUNNER_VM_NAME=${{ env.RUNNER_VM_NAME }}" | ||
az login --service-principal --username "${{ secrets.AZURE_APP_ID }}" --password "${{ secrets.AZURE_APP_PASSWORD }}" --tenant "${{ secrets.AZURE_TENANT_ID }}" | ||
./scripts/azure-remove.sh "Creditcoin-Test" "${{ env.RUNNER_VM_NAME }}" |