From 694e2892ac4ab096df707be2529c38b2e0a068fc Mon Sep 17 00:00:00 2001 From: pputman12 Date: Fri, 13 Sep 2024 08:30:29 -0500 Subject: [PATCH 1/3] adding permissions to protocol-devchain-anvil.yml workflow --- .github/workflows/protocol-devchain-anvil.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/protocol-devchain-anvil.yml b/.github/workflows/protocol-devchain-anvil.yml index 3fa4e8f4d30..e0344af0877 100644 --- a/.github/workflows/protocol-devchain-anvil.yml +++ b/.github/workflows/protocol-devchain-anvil.yml @@ -17,6 +17,8 @@ on: required: true type: string + + env: # Increment these to force cache rebuilding FOUNDRY_CACHE_KEY: 1 @@ -24,6 +26,9 @@ env: SUPPORTED_FOUNDRY_VERSION: ${{ vars.SUPPORTED_FOUNDRY_VERSION }} ANVIL_PORT: 8546 +permissions: + contents: read + jobs: build: defaults: From 4bbac336d82decd270106d2268aeb5811a9cdaac Mon Sep 17 00:00:00 2001 From: pputman-clabs Date: Sun, 22 Dec 2024 16:13:12 -0600 Subject: [PATCH 2/3] Change package version to reference github commit sha instead of pr number The github sha would be a better version number to use than the PR number, as its immutable and follows best practices. --- .github/workflows/protocol-devchain-anvil.yml | 33 +------------------ 1 file changed, 1 insertion(+), 32 deletions(-) diff --git a/.github/workflows/protocol-devchain-anvil.yml b/.github/workflows/protocol-devchain-anvil.yml index 31001d8c110..bbedcd556ab 100644 --- a/.github/workflows/protocol-devchain-anvil.yml +++ b/.github/workflows/protocol-devchain-anvil.yml @@ -64,37 +64,6 @@ jobs: path: ./out key: ${{ runner.os }}-foundry-out-${{ env.FOUNDRY_CACHE_KEY }} - - name: Display SHA - run: | - echo "SHA: ${{ github.sha }}" - - - name: Get Pull Request data - id: get_pr_data - uses: actions/github-script@v7 - with: - script: | - const result = ( - await github.rest.repos.listPullRequestsAssociatedWithCommit({ - commit_sha: context.sha, - owner: context.repo.owner, - repo: context.repo.repo, - }) - ).data[0]; - core.setOutput("number", result ? result.number : ""); - - - name: Set PR Number - id: set_pr_number - run: | - if [ -z "${{ steps.get_pr_data.outputs.number }}" ]; then - echo "PR_NUMBER=${{ github.event.pull_request.number }}" >> $GITHUB_ENV - else - echo "PR_NUMBER=${{ steps.get_pr_data.outputs.number }}" >> $GITHUB_ENV - fi - - - name: Display PR Number - run: | - echo "Pull Request Number: ${{ env.PR_NUMBER }}" - - name: Install Foundry uses: foundry-rs/foundry-toolchain@8f1998e9878d786675189ef566a2e4bf24869773 with: @@ -167,7 +136,7 @@ jobs: - name: Upload devchain as artifact uses: actions/upload-artifact@v4 with: - name: devchain-${{ env.PR_NUMBER }}-${{ steps.date.outputs.date }} + name: devchain-${{ github.sha }}-${{ steps.date.outputs.date }} path: packages/protocol/.tmp # Max retention time is 90 days for public repos # https://docs.github.com/en/actions/learn-github-actions/usage-limits-billing-and-administration#artifact-and-log-retention-policy From e494b16e497e1eb01827c62ddaef8e9be1fb3b39 Mon Sep 17 00:00:00 2001 From: pputman-clabs Date: Sun, 22 Dec 2024 16:13:12 -0600 Subject: [PATCH 3/3] Change artifact upload to reference github commit sha instead of pr number The github sha would be a better version number to use than the PR number, as its immutable and follows best practices. Also eliminates unnecessary junk in the workflow to make it work with both PRs and pushes/merges --- .github/workflows/protocol-devchain-anvil.yml | 33 +------------------ 1 file changed, 1 insertion(+), 32 deletions(-) diff --git a/.github/workflows/protocol-devchain-anvil.yml b/.github/workflows/protocol-devchain-anvil.yml index 31001d8c110..bbedcd556ab 100644 --- a/.github/workflows/protocol-devchain-anvil.yml +++ b/.github/workflows/protocol-devchain-anvil.yml @@ -64,37 +64,6 @@ jobs: path: ./out key: ${{ runner.os }}-foundry-out-${{ env.FOUNDRY_CACHE_KEY }} - - name: Display SHA - run: | - echo "SHA: ${{ github.sha }}" - - - name: Get Pull Request data - id: get_pr_data - uses: actions/github-script@v7 - with: - script: | - const result = ( - await github.rest.repos.listPullRequestsAssociatedWithCommit({ - commit_sha: context.sha, - owner: context.repo.owner, - repo: context.repo.repo, - }) - ).data[0]; - core.setOutput("number", result ? result.number : ""); - - - name: Set PR Number - id: set_pr_number - run: | - if [ -z "${{ steps.get_pr_data.outputs.number }}" ]; then - echo "PR_NUMBER=${{ github.event.pull_request.number }}" >> $GITHUB_ENV - else - echo "PR_NUMBER=${{ steps.get_pr_data.outputs.number }}" >> $GITHUB_ENV - fi - - - name: Display PR Number - run: | - echo "Pull Request Number: ${{ env.PR_NUMBER }}" - - name: Install Foundry uses: foundry-rs/foundry-toolchain@8f1998e9878d786675189ef566a2e4bf24869773 with: @@ -167,7 +136,7 @@ jobs: - name: Upload devchain as artifact uses: actions/upload-artifact@v4 with: - name: devchain-${{ env.PR_NUMBER }}-${{ steps.date.outputs.date }} + name: devchain-${{ github.sha }}-${{ steps.date.outputs.date }} path: packages/protocol/.tmp # Max retention time is 90 days for public repos # https://docs.github.com/en/actions/learn-github-actions/usage-limits-billing-and-administration#artifact-and-log-retention-policy