Skip to content

Integration of BSC Native Staking Modules #250

Integration of BSC Native Staking Modules

Integration of BSC Native Staking Modules #250

Workflow file for this run

name: CI
on:
# Trigger the workflow on push or pull request,
# but only for the main branch
push:
branches:
- main
- release/**
pull_request:
branches:
- main
- release/**
jobs:
# add get-diff job
get-diff:
runs-on: ubuntu-latest
# Map a step output to a job output
outputs:
contract: ${{ steps.get-diff-contract.outputs.diff }}
certora-contract: ${{ steps.get-diff-certora-contract.outputs.diff }}
certora-spec: ${{ steps.get-diff-certora-spec.outputs.diff }}
scripts: ${{ steps.get-diff-scripts.outputs.diff }}
agents: ${{ steps.get-diff-agents.outputs.diff }}
env: ${{ steps.get-diff-env.outputs.diff }}
steps:
- uses: actions/checkout@v3
- name: Get diff for contract
uses: technote-space/[email protected]
id: get-diff-contract # via outputs
with:
PATTERNS: |
+(contracts)/*.sol
+(contracts/**/*.sol
- name: Get diff for certora contract
uses: technote-space/[email protected]
id: get-diff-certora-contract # via outputs
with:
PATTERNS: |
+(certora)/**/*.sol
- name: Get diff for certora specs/scripts
uses: technote-space/[email protected]
id: get-diff-certora-spec # via outputs
with:
PATTERNS: |
+(certora)/**/*.spec
+(certora)/**/ci.sh
- name: Get diff for scripts/test
uses: technote-space/[email protected]
id: get-diff-scripts # via outputs
with:
PATTERNS: |
+(scripts|test)/*.+(js|ts)
+(scripts|test)/**/*.+(js|ts)
+hardhat.config.ts
+.eslintrc.js
- name: Get diff for agents
uses: technote-space/[email protected]
id: get-diff-agents # via outputs
with:
PATTERNS: |
+(agents)/*.+(js|ts)
+(agents)/**/*.+(js|ts)
+.eslintrc.js
- name: Get diff for example env
uses: technote-space/[email protected]
id: get-diff-env # via outputs
with:
PATTERNS: |
+.env.example.json
generate-json-schema:
name: .env JSON Schema Generator
runs-on: ubuntu-latest
needs: get-diff
if: needs.get-diff.outputs.env
steps:
- name: Check out Git repository
uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}
- name: Set up Node.js
uses: actions/[email protected]
with:
node-version: 20
- name: Generate JSON schema
run: |
yarn install
cp .env.example.json .env.json
npm install -g json-schema-generator
json-schema-generator .env.json -o env-schema.json --force --pretty
- name: Verify Schema
run: |
yarn compile
- name: Commit
uses: EndBug/add-and-commit@v9
with:
default_author: github_actions
message: 'CI: Generated Schema'
add: 'env-schema.json'
contract-size:
name: Contract Size
runs-on: ubuntu-latest
needs: generate-json-schema
if: ${{ always() && !contains(join(needs.generate-json-schema.result, ','), 'failure') && needs.get-diff.outputs.contract }}
steps:
- name: Check out Git repository
uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}
- name: Setup Node.js
uses: actions/[email protected]
with:
node-version: 20
- name: Setup Environment
run: |
yarn install
cp .env.example.json .env.json
- name: Run Contract-sizer
run: |
yarn contract:size
test-contract:
name: Test Contract
runs-on: ubuntu-latest
needs: generate-json-schema
if: ${{ always() && !contains(join(needs.generate-json-schema.result, ','), 'failure') && (needs.get-diff.outputs.contract || needs.get-diff.outputs.scripts)}}
steps:
- name: Check out Git repository
uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}
- name: Setup Node.js
uses: actions/[email protected]
with:
node-version: 20
- name: Setup Environment
run: |
yarn install
cp .env.example.json .env.json
- name: Run test
run: |
yarn test
linter:
name: Linter
runs-on: ubuntu-latest
needs: generate-json-schema
if: ${{ always() && !contains(join(needs.generate-json-schema.result, ','), 'failure') && (needs.get-diff.outputs.contract || needs.get-diff.outputs.certora-contract || needs.get-diff.outputs.scripts || needs.get-diff.outputs.agents)}}
steps:
- name: Check out Git repository
uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}
- name: Setup Node.js
uses: actions/[email protected]
with:
node-version: 20
- name: Setup Environment
run: |
yarn install
- name: Run Linter Fix
run: |
yarn lint
- name: Commit
uses: EndBug/add-and-commit@v9
with:
default_author: github_actions
message: 'CI: Fix Lint'
solhint:
name: Solhint
runs-on: ubuntu-latest
needs: linter
if: needs.get-diff.outputs.contract
steps:
- name: Check out Git repository
uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}
- name: Setup Node.js
uses: actions/[email protected]
with:
node-version: 20
- name: Setup Environment
run: |
yarn install
- name: Run Solhint
run: |
yarn solhint
generate-abis:
name: Generate ABIs
runs-on: ubuntu-latest
needs: linter
if: needs.get-diff.outputs.contract
steps:
- name: Check out Git repository
uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}
- name: Set up Node.js
uses: actions/[email protected]
with:
node-version: 20
- name: Setup environment
run: |
yarn install
cp .env.example.json .env.json
yarn compile
npm install -g fx
- name: Copy UI ABIs
run: |
mkdir -p abis/ui
cp artifacts/contracts/AddressStore.sol/AddressStore.json abis/ui/
cp artifacts/contracts/FeeVault.sol/FeeVault.json abis/ui/
cp artifacts/contracts/StakedBNBToken.sol/StakedBNBToken.json abis/ui/
cp artifacts/contracts/StakePool.sol/StakePool.json abis/ui/
cp artifacts/contracts/UndelegationHolder.sol/UndelegationHolder.json abis/ui/
cp artifacts/contracts/TimelockedAdmin.sol/TimelockedAdmin.json abis/ui/
- name: Extract info for Go ABIs
run: |
mkdir temp
fx artifacts/contracts/StakedBNBToken.sol/StakedBNBToken.json .abi > temp/StakedBNBToken.json
fx artifacts/contracts/StakedBNBToken.sol/StakedBNBToken.json .bytecode > temp/StakedBNBToken.bin
fx artifacts/contracts/StakePool.sol/StakePool.json .abi > temp/StakePool.json
fx artifacts/contracts/StakePool.sol/StakePool.json .bytecode > temp/StakePool.bin
fx artifacts/contracts/interfaces/ITokenHub.sol/ITokenHub.json .abi > temp/ITokenHub.json
fx artifacts/contracts/interfaces/ITokenHub.sol/ITokenHub.json .bytecode > temp/ITokenHub.bin
fx artifacts/contracts/interfaces/ITokenManager.sol/ITokenManager.json .abi > temp/ITokenManager.json
fx artifacts/contracts/interfaces/ITokenManager.sol/ITokenManager.json .bytecode > temp/ITokenManager.bin
- name: Generate Go ABIs
run: |
chmod 755 tools/abigen
mkdir -p abis/go
./tools/abigen --abi=temp/StakedBNBToken.json --bin=temp/StakedBNBToken.bin --pkg=contracts --type=StakedBNBToken --out=abis/go/staked_bnb_token.go
./tools/abigen --abi=temp/StakePool.json --bin=temp/StakePool.bin --pkg=contracts --type=StakePool --out=abis/go/stake_pool.go
./tools/abigen --abi=temp/ITokenHub.json --bin=temp/ITokenHub.bin --pkg=contracts --type=TokenHub --out=abis/go/token_hub.go
./tools/abigen --abi=temp/ITokenManager.json --bin=temp/ITokenManager.bin --pkg=contracts --type=TokenManager --out=abis/go/token_manager.go
rm -rf temp
- name: Commit
uses: EndBug/add-and-commit@v9
with:
default_author: github_actions
message: 'CI: Generated ABIs'
add: 'abis/*'
certora:
runs-on: ubuntu-latest
if: needs.get-diff.outputs.certora-contract || needs.get-diff.outputs.contract || needs.get-diff.outputs.certora-spec
needs: get-diff
steps:
- uses: actions/checkout@v3
- name: Use Node.js 20 LTS
uses: actions/setup-node@v2
with:
node-version: '20'
- name: Installing dependencies
run: yarn install
- name: Set up Python 3.7
uses: actions/setup-python@v2
with:
python-version: 3.7
- uses: actions/setup-java@v1
with:
java-version: '11'
java-package: jre
- name: Install dependencies
run: |
wget https://github.com/ethereum/solidity/releases/download/v0.8.7/solc-static-linux
chmod +x solc-static-linux
sudo mv solc-static-linux /usr/local/bin/solc
pip3 install certora-cli --upgrade
- name: Prepare
run: |
chmod +x certora/scripts/*.sh
- name: Verify with Certora
run: |
certora/scripts/ci.sh
env:
CERTORAKEY: ${{ secrets.CERTORAKEY }}
slither-analyze:
name: Slither Analysis
runs-on: ubuntu-latest
needs: get-diff
permissions:
contents: read
actions: read
security-events: write
if: needs.get-diff.outputs.contract
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup Environment
run: |
yarn install
cp .env.example.json .env.json
- name: Run Slither
uses: crytic/[email protected]
continue-on-error: true
id: slither
with:
node-version: 20
sarif: results.sarif
# - name: Upload SARIF file
# uses: github/codeql-action/upload-sarif@v2
# with:
# sarif_file: "${{ steps.slither.outputs.sarif }}"