Skip to content

ci: add contracts upgradability check #188

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 8, 2023
Merged
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
28 changes: 28 additions & 0 deletions .github/workflows/contract-inheritance-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Check Contract Inheritance

on:
pull_request:
push:
branches:
- master

jobs:
check_inheritance:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: 16

- name: Install Surya
run: |
npm install -g surya

- name: Run Surya Inheritance Check
run: |
./scripts/upgradability_check.sh
22 changes: 22 additions & 0 deletions scripts/upgradability_check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash

# this script will check if the QGB contract is inheriting the correct upgradability contracts.

out=$(surya inheritance src/QuantumGravityBridge.sol | grep -i "\"QuantumGravityBridge\" ->" | cut -d ">" -f 2 | sed 's/[";]//g')

required_contracts=("Initializable" "UUPSUpgradeable" "OwnableUpgradeable")
missing_contracts=()

for field in "${required_contracts[@]}"; do
if ! grep -q "\<$field\>" <<< "$out"; then
missing_contracts+=("$field")
fi
done

if [ ${#missing_contracts[@]} -eq 0 ]; then
echo "The QuantumGravityBridge contract is inheriting the right contracts. Exiting."
exit 0
else
echo "The QuantumGravityBridge contract is missing the necessary inherited contracts: ${missing_contracts[*]}"
exit 1
fi