Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
26 changes: 25 additions & 1 deletion .github/workflows/apply-benchmark-patch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ name: Apply-Benchmark-Patch
on:
pull_request:
types: [labeled]
workflow_dispatch:

permissions:
contents: write
pull-requests: write
actions: read # required to list & download artifacts across workflows
actions: write # re-trigger downstream workflows after applying the patch

jobs:
apply:
Expand All @@ -23,6 +24,14 @@ jobs:
ref: ${{ github.event.pull_request.head.ref }}
fetch-depth: 0

- name: Check out automation helpers from base branch
uses: actions/checkout@v4
with:
repository: ${{ github.repository }}
ref: ${{ github.event.pull_request.base.ref }}
path: ci-tools
fetch-depth: 1

- name: Install GitHub CLI
run: |
sudo DEBIAN_FRONTEND=noninteractive NEEDRESTART_MODE=a apt-get update
Expand Down Expand Up @@ -56,8 +65,10 @@ jobs:
ls -la .bench_patch || true

- name: Apply and commit patch
id: apply_patch
run: |
set -euo pipefail
echo "changes_applied=false" >> "$GITHUB_OUTPUT"

if [ ! -d ".bench_patch" ]; then
echo "No .bench_patch directory found after extraction."
Expand Down Expand Up @@ -101,6 +112,19 @@ jobs:

git commit -m "auto-update benchmark weights"
git push origin "HEAD:${branch}"
new_sha=$(git rev-parse HEAD)
echo "changes_applied=true" >> "$GITHUB_OUTPUT"
echo "head_sha=${new_sha}" >> "$GITHUB_OUTPUT"

- name: Re-run pull_request workflows (except Validate-Benchmarks)
if: steps.apply_patch.outputs.changes_applied == 'true'
run: python3 ci-tools/scripts/ci/rerun_pr_workflows.py
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_REPOSITORY: ${{ github.repository }}
PR_NUMBER: ${{ github.event.pull_request.number }}
PR_HEAD_SHA: ${{ steps.apply_patch.outputs.head_sha }}
EXTRA_SKIP_WORKFLOWS: Apply-Benchmark-Patch

- name: Remove apply-benchmark-patch label
if: ${{ success() }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/cargo-audit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
- unlabeled
- synchronize
- opened
workflow_dispatch:
concurrency:
group: cargo-audit-${{ github.ref }}
cancel-in-progress: true
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/check-devnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
pull_request:
branches: [devnet, devnet-ready]
types: [labeled, unlabeled, synchronize, opened]
workflow_dispatch:

concurrency:
group: check-devnet-${{ github.ref }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/check-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: Build Docker Image

on:
pull_request:
workflow_dispatch:

concurrency:
group: check-docker-${{ github.ref }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/check-finney.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
pull_request:
branches: [finney, main]
types: [labeled, unlabeled, synchronize, opened]
workflow_dispatch:

concurrency:
group: check-finney-${{ github.ref }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/check-testnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
pull_request:
branches: [testnet, testnet-ready]
types: [labeled, unlabeled, synchronize, opened]
workflow_dispatch:

concurrency:
group: check-testnet-${{ github.ref }}
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/hotfixes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ name: Handle Hotfix PRs
on:
pull_request:
types: [opened]
workflow_dispatch:

permissions:
pull-requests: write
contents: write

jobs:
handle-hotfix-pr:
runs-on: [self-hosted, type-ccx13]
runs-on: ubuntu-latest
steps:
- name: Check if PR is a hotfix into `main`
if: >
Expand Down
123 changes: 121 additions & 2 deletions .github/workflows/label-triggers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,17 @@ on:
- unlabeled
- synchronize
- opened
workflow_dispatch:

permissions:
issues: write
pull-requests: write
contents: write
actions: write

jobs:
comment_on_breaking_change:
runs-on: [self-hosted, type-ccx13]
runs-on: ubuntu-latest
steps:
- name: Check if 'breaking change' label is added
if: github.event.label.name == 'breaking-change'
Expand All @@ -25,4 +28,120 @@ jobs:
owner: context.repo.owner,
repo: context.repo.repo,
body: '@opentensor/cerebrum / @opentensor/gyrus / @opentensor/cortex breaking change detected! Please prepare accordingly!'
})
})

bump_spec_version:
if: ${{ github.event.action == 'labeled' && github.event.label.name == 'bump-spec-version' }}
runs-on: ubuntu-latest
steps:
- name: Check out PR branch
uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
fetch-depth: 0

