Skip to content

Commit

Permalink
Merge pull request #3 from v1-core/feat/abi-automation
Browse files Browse the repository at this point in the history
feat: automate sync of ABI files from v1-core to xeon-dapp
  • Loading branch information
heyJonBray authored Jul 28, 2024
2 parents cba9ac8 + 6d8128f commit 78766bd
Show file tree
Hide file tree
Showing 4 changed files with 125 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .github/actions/check-abi-naming/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: 'Check ABI File Naming'
description: 'Ensures ABI files follow the naming convention: ContractName.abi.json'
runs:
using: 'composite'
steps:
- name: Check ABI file naming
shell: bash
run: |
for FILE in $(find . -name "*.abi.json"); do
BASENAME=$(basename "$FILE")
if [[ ! $BASENAME =~ ^[A-Za-z0-9]+\.abi\.json$ ]]; then
echo "Error: ABI file '$BASENAME' does not follow the naming convention 'ContractName.abi.json'"
exit 1
fi
done
15 changes: 15 additions & 0 deletions .github/actions/list-changed-files/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: 'List Changed Files'
description: 'Lists changed files between the last commit and the current commit.'
outputs:
changed_files:
description: 'Files changed in the latest commit'
value: ${{ steps.list_files.outputs.changed_files }}

runs:
using: 'composite'
steps:
- id: list_files
run: |
CHANGED_FILES=$(git diff --name-only HEAD~1 HEAD)
echo "changed_files=$CHANGED_FILES" >> $GITHUB_ENV
echo "::set-output name=changed_files::$CHANGED_FILES"
19 changes: 19 additions & 0 deletions .github/workflows/check-abi-filename.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Check ABI File Naming

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
check_naming:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Check ABI File Naming
uses: ./.github/actions/check-abi-naming
76 changes: 76 additions & 0 deletions .github/workflows/sync-abi-to-dapp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Sync ABI Files to xeon-dapp

permissions:
contents: write

on:
push:
branches:
- main

jobs:
sync_abi_files:
runs-on: ubuntu-latest
steps:
- name: Setup SSH
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.V1_CORE_SSH_KEY }}

- name: Checkout v1-core
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Check for ABI changes
id: check_changes
run: |
git diff --exit-code abi/ || echo "ABI files have changed"
echo "::set-output name=changed::$(git diff --exit-code abi/ || echo 1)"
- name: Sync ABI to xeon-dapp
if: steps.check_changes.outputs.changed == '1'
run: |
git clone [email protected]:xeon-protocol/xeon-dapp.git
cd xeon-dapp
git checkout -b ci/abi-sync origin/ci/abi-sync || git checkout --orphan ci/abi-sync
git pull origin main
rsync -a ../abi/ src/abi/
- name: Check ABI File Naming
uses: ./.github/actions/check-abi-naming

- name: Commit and push changes
if: steps.check_changes.outputs.changed == '1'
run: |
git add src/abi/
if git diff-index --quiet HEAD; then
echo "No changes to commit."
else
git config user.name "v1-core"
git config user.email "[email protected]"
git commit -m "ci: sync ABI files from `v1-core`"
git push origin ci/abi-sync
fi
- name: List changed files
uses: ./.github/actions/list-changed-files

- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: 'ci: sync ABI files from `v1-core`'
branch: ci/abi-sync
base: main
title: '[v1-core] sync ABI files'
body: |
gm ☀️
here are some incoming ABI changes from the `v1-core` repository
**Summary of changes:**
${{ env.changed_files }}
Please review the changes to ensure there are no breaking changes before merging.
labels: 'automated, scope: contracts'
assignees: 'heyJonBray, RTJ99'

0 comments on commit 78766bd

Please sign in to comment.