Skip to content

Commit

Permalink
NET-61 ci gamma diff report (#1008)
Browse files Browse the repository at this point in the history
Full implementation of:
1. ci job (alpha <> gamma comparison) to run entire pipeline with
post-step push html report to
https://gamma-reports.river.build/report.html

Pipeline steps:
1. Run diff tool between alpha and gamma
2. Upgrade facets missing or changed on gamma versus alpha (source of
truth)
3. Add keccak256 hashes for each deployed facet to report
4. Render to html
5. Push report to s3 bucket `gamma-reports` serving latest report on
`https://gamma-reports.river.build`
  • Loading branch information
jterzis authored Sep 10, 2024
1 parent c55ab1d commit 9ed4200
Show file tree
Hide file tree
Showing 3 changed files with 188 additions and 23 deletions.
172 changes: 171 additions & 1 deletion .github/workflows/Bytecode_diff_report.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,174 @@
name: Bytecode diff report
name: Bytecode Diff Report
env:
FOUNDRY_VERSION: nightly
TESTNET_PRIVATE_KEY: ${{ secrets.GAMMA_BASE_SEPOLIA_DEPLOYER_PK }}
BASE_RPC_URL: ${{ secrets.BASE_RPC_URL }}
BASE_SEPOLIA_RPC_URL: ${{ secrets.BASE_SEPOLIA_RPC_URL }}
FACET_SOURCE_PATH: ../../contracts/src
REPORT_OUT_DIR: ${{ vars.REPORT_OUT_DIR }}
BASESCAN_API_KEY: ${{ secrets.BASESCAN_API_KEY }}
BASESCAN_SEPOLIA_URL: 'https://api-sepolia.basescan.org/api'
BLOCKSCOUT_SEPOLIA_URL: 'https://base-sepolia.blockscout.com/api'
BLOCKSCOUT_SEPOLIA_API_KEY: ${{ secrets.BLOCKSCOUT_BASE_SEPOLIA_API_KEY }}
AWS_ACCESS_KEY_ID: ${{ secrets.RIVER_S3_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.RIVER_S3_AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.RIVER_S3_AWS_REGION }}
GOWORK: off

on:
workflow_dispatch:
inputs:
origin_environment:
description: 'Origin environment'
required: true
type: choice
options:
- 'alpha'
- 'gamma'
- 'omega'
default: 'alpha'
target_environment:
description: 'Target environment'
required: true
type: choice
options:
- 'alpha'
- 'gamma'
- 'omega'
default: 'gamma'

workflow_call:
inputs:
origin_environment:
description: 'Origin environment'
required: true
type: string
target_environment:
description: 'Target environment'
required: true
type: string
secrets:
BASE_RPC_URL:
required: true
BASE_SEPOLIA_RPC_URL:
required: true
BASESCAN_API_KEY:
required: true
BLOCKSCOUT_BASE_SEPOLIA_API_KEY:
required: true
GAMMA_BASE_SEPOLIA_DEPLOYER_PK:
required: true
RIVER_S3_AWS_ACCESS_KEY_ID:
required: true
RIVER_S3_AWS_SECRET_ACCESS_KEY:
required: true
RIVER_S3_AWS_REGION:
required: true

jobs:
Render_Network_Diff_Upgrade_Report:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}

- uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'yarn'

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: ${{ env.FOUNDRY_VERSION }}

- name: Install node dependencies
run: yarn install --immutable

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.22' # Specify the Go version you need

- name: Install dependencies
run: |
go mod download
go mod tidy
working-directory: scripts/bytecode-diff

- name: Run report generation
run: |
go run main.go -v ${{ inputs.origin_environment }} ${{ inputs.target_environment }}
working-directory: scripts/bytecode-diff
env:
REPORT_OUT_DIR: ${{ env.REPORT_OUT_DIR }}
BASESCAN_API_KEY: ${{ env.BASESCAN_API_KEY }}
BASE_RPC_URL: ${{ env.BASE_RPC_URL }}
BASE_SEPOLIA_RPC_URL: ${{ env.BASE_SEPOLIA_RPC_URL }}
FACET_SOURCE_PATH: ${{ env.FACET_SOURCE_PATH }}
GOWORK: ${{ env.GOWORK }}

- name: Get latest facet diff file
run: |
FACET_DIFF_FILE=$(find ${{ env.REPORT_OUT_DIR }} -name "facet_diff*.yaml" | sort -r | head -n 1 | xargs basename)
echo "Latest facet diff file: $FACET_DIFF_FILE"
echo "FACET_DIFF_FILE=$FACET_DIFF_FILE" >> $GITHUB_ENV
working-directory: scripts/bytecode-diff

