From 26a5993bb19e5fc66f8f6e22b1eddbd55b0c2a2a Mon Sep 17 00:00:00 2001 From: Jon C Date: Fri, 11 Apr 2025 14:05:52 +0200 Subject: [PATCH 01/11] CI: Add a comment if a PR touches sysvars #### Problem As noted at https://github.com/anza-xyz/agave/pull/428#issuecomment-2795213465, it's possible to update the Rust client and forget to update the JS client. #### Summary of changes Copy the solution at https://github.com/orgs/community/discussions/69944#discussioncomment-10796276, but adapt it to our needs. NOTE: I'll try updating some paths to see if this works. --- .github/workflows/sysvar-comment.yml | 38 ++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 .github/workflows/sysvar-comment.yml diff --git a/.github/workflows/sysvar-comment.yml b/.github/workflows/sysvar-comment.yml new file mode 100644 index 00000000..82205726 --- /dev/null +++ b/.github/workflows/sysvar-comment.yml @@ -0,0 +1,38 @@ +name: Sysvar Auto-Comment + +on: + pull_request: + types: + - opened + paths: + - 'clock/src/**' + - 'epoch-rewards/src/**' + - 'epoch-schedule/src/**' + - 'fee-calculator/src/**' + - 'last-restart-slot/src/**' + - 'rent/src/**' + - 'slot-hashes/src/**' + - 'slot-history/src/**' + - 'sysvar/src/**' + - 'sysvar-id/src/**' + +jobs: + comment: + runs-on: ubuntu-latest + steps: + - name: Git Checkout + uses: actions/checkout@v4 + + - name: PR Comment + run: + gh pr comment $PRNUM --body $COMMENT + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_REPO: ${{ github.repository }} + PRNUM: ${{ github.event.pull_request.number }} + COMMENT: "If this PR represents a change to the sysvar layout, please + open a follow-up PR to update the JavaScript client `@solana/sysvars` + ([example](https://github.com/anza-xyz/kit/pull/375)) + + Thank you for keeping the JavaScript clients in sync with the Rust + clients." From bb24fff73c0fc8b0c3f2d3246a2dcfeb2ab35904 Mon Sep 17 00:00:00 2001 From: Jon C Date: Fri, 11 Apr 2025 14:09:31 +0200 Subject: [PATCH 02/11] Add whitespace for testing, don't restrict on opened PR --- .github/workflows/sysvar-comment.yml | 4 ++-- sysvar/src/lib.rs | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/sysvar-comment.yml b/.github/workflows/sysvar-comment.yml index 82205726..c5f5d7bb 100644 --- a/.github/workflows/sysvar-comment.yml +++ b/.github/workflows/sysvar-comment.yml @@ -2,8 +2,8 @@ name: Sysvar Auto-Comment on: pull_request: - types: - - opened + #types: + # - opened paths: - 'clock/src/**' - 'epoch-rewards/src/**' diff --git a/sysvar/src/lib.rs b/sysvar/src/lib.rs index 10ee892a..bd125568 100644 --- a/sysvar/src/lib.rs +++ b/sysvar/src/lib.rs @@ -245,6 +245,7 @@ fn get_sysvar( #[cfg(test)] mod tests { + use { super::*, crate::program_stubs::{set_syscall_stubs, SyscallStubs}, From 9a214413b6b288989a88d9462e5f6d376235fb1a Mon Sep 17 00:00:00 2001 From: Jon C Date: Fri, 11 Apr 2025 14:10:23 +0200 Subject: [PATCH 03/11] Fix passing comment to command --- .github/workflows/sysvar-comment.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sysvar-comment.yml b/.github/workflows/sysvar-comment.yml index c5f5d7bb..beee33cf 100644 --- a/.github/workflows/sysvar-comment.yml +++ b/.github/workflows/sysvar-comment.yml @@ -25,7 +25,7 @@ jobs: - name: PR Comment run: - gh pr comment $PRNUM --body $COMMENT + gh pr comment $PRNUM --body "$COMMENT" env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GH_REPO: ${{ github.repository }} From e10e233f33d2d6fee9b6fd8c56a59437328ae15d Mon Sep 17 00:00:00 2001 From: Jon C Date: Fri, 11 Apr 2025 14:14:12 +0200 Subject: [PATCH 04/11] Update permissions --- .github/workflows/sysvar-comment.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/sysvar-comment.yml b/.github/workflows/sysvar-comment.yml index beee33cf..5776ecf0 100644 --- a/.github/workflows/sysvar-comment.yml +++ b/.github/workflows/sysvar-comment.yml @@ -19,6 +19,9 @@ on: jobs: comment: runs-on: ubuntu-latest + permissions: + contents: read + pull-requests: write steps: - name: Git Checkout uses: actions/checkout@v4 From 4b9db7613889783ddf51e7b72865341240c4436a Mon Sep 17 00:00:00 2001 From: Jon C Date: Fri, 11 Apr 2025 14:18:57 +0200 Subject: [PATCH 05/11] Also add write ability to issues? --- .github/workflows/sysvar-comment.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/sysvar-comment.yml b/.github/workflows/sysvar-comment.yml index 5776ecf0..7f93932c 100644 --- a/.github/workflows/sysvar-comment.yml +++ b/.github/workflows/sysvar-comment.yml @@ -21,6 +21,7 @@ jobs: runs-on: ubuntu-latest permissions: contents: read + issues: write pull-requests: write steps: - name: Git Checkout From 26e95deb316e340d6a8072a599ebdd34d2edd3c5 Mon Sep 17 00:00:00 2001 From: Jon C Date: Fri, 11 Apr 2025 14:21:19 +0200 Subject: [PATCH 06/11] Move where permissions are declared? --- .github/workflows/sysvar-comment.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/sysvar-comment.yml b/.github/workflows/sysvar-comment.yml index 7f93932c..e3f6c074 100644 --- a/.github/workflows/sysvar-comment.yml +++ b/.github/workflows/sysvar-comment.yml @@ -16,13 +16,14 @@ on: - 'sysvar/src/**' - 'sysvar-id/src/**' +permissions: + contents: read + issues: write + pull-requests: write + jobs: comment: runs-on: ubuntu-latest - permissions: - contents: read - issues: write - pull-requests: write steps: - name: Git Checkout uses: actions/checkout@v4 From 94539cb11afecfbeb518cc0a17975ab8ab2cb557 Mon Sep 17 00:00:00 2001 From: Jon C Date: Fri, 11 Apr 2025 14:23:24 +0200 Subject: [PATCH 07/11] More write? --- .github/workflows/sysvar-comment.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/sysvar-comment.yml b/.github/workflows/sysvar-comment.yml index e3f6c074..51ee7d80 100644 --- a/.github/workflows/sysvar-comment.yml +++ b/.github/workflows/sysvar-comment.yml @@ -16,14 +16,13 @@ on: - 'sysvar/src/**' - 'sysvar-id/src/**' -permissions: - contents: read - issues: write - pull-requests: write - jobs: comment: runs-on: ubuntu-latest + permissions: + contents: write + issues: write + pull-requests: write steps: - name: Git Checkout uses: actions/checkout@v4 From 326f30569a40881c4005ea922451568f02095416 Mon Sep 17 00:00:00 2001 From: Jon C Date: Fri, 11 Apr 2025 14:29:43 +0200 Subject: [PATCH 08/11] Use `pull_request_target` instead --- .github/workflows/sysvar-comment.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/sysvar-comment.yml b/.github/workflows/sysvar-comment.yml index 51ee7d80..bd27397b 100644 --- a/.github/workflows/sysvar-comment.yml +++ b/.github/workflows/sysvar-comment.yml @@ -1,7 +1,7 @@ name: Sysvar Auto-Comment on: - pull_request: + pull_request_target: #types: # - opened paths: @@ -20,8 +20,7 @@ jobs: comment: runs-on: ubuntu-latest permissions: - contents: write - issues: write + contents: read pull-requests: write steps: - name: Git Checkout From 301821db188aacf868412e6e4400388b4c3dbf99 Mon Sep 17 00:00:00 2001 From: Jon C Date: Fri, 11 Apr 2025 14:32:05 +0200 Subject: [PATCH 09/11] Add types to force it to run --- .github/workflows/sysvar-comment.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/sysvar-comment.yml b/.github/workflows/sysvar-comment.yml index bd27397b..b0293971 100644 --- a/.github/workflows/sysvar-comment.yml +++ b/.github/workflows/sysvar-comment.yml @@ -2,8 +2,9 @@ name: Sysvar Auto-Comment on: pull_request_target: - #types: - # - opened + types: + - opened + - reopened paths: - 'clock/src/**' - 'epoch-rewards/src/**' From 3d5e6e5f0f4467d72b921ed53a4ce2fb2890587b Mon Sep 17 00:00:00 2001 From: Jon C Date: Fri, 11 Apr 2025 14:34:20 +0200 Subject: [PATCH 10/11] Remove "reopened" event type --- .github/workflows/sysvar-comment.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/sysvar-comment.yml b/.github/workflows/sysvar-comment.yml index b0293971..6d900972 100644 --- a/.github/workflows/sysvar-comment.yml +++ b/.github/workflows/sysvar-comment.yml @@ -4,7 +4,6 @@ on: pull_request_target: types: - opened - - reopened paths: - 'clock/src/**' - 'epoch-rewards/src/**' From 26b6b0dac6342122a758e53be63d3e0c5df1d3e0 Mon Sep 17 00:00:00 2001 From: Jon C Date: Tue, 22 Apr 2025 19:40:25 +0200 Subject: [PATCH 11/11] Add synchronize event type and remove testing whitespace --- .github/workflows/sysvar-comment.yml | 1 + sysvar/src/lib.rs | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sysvar-comment.yml b/.github/workflows/sysvar-comment.yml index 6d900972..eca68e51 100644 --- a/.github/workflows/sysvar-comment.yml +++ b/.github/workflows/sysvar-comment.yml @@ -4,6 +4,7 @@ on: pull_request_target: types: - opened + - synchronize paths: - 'clock/src/**' - 'epoch-rewards/src/**' diff --git a/sysvar/src/lib.rs b/sysvar/src/lib.rs index bd125568..10ee892a 100644 --- a/sysvar/src/lib.rs +++ b/sysvar/src/lib.rs @@ -245,7 +245,6 @@ fn get_sysvar( #[cfg(test)] mod tests { - use { super::*, crate::program_stubs::{set_syscall_stubs, SyscallStubs},