- name: Check out automation helpers from base branch
uses: actions/checkout@v4
with:
repository: ${{ github.repository }}
ref: ${{ github.event.pull_request.base.ref }}
path: ci-tools
fetch-depth: 1

- name: Bump spec_version
id: bump_spec
run: |
set -euo pipefail
python3 <<'PY'
import os
import pathlib
import re

path = pathlib.Path("runtime/src/lib.rs")
content = path.read_text(encoding="utf-8")

pattern = re.compile(r"(spec_version:\s*)(\d+)")
match = pattern.search(content)
if not match:
raise SystemExit("spec_version field not found in runtime/src/lib.rs")

old_value = int(match.group(2))
new_value = old_value + 1
updated = content[: match.start(2)] + str(new_value) + content[match.end(2) :]
path.write_text(updated, encoding="utf-8")
print(f"Bumped spec_version from {old_value} to {new_value}")

output_path = os.environ["GITHUB_OUTPUT"]
with open(output_path, "a", encoding="utf-8") as handle:
handle.write(f"spec_version={new_value}\n")
PY

- name: Commit spec_version bump
id: commit_spec
run: |
set -euo pipefail
echo "changes_made=false" >> "$GITHUB_OUTPUT"

git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add runtime/src/lib.rs

if git diff --cached --quiet; then
echo "No spec_version updates to commit."
exit 0
fi

version="${{ steps.bump_spec.outputs.spec_version }}"
version="${version//$'\n'/}"
version="${version//$'\r'/}"
if [ -z "$version" ]; then
version="(unknown)"
fi

git commit -m "chore: bump spec version to ${version}"
branch=$(git symbolic-ref --quiet --short HEAD || true)
if [ -z "$branch" ]; then
echo "Unable to determine branch name for push." >&2
exit 1
fi
git push origin "HEAD:${branch}"
head_sha=$(git rev-parse HEAD)
echo "changes_made=true" >> "$GITHUB_OUTPUT"
echo "head_sha=${head_sha}" >> "$GITHUB_OUTPUT"
echo "head_ref=${branch}" >> "$GITHUB_OUTPUT"

- name: Re-run pull_request workflows (except Validate-Benchmarks)
if: steps.commit_spec.outputs.changes_made == 'true'
run: |
set -euo pipefail
script_path="scripts/ci/rerun_pr_workflows.py"
if [ ! -f "$script_path" ]; then
script_path="ci-tools/scripts/ci/rerun_pr_workflows.py"
fi
echo "Using rerun helper at $script_path"
python3 "$script_path"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_REPOSITORY: ${{ github.repository }}
PR_NUMBER: ${{ github.event.pull_request.number }}
PR_HEAD_SHA: ${{ steps.commit_spec.outputs.head_sha }}
PR_HEAD_REF: ${{ steps.commit_spec.outputs.head_ref }}

- name: Remove bump-spec-version label
if: ${{ success() }}
uses: actions/github-script@v6
with:
script: |
try {
await github.rest.issues.removeLabel({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
name: 'bump-spec-version'
})
} catch (error) {
if (error.status !== 404) {
throw error
}
}
84 changes: 72 additions & 12 deletions .github/workflows/require-clean-merges.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,83 @@
- devnet-ready
- devnet
- testnet
workflow_dispatch:
inputs:
pr-number:
description: "Pull request number to check when running manually"
required: true

jobs:
assert-clean-merges:
runs-on: [self-hosted, type-ccx13]
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Ensures we get all branches for merging