- name: Run facet upgrades based on diffs
run: |
./scripts/upgrade-facets.sh ${{ inputs.target_environment }} ${{ env.REPORT_OUT_DIR }} ${{ env.FACET_DIFF_FILE }}
working-directory: scripts/bytecode-diff
env:
BASE_RPC_URL: ${{ env.BASE_RPC_URL }}
BASE_SEPOLIA_RPC_URL: ${{ env.BASE_SEPOLIA_RPC_URL }}
BLOCKSCOUT_SEPOLIA_URL: ${{ env.BLOCKSCOUT_SEPOLIA_URL }}
BLOCKSCOUT_SEPOLIA_API_KEY: ${{ env.BLOCKSCOUT_SEPOLIA_API_KEY }}
BASESCAN_API_KEY: ${{ env.BASESCAN_API_KEY }}
BASESCAN_SEPOLIA_URL: ${{ env.BASESCAN_SEPOLIA_URL }}
TESTNET_PRIVATE_KEY: ${{ env.TESTNET_PRIVATE_KEY }}

- name: Run final html report generation w/ updated hashes
id: gen_html_report

run: |
go run main.go add-hashes ${{ inputs.target_environment }} ${{ env.REPORT_OUT_DIR }}/${{ env.FACET_DIFF_FILE }}
working-directory: scripts/bytecode-diff
env:
BASE_RPC_URL: ${{ env.BASE_RPC_URL }}
BASE_SEPOLIA_RPC_URL: ${{ env.BASE_SEPOLIA_RPC_URL }}
GOWORK: ${{ env.GOWORK }}

- name: Configure AWS credentials
if: steps.gen_html_report.outcome == 'success'
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ env.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ env.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}

- name: Copy HTML report to S3
if: steps.gen_html_report.outcome == 'success'
run: |
# Find the latest hashed HTML file
HTML_FILE=$(find ${{ env.REPORT_OUT_DIR }} -name "*_hashed_*.html" | sort -r | head -n 1)
if [ -z "$HTML_FILE" ]; then
echo "Error: No HTML file found"
exit 1
fi
echo "Latest HTML file: $HTML_FILE"
# Copy to report.html
aws s3 cp $HTML_FILE s3://${{ inputs.target_environment }}-reports/report.html
# Copy to report_YYYYMMDD.html
DATED_FILENAME="report_$(date -u +%Y%m%d).html"
aws s3 cp $HTML_FILE s3://${{ inputs.target_environment }}-reports/$DATED_FILENAME
echo "HTML report copied to S3 bucket ${{ inputs.target_environment }}-reports files report.html and $DATED_FILENAME"
working-directory: scripts/bytecode-diff
35 changes: 17 additions & 18 deletions .github/workflows/Network_diff_upgrade.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,22 @@ name: Network Diff Upgrade

on:
workflow_dispatch:
schedule:
- cron: '0 6 * * 1' # Run every Monday at 6:00 AM UTC

jobs:
Run_Bytecode_Diff_Upgrade:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: main

- name: Gamma Network Diff Report
uses: ./.github/workflows/Bytecode_diff_report.yml
with:
origin_environment: alpha
target_environment: gamma

- name: Upgrade Gamma Facets
uses: ./.github/workflows/Upgrade_network_facets.yml
with:
environment_name: gamma
Run_Alpha_to_Gamma:
name: Run Alpha to Gamma Diff Upgrade
uses: ./.github/workflows/Bytecode_diff_report.yml
with:
origin_environment: alpha
target_environment: gamma
secrets:
BASE_RPC_URL: ${{ secrets.BASE_RPC_URL }}
BASE_SEPOLIA_RPC_URL: ${{ secrets.BASE_SEPOLIA_RPC_URL }}
BASESCAN_API_KEY: ${{ secrets.BASESCAN_API_KEY }}
BLOCKSCOUT_BASE_SEPOLIA_API_KEY: ${{ secrets.BLOCKSCOUT_BASE_SEPOLIA_API_KEY }}
GAMMA_BASE_SEPOLIA_DEPLOYER_PK: ${{ secrets.GAMMA_BASE_SEPOLIA_DEPLOYER_PK }}
RIVER_S3_AWS_ACCESS_KEY_ID: ${{ secrets.RIVER_S3_AWS_ACCESS_KEY_ID }}
RIVER_S3_AWS_SECRET_ACCESS_KEY: ${{ secrets.RIVER_S3_AWS_SECRET_ACCESS_KEY }}
RIVER_S3_AWS_REGION: ${{ secrets.RIVER_S3_AWS_REGION }}
4 changes: 0 additions & 4 deletions .github/workflows/Upgrade_network_facets.yml

This file was deleted.

0 comments on commit 9ed4200

Please sign in to comment.