Skip to content

CSUB-1345: Migrate away from Azure in favor of Linode #39

CSUB-1345: Migrate away from Azure in favor of Linode

CSUB-1345: Migrate away from Azure in favor of Linode #39

Workflow file for this run

---
name: gluwa
# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [master, pos-keep-history-*]
pull_request:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
permissions: read-all
env:
RUNNER_VM_NAME: "${{ github.event.repository.name }}-$GITHUB_RUN_ID-attempt-$GITHUB_RUN_ATTEMPT"
LINODE_REGION: "nl-ams"
# Shared CPU, Linode 16 GB, 6 vCPU, 320 GB, $96/mo
LINODE_VM_SIZE: "g6-standard-6"
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
deploy-github-runner:
timeout-minutes: 15
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- proxy_type: substrate
steps:
- uses: actions/checkout@v4
# See https://github.com/actions/runner/issues/1879#issuecomment-1123196869
- name: Create matrix.txt
run: |
echo "proxy=${{ matrix.proxy }} / ${{ matrix.secret }} / type=${{ matrix.proxy_type }}" > matrix.txt
- name: Evaluate env vars
id: get-env
run: |
HASH_VALUE=$(echo "${{ hashFiles('matrix.txt') }}" | cut -c1-7)
rm matrix.txt
# 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 }}-$HASH_VALUE" >> "$GITHUB_OUTPUT"
- name: Provision VM
if: env.LC_GITHUB_REPO_ADMIN_TOKEN
run: |
.github/provision-linode-vm.sh
env:
LC_OWNER_REPO_SLUG: ${{ github.repository }}
LC_GITHUB_REPO_ADMIN_TOKEN: ${{ secrets.GH_REPO_ADMIN_TOKEN }}
LC_RUNNER_EPHEMERAL: false
LC_RUNNER_VM_NAME: ${{ steps.get-env.outputs.runner_vm_name }}
LC_PROXY_ENABLED: ${{ matrix.proxy }}
LC_PROXY_SECRET_VARIANT: ${{ matrix.secret }}
LC_PROXY_TYPE: ${{ matrix.proxy_type }}
LC_WORKFLOW_ID: ${{ github.run_id }}
LINODE_CLI_TOKEN: ${{ secrets.LINODE_CLI_TOKEN }}
- name: Upload Linode logs
if: always()
uses: actions/upload-artifact@v4
with:
name: linode-${{ matrix.proxy }}-${{ matrix.secret }}-${{ matrix.proxy_type }}-logs
path: retry*.json
cargo-check:
needs:
- deploy-github-runner
runs-on:
[self-hosted, "workflow-${{ github.run_id }}", "type-substrate"]
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4
- name: Configure rustc version
run: |
# use the version defined in gluwa/creditcoin
RUSTC_VERSION=$(curl --silent https://raw.githubusercontent.com/gluwa/creditcoin/dev/rust-toolchain.toml | grep channel | tail -n1 | tr -d " " | cut -f2 -d'"')
echo "RUSTC_VERSION=$RUSTC_VERSION" >> "$GITHUB_ENV"
- name: Install Rust toolchain
uses: gluwa/toolchain@dev
with:
toolchain: ${{ env.RUSTC_VERSION }}
target: wasm32-unknown-unknown
profile: minimal
override: true
- uses: Swatinem/rust-cache@v2
- name: Check Build
run: |
cargo check --release
cargo-test:
needs:
- deploy-github-runner
runs-on:
[self-hosted, "workflow-${{ github.run_id }}", "type-substrate"]
steps:
- uses: actions/checkout@v4
- name: Configure rustc version
run: |
# use the version defined in gluwa/creditcoin
RUSTC_VERSION=$(curl --silent https://raw.githubusercontent.com/gluwa/creditcoin/dev/rust-toolchain.toml | grep channel | tail -n1 | tr -d " " | cut -f2 -d'"')
echo "RUSTC_VERSION=$RUSTC_VERSION" >> "$GITHUB_ENV"
- name: Install Rust toolchain
uses: gluwa/toolchain@dev
with:
toolchain: ${{ env.RUSTC_VERSION }}
target: wasm32-unknown-unknown
profile: minimal
override: true
- uses: Swatinem/rust-cache@v2
- name: Run tests
uses: gluwa/cargo@dev
with:
command: test
args: --features runtime-benchmarks
remove-github-runner:
runs-on: ubuntu-latest
needs:
- deploy-github-runner
- cargo-check
- cargo-test
if: ${{ always() && needs.deploy-github-runner.result != 'skipped' }}
strategy:
fail-fast: false
matrix:
include:
- proxy_type: substrate
steps:
- uses: actions/checkout@v4
# See https://github.com/actions/runner/issues/1879#issuecomment-1123196869
- name: Create matrix.txt
run: |
echo "proxy=${{ matrix.proxy }} / ${{ matrix.secret }} / type=${{ matrix.proxy_type }}" > matrix.txt
- name: Evaluate env vars
id: get-env
run: |
HASH_VALUE=$(echo "${{ hashFiles('matrix.txt') }}" | cut -c1-7)
rm matrix.txt
echo "runner_vm_name=${{ env.RUNNER_VM_NAME }}-$HASH_VALUE" >> "$GITHUB_OUTPUT"
- name: Remove VM
continue-on-error: true
run: |
.github/remove-linode-vm.sh
env:
LINODE_CLI_TOKEN: ${{ secrets.LINODE_CLI_TOKEN }}
LC_RUNNER_VM_NAME: ${{ steps.get-env.outputs.runner_vm_name }}