- name: Gather PR metadata
id: gather-pr
env:
EVENT_PR_NUMBER: ${{ github.event.pull_request.number }}
DISPATCH_PR_NUMBER: ${{ inputs.pr-number }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_REPOSITORY: ${{ github.repository }}
run: |
set -euo pipefail
python3 <<'PY'
import json
import os
import sys
import urllib.request

pr_number = os.environ.get("EVENT_PR_NUMBER") or os.environ.get("DISPATCH_PR_NUMBER") or ""
if not pr_number:
print("Unable to determine PR number.", file=sys.stderr)
sys.exit(1)

repo = os.environ["GITHUB_REPOSITORY"]
token = os.environ.get("GITHUB_TOKEN")
req = urllib.request.Request(f"https://api.github.com/repos/{repo}/pulls/{pr_number}")
req.add_header("Accept", "application/vnd.github+json")
if token:
req.add_header("Authorization", f"Bearer {token}")

with urllib.request.urlopen(req, timeout=30) as resp:
payload = json.loads(resp.read().decode("utf-8"))

base_ref = payload["base"]["ref"]
head_ref = payload["head"]["ref"]
head_repo = payload["head"].get("repo") or {}
is_fork = bool(head_repo.get("fork"))
clone_url = head_repo.get("clone_url") or ""

env_path = os.environ["GITHUB_ENV"]
with open(env_path, "a", encoding="utf-8") as env_file:
env_file.write(f"PR_NUMBER={pr_number}\n")
env_file.write(f"PR_BASE_REF={base_ref}\n")
env_file.write(f"PR_HEAD_REF={head_ref}\n")
env_file.write(f"PR_HEAD_IS_FORK={'true' if is_fork else 'false'}\n")
env_file.write(f"PR_HEAD_CLONE_URL={clone_url}\n")

output_path = os.environ["GITHUB_OUTPUT"]
with open(output_path, "a", encoding="utf-8") as out:
out.write(f"pr-number={pr_number}\n")
out.write(f"base-ref={base_ref}\n")
out.write(f"head-ref={head_ref}\n")
out.write(f"is-fork={'true' if is_fork else 'false'}\n")
out.write(f"fork-clone-url={clone_url}\n")
PY

- name: Determine Target Branch and Set Merge List
id: set-merge-branches
run: |
TARGET_BRANCH="${{ github.event.pull_request.base.ref }}"
PR_BRANCH="${{ github.event.pull_request.head.ref }}"
TARGET_BRANCH="${{ steps.gather-pr.outputs.base-ref }}"
PR_BRANCH="${{ steps.gather-pr.outputs.head-ref }}"
echo "PR_BRANCH=$PR_BRANCH" >> $GITHUB_ENV

if [[ "$TARGET_BRANCH" == "devnet-ready" ]]; then
echo "MERGE_BRANCHES=devnet testnet main" >> $GITHUB_ENV

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}
elif [[ "$TARGET_BRANCH" == "devnet" ]]; then
echo "MERGE_BRANCHES=testnet main" >> $GITHUB_ENV
elif [[ "$TARGET_BRANCH" == "testnet" ]]; then
Expand All @@ -34,23 +92,25 @@
else
echo "MERGE_BRANCHES=devnet-ready devnet testnet main" >> $GITHUB_ENV
fi

- name: Add Fork Remote and Fetch PR Branch
if: github.event.pull_request.head.repo.fork == true
if: steps.gather-pr.outputs.is-fork == 'true'
run: |
PR_BRANCH="${{ github.event.pull_request.head.ref }}"
PR_FORK="${{ github.event.pull_request.head.repo.clone_url }}"
git remote add fork $PR_FORK
git fetch --no-tags --prune fork $PR_BRANCH
PR_BRANCH="${{ steps.gather-pr.outputs.head-ref }}"
PR_FORK="${{ steps.gather-pr.outputs.fork-clone-url }}"
git remote remove fork 2>/dev/null || true
git remote add fork "$PR_FORK"
git fetch --no-tags --prune fork "$PR_BRANCH"

- name: Check Merge Cleanliness
run: |
TARGET_BRANCH="${{ github.event.pull_request.base.ref }}"
PR_BRANCH="${{ github.event.pull_request.head.ref }}"
TARGET_BRANCH="${{ steps.gather-pr.outputs.base-ref }}"
PR_BRANCH="${{ steps.gather-pr.outputs.head-ref }}"
IS_FORK="${{ steps.gather-pr.outputs.is-fork }}"
echo "Fetching all branches..."
git fetch --all --prune

if [[ "${{github.event.pull_request.head.repo.fork}}" == "true" ]]; then
if [[ "$IS_FORK" == "true" ]]; then
PR_BRANCH_REF="fork/$PR_BRANCH"
echo "Using fork reference: $PR_BRANCH_REF"
else
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/try-runtime.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: Try Runtime

on:
pull_request:
workflow_dispatch:

concurrency:
group: try-runtime-${{ github.ref }}
Expand Down
2 changes: 1 addition & 1 deletion runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
// `spec_version`, and `authoring_version` are the same between Wasm and native.
// This value is set to 100 to notify Polkadot-JS App (https://polkadot.js.org/apps) to use
// the compatible custom types.
spec_version: 346,
spec_version: 352,
impl_version: 1,
apis: RUNTIME_API_VERSIONS,
transaction_version: 1,
Expand Down
Binary file not shown.
Loading