Skip to content

Commit

Permalink
Autogen solidity wrappers
Browse files Browse the repository at this point in the history
  • Loading branch information
HenryNguyen5 committed Apr 30, 2024
1 parent 36756fa commit b78cb0b
Show file tree
Hide file tree
Showing 3 changed files with 120 additions and 24 deletions.
36 changes: 36 additions & 0 deletions .github/actions/detect-solidity-file-changes/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: 'Detect Changes Composite Action'
description: 'Detects changes in solidity files and fails if read-only files are modified.'
outputs:
changes:
description: 'Whether or not changes were detected'
value: ${{ steps.changed_files.outputs.src }}
runs:
using: 'composite'
steps:

- name: Filter paths
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
id: changed_files
with:
list-files: 'csv'
filters: |
src:
- 'contracts/**/*'
- '.github/workflows/solidity.yml'
- '.github/workflows/solidity-foundry.yml'
- '.github/workflows/solidity-wrappers.yml'
read_only_sol:
- 'contracts/src/v0.8/interfaces/**/*'
- 'contracts/src/v0.8/automation/v1_2/**/*'
- 'contracts/src/v0.8/automation/v1_3/**/*'
- 'contracts/src/v0.8/automation/v2_0/**/*'
- name: Fail if read-only files have changed
if: ${{ steps.changed_files.outputs.read_only_sol == 'true' }}
shell: bash
run: |
echo "One or more read-only Solidity file(s) has changed."
for file in ${{ steps.changed_files.outputs.read_only_sol_files }}; do
echo "$file was changed"
done
exit 1
80 changes: 80 additions & 0 deletions .github/workflows/solidity-wrappers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: Solidity Wrappers
# This is its own workflow file rather than being merged into "solidity.yml" to avoid over complicating the conditionals
# used for job execution. The jobs in "solidity.yml" are configured around push events, whereas
# we only want to generate gethwrappers during pull requests.
on:
pull_request:
types:
- opened
- synchronize
- reopened

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
changes:
name: Detect changes
runs-on: ubuntu-latest
outputs:
changes: ${{ steps.ch.outputs.changes }}
steps:
- name: Checkout the repo
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
- name: Detect changes
id: ch
uses: ./.github/actions/detect-solidity-file-changes

# On a pull request event, make updates to gethwrappers if there are changes.
update-wrappers:
needs: [changes]
if: needs.changes.outputs.changes == 'true'
name: Update Wrappers
runs-on: ubuntu22.04-8cores-32GB
steps:
- name: Checkout the repo
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2

- name: Setup Go
uses: ./.github/actions/setup-go

- name: Run native compile and generate wrappers
run: make wrappers-all
working-directory: ./contracts

- name: Assume role capable of dispatching action
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # v4.0.2
with:
role-to-assume: ${{ secrets.AWS_OIDC_CHAINLINK_CI_AUTO_PR_TOKEN_ISSUER_ROLE_ARN }}
aws-region: ${{ secrets.AWS_REGION }}
role-duration-seconds: 3600
role-session-name: solidity-wrappers.update-wrappers
mask-aws-account-id: true

- name: Get Github Token
id: get-gh-token
uses: smartcontractkit/chainlink-github-actions/github-app-token-issuer@5874ff7211cf5a5a2670bb010fbff914eaaae138 # v2.3.12
with:
url: ${{ secrets.AWS_INFRA_RELENG_TOKEN_ISSUER_LAMBDA_URL }}

- name: Commit any wrapper changes
uses: planetscale/ghcommit-action@21a8cda29f55e5cc2cdae0cdbdd08e38dd148c25 # https://github.com/planetscale/ghcommit-action/releases/tag/v0.1.37
with:
commit_message: "Update gethwrappers"
repo: ${{ github.repository }}
branch: ${{ github.head_ref }}
file_pattern: "core/gethwrappers/**/generated/*.go"
env:
GITHUB_TOKEN: ${{ steps.get-gh-token.outputs.access-token }}

- name: Collect Metrics
id: collect-gha-metrics
uses: smartcontractkit/push-gha-metrics-action@dea9b546553cb4ca936607c2267a09c004e4ab3f # v3.0.0
with:
id: solidity-update-wrappers
org-id: ${{ secrets.GRAFANA_INTERNAL_TENANT_ID }}
basic-auth: ${{ secrets.GRAFANA_INTERNAL_BASIC_AUTH }}
hostname: ${{ secrets.GRAFANA_INTERNAL_HOST }}
this-job-name: Update Wrappers
continue-on-error: true
28 changes: 4 additions & 24 deletions .github/workflows/solidity.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,33 +13,13 @@ jobs:
name: Detect changes
runs-on: ubuntu-latest
outputs:
changes: ${{ steps.changes.outputs.src }}
changes: ${{ steps.ch.outputs.changes }}
steps:
- name: Checkout the repo
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
id: changes
with:
list-files: "csv"
filters: |
src:
- 'contracts/**/*'
- '.github/workflows/solidity.yml'
- '.github/workflows/solidity-foundry.yml'
read_only_sol:
- 'contracts/src/v0.8/interfaces/**/*'
- 'contracts/src/v0.8/automation/v1_2/**/*'
- 'contracts/src/v0.8/automation/v1_3/**/*'
- 'contracts/src/v0.8/automation/v2_0/**/*'
- name: Fail if read-only files have changed
if: ${{ steps.changes.outputs.read_only_sol == 'true' }}
run: |
echo "One or more read-only Solidity file(s) has changed."
for file in ${{ steps.changes.outputs.read_only_sol_files }}; do
echo "$file was changed"
done
exit 1
- name: Detect changes
id: ch
uses: ./.github/actions/detect-solidity-file-changes

tag-check:
needs: [changes]
Expand Down

0 comments on commit b78cb0b

Please sign in to comment.