Skip to content

Commit

Permalink
Merge branch 'main' into bko-extended-ci-tests-pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
bkontur authored Nov 30, 2023
2 parents 0179348 + 4e4da08 commit 2cc2963
Show file tree
Hide file tree
Showing 68 changed files with 3,592 additions and 2,041 deletions.
65 changes: 65 additions & 0 deletions .github/changelog-processor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#!/usr/bin/env python

import os
import sys
import argparse

parser = argparse.ArgumentParser(description="Process the CHANGELOG.md")
parser.add_argument(
"changelog",
metavar="CHANGELOG",
help="Path to the CHANGELOG.md file",
default="CHANGELOG.md",
nargs='?'
)

group = parser.add_mutually_exclusive_group()
group.add_argument(
"--print-latest-version",
dest="print_latest_version",
help="Print the latest version (first in the file) found in the CHANGELOG.md",
action="store_true"
)
group.add_argument(
"--should-release",
dest="should_release",
help="Should a release be made? Prints `1` or `0`.",
action="store_true"
)

args = parser.parse_args()

with open(args.changelog, "r") as changelog:
lines = changelog.readlines()

# Find the latest version
for line in lines:
if not line.startswith("## ["):
continue

version = line.strip().removeprefix("## [").split("]")[0]
break

if args.print_latest_version:
print(version, end = "")
sys.exit(0)
elif args.should_release:
if version.lower() == "unreleased":
print("0", end = "")
sys.exit(-1)
elif version.count(".") != 2:
print("0", end = "")
sys.exit(-1)

stream = os.popen("git tag -l v" + version)
output = stream.read()

# Empty output means that the tag doesn't exist and that we should release.
if output.strip() == "":
print("1", end = "")
else:
print("0", end = "")

sys.exit(0)
else:
parser.print_help()
1 change: 1 addition & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!-- Remember that you can run `/merge` to enable auto-merge in the PR -->
24 changes: 10 additions & 14 deletions .github/review-bot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,25 @@ rules:
include:
- ^\.github/.*
type: fellows
minRank: 4
minRank: 3
minApprovals: 2
- name: Relay and system files
condition:
include:
- ^relay\/kusama\/.*
- ^relay\/polkadot\/.*
- ^relay\/.*
- ^system-parachains\/.*
- ^CHANGELOG$
exclude:
- ^relay\/.+\.adoc$
- ^CHANGELOG.md$
type: fellows
minRank: 3
minApprovals: 4
minRank: 2
minApprovals: 3
- name: General Files
condition:
include:
- '.*'
exclude:
- ^relay\/kusama\/.*
- ^relay\/polkadot\/.*
- ^\.github/.*
exclude:
- ^relay\/.*
- ^system-parachains\/.*
- ^target\/.*
- ^\.github/.*
- ^CHANGELOG.md$
type: fellows
minRank: 2
minRank: 1
29 changes: 29 additions & 0 deletions .github/workflows/auto-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Auto Merge Bot

on:
# GitHub considers PRs as issues
issue_comment:
types: [created]

jobs:
set-auto-merge:
runs-on: ubuntu-latest
environment: master
# Important! This forces the job to run only on comments on Pull Requests that starts with '/merge'
if: ${{ github.event.issue.pull_request && startsWith(github.event.comment.body, '/merge') }}
steps:
- name: Get the GitHub handle of the fellows
uses: paritytech/[email protected]
id: fellows
- name: Generate token
id: merge_token
uses: tibdex/github-app-token@v1
with:
app_id: ${{ secrets.MERGE_APP_ID }}
private_key: ${{ secrets.MERGE_APP_KEY }}
- name: Set auto merge
uses: paritytech/[email protected]
with:
GITHUB_TOKEN: ${{ steps.merge_token.outputs.token }}
MERGE_METHOD: "SQUASH"
ALLOWLIST: ${{ steps.fellows.outputs.github-handles }}
80 changes: 80 additions & 0 deletions .github/workflows/check-migrations.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: Check Migrations

on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
workflow_dispatch:

# Cancel a currently running workflow from the same PR, branch or tag when a new workflow is
# triggered (ref https://stackoverflow.com/a/72408109)
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
runtime-matrix:
runs-on: ubuntu-latest
outputs:
runtime: ${{ steps.runtime.outputs.runtime }}
name: Extract tasks from matrix
steps:
- uses: actions/checkout@v2
- id: runtime
run: |
# Filter out runtimes that don't have a URI
TASKS=$(jq '[.[] | select(.uri != null)]' .github/workflows/runtimes-matrix.json)
SKIPPED_TASKS=$(jq '[.[] | select(.uri == null)]' .github/workflows/runtimes-matrix.json)
echo --- Running the following tasks ---
echo $TASKS
echo --- Skipping the following tasks due to not having a uri field ---
echo $SKIPPED_TASKS
# Strip whitespace from Tasks now that we've logged it
TASKS=$(echo $TASKS | jq -c .)
echo "runtime=$TASKS" >> $GITHUB_OUTPUT
check-migrations:
needs: [runtime-matrix]
continue-on-error: true
runs-on: ubuntu-latest
strategy:
matrix:
runtime: ${{ fromJSON(needs.runtime-matrix.outputs.runtime) }}
steps:
- name: Checkout sources
uses: actions/checkout@v3

- name: Download try-runtime-cli
run: |
curl -sL https://github.com/paritytech/try-runtime-cli/releases/download/v0.5.0/try-runtime-x86_64-unknown-linux-musl -o try-runtime
chmod +x ./try-runtime
- name: Install Protoc
uses: arduino/setup-protoc@v1
with:
version: "3.6.1"

- name: Add wasm32-unknown-unknown target
run: rustup target add wasm32-unknown-unknown

- name: Build ${{ matrix.runtime.name }}
run: |
cargo build --profile production -p ${{ matrix.runtime.package }} --features try-runtime
- name: Check migrations
run: |
PACKAGE_NAME=${{ matrix.runtime.package }}
RUNTIME_BLOB_NAME=$(echo $PACKAGE_NAME | sed 's/-/_/g').compact.compressed.wasm
# When running on relay, we don't need weight checks.
NO_WEIGHT_WARNINGS_FLAG=""
if [[ "${{ matrix.runtime.is_relay }}" == "true" ]]; then
NO_WEIGHT_WARNINGS_FLAG="--no-weight-warnings"
fi
# Disable idempotency checks for now because the Scheduler pallet MigrateToV1 migration is
# non-idempotent at its root in Polkadot SDK V1.2.0. In V1.3.0 we can re-enable
# idempotency checks.
EXTRA_ARGS="--disable-spec-version-check --disable-idempotency-checks"
./try-runtime \
--runtime ./target/production/wbuild/$PACKAGE_NAME/$RUNTIME_BLOB_NAME \
on-runtime-upgrade --checks=pre-and-post $EXTRA_ARGS $NO_WEIGHT_WARNINGS_FLAG live --uri ${{ matrix.runtime.uri }}
10 changes: 0 additions & 10 deletions .github/workflows/release-matrix.json

This file was deleted.

40 changes: 26 additions & 14 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Create Draft Release
name: Create Release

on:
push:
Expand All @@ -7,15 +7,29 @@ on:
workflow_dispatch:

jobs:
collect-release-information:
runs-on: ubuntu-latest
outputs:
should-release: ${{ steps.run.outputs.should-release }}
version: ${{ steps.run.outputs.version }}
steps:
- uses: actions/checkout@v2
- id: run
run: |
echo "should-release=$(.github/changelog-processor.py CHANGELOG.md --should-release)" >> $GITHUB_OUTPUT
echo "version=$(.github/changelog-processor.py CHANGELOG.md --print-latest-version)" >> $GITHUB_OUTPUT
cat $GITHUB_OUTPUT
runtime-matrix:
needs: [ collect-release-information ]
if: needs.collect-release-information.outputs.should-release == '1'
runs-on: ubuntu-latest
outputs:
runtime: ${{ steps.runtime.outputs.runtime }}
steps:
- uses: actions/checkout@v2
- id: runtime
run: |
TASKS=$(echo $(cat .github/workflows/release-matrix.json) | sed 's/ //g' )
TASKS=$(echo $(cat .github/workflows/runtimes-matrix.json) | sed 's/ //g' )
echo $TASKS
echo "runtime=$TASKS" >> $GITHUB_OUTPUT
build-runtimes:
Expand Down Expand Up @@ -66,9 +80,9 @@ jobs:
path: |
${{ steps.srtool_build.outputs.wasm_compressed }}
publish-draft-release:
publish-release:
runs-on: ubuntu-latest
needs: [ build-runtimes ]
needs: [ build-runtimes, collect-release-information ]
outputs:
release_url: ${{ steps.create-release.outputs.html_url }}
asset_upload_url: ${{ steps.create-release.outputs.upload_url }}
Expand All @@ -92,7 +106,6 @@ jobs:
SRTOOL() { <$(<<<$CONTEXT head -n1) jq -r .$1; }
WASM() { <${JSON} jq -r ".runtimes.compressed.subwasm.$1"; }
tee -a DRAFT <<-EOF
## Changelog
EOF
tee -a DRAFT <CHANGELOG.md
tee -a DRAFT <<-EOF
Expand All @@ -115,19 +128,19 @@ jobs:
EOF
done
- name: Create draft release
- name: Create release
id: create-release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Runtimes ${{ github.sha }}
tag_name: ${{ format('v{0}', needs.collect-release-information.outputs.version) }}
release_name: Runtimes ${{ needs.collect-release-information.outputs.version }}
body_path: DRAFT
draft: true
draft: false

publish-runtimes:
needs: [ runtime-matrix, publish-draft-release ]
needs: [ runtime-matrix, publish-release ]
continue-on-error: true
runs-on: ubuntu-latest
env:
Expand All @@ -148,14 +161,13 @@ jobs:
run: |
>>$GITHUB_ENV echo ASSET=$(find ${{ matrix.runtime.name }} -name '*.compact.compressed.wasm')
>>$GITHUB_ENV echo SPEC=$(<${JSON} jq -r .runtimes.compact.subwasm.core_version.specVersion)
>>$GITHUB_ENV echo TXVER=$(<${JSON} jq -r .runtimes.compact.subwasm.core_version.transactionVersion)
- name: Upload compressed ${{ matrix.runtime.name }} v${{ env.SPEC }} tx${{ env.TXVER }} wasm
- name: Upload compressed ${{ matrix.runtime.name }} v${{ env.SPEC }} wasm
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.publish-draft-release.outputs.asset_upload_url }}
upload_url: ${{ needs.publish-release.outputs.asset_upload_url }}
asset_path: ${{ env.ASSET }}
asset_name: ${{ matrix.runtime.name }}_runtime-v${{ env.SPEC }}.tx${{ env.TXVER }}.compact.compressed.wasm
asset_name: ${{ matrix.runtime.name }}_runtime-v${{ env.SPEC }}.compact.compressed.wasm
asset_content_type: application/wasm
24 changes: 13 additions & 11 deletions .github/workflows/review-bot.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,34 @@
name: Review PR
name: Review Bot

on:
pull_request_target:
workflow_run:
workflows:
- Review-Trigger
types:
- opened
- reopened
- synchronize
- review_requested
- review_request_removed
- ready_for_review
pull_request_review:
- completed

permissions:
contents: read
checks: write

jobs:
review-approvals:
runs-on: ubuntu-latest
steps:
- name: Extract content of artifact
id: number
uses: Bullrich/[email protected]
with:
artifact-name: pr_number
- name: Generate token
id: team_token
uses: tibdex/github-app-token@v1
with:
app_id: ${{ secrets.REVIEW_APP_ID }}
private_key: ${{ secrets.REVIEW_APP_KEY }}
- name: "Evaluates PR reviews and assigns reviewers"
uses: paritytech/review-bot@v2.0.0
uses: paritytech/review-bot@v2.3.0
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
team-token: ${{ steps.team_token.outputs.token }}
checks-token: ${{ steps.team_token.outputs.token }}
pr-number: ${{ steps.number.outputs.content }}
Loading

0 comments on commit 2cc2963

Please sign in to comment.