-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from v1-core/feat/abi-automation
feat: automate sync of ABI files from v1-core to xeon-dapp
- Loading branch information
Showing
4 changed files
with
125 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |