From c433cb47515f45f54f5564050f041b849274d8ad Mon Sep 17 00:00:00 2001 From: Sam Wilson Date: Fri, 14 Feb 2025 14:46:22 -0500 Subject: [PATCH] Move workflows in-repo instead of separately --- .github/actions/build-eips/action.yml | 41 +++++++++++++++ .github/workflows/ci.yml | 72 +++++++++++++++++++++++++-- .github/workflows/post-ci.yml | 51 +++++++++++++++++-- .github/workflows/publish.yml | 33 ++++++++++-- .github/workflows/review-trigger.yml | 50 +++++++++++++++++-- .github/workflows/review.yml | 22 +++++++- 6 files changed, 253 insertions(+), 16 deletions(-) create mode 100644 .github/actions/build-eips/action.yml diff --git a/.github/actions/build-eips/action.yml b/.github/actions/build-eips/action.yml new file mode 100644 index 00000000..d34fc774 --- /dev/null +++ b/.github/actions/build-eips/action.yml @@ -0,0 +1,41 @@ +name: 'build-eips' + +description: 'Run the build-eips tool' + +inputs: + args: + description: 'Command-line arguments to pass to build-eips' + required: true + +outputs: + stdout: + description: 'Standard output from build-eips' + value: ${{ steps.run-build-eips.outputs.stdout }} + +runs: + using: "composite" + steps: + - name: Rust Cache + uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 + + - name: Install build-eips + shell: bash + run: | + rm -rf build-eips build-eips.tar.xz + wget https://github.com/eips-wg/preprocessor/releases/latest/download/build-eips-ubuntu.tar.xz + tar xvf build-eips-ubuntu.tar.xz + + - name: Install Zola + shell: bash + run: cargo install --locked --git https://github.com/getzola/zola.git --rev bcbcd1e7edfc4e011b0760aaaba965878144a7d3 + + - name: Run build-eips + id: run-build-eips + shell: bash + env: + BUILD_EIPS_ARGS: ${{ inputs.args }} + run: | + set -euf -o pipefail + echo "stdout<> "$GITHUB_OUTPUT" + ./build-eips $BUILD_EIPS_ARGS | awk '{ print; if ($0 == "EOF") exit 1 }' | tee -a "$GITHUB_OUTPUT" + echo -e "\nEOF" >> "$GITHUB_OUTPUT" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e936b934..1f016977 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,8 +9,74 @@ on: - ready_for_review - edited +concurrency: + group: ${{ github.workflow }}-${{ github.repository }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + jobs: - ci: + # Stores metadata about the pull request so that `post-ci.yml` can leave a + # useful comment on the pull request. + save-pr: + if: github.event.pull_request.base.repo.owner.login == 'eips-wg' + name: Save Pull Request Metadata + runs-on: ubuntu-latest + + steps: + - name: Build Artifact + env: + PR_NUMBER: ${{ github.event.number }} + PR_SHA: ${{ github.event.pull_request.head.sha }} + MERGE_SHA: ${{ github.sha }} + run: | + mkdir -p ./pr + echo $PR_NUMBER > ./pr/pr_number + echo $PR_SHA > ./pr/pr_sha + echo $MERGE_SHA > ./pr/merge_sha + + - name: Upload Artifact + uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # 4.6.0 + with: + name: pr_number + path: pr/ + + check: + if: github.event.pull_request.base.repo.owner.login == 'eips-wg' + name: Check + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2 + + - name: EIPs Build (Check) + uses: ./.github/actions/build-eips + with: + args: check + + markdownlint: if: github.event.pull_request.base.repo.owner.login == 'eips-wg' - uses: eips-wg/build/.github/workflows/ci.yml@master - secrets: inherit + name: Markdown Linter + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2 + + - name: Get Changed Files + id: changed-files + uses: ./.github/actions/build-eips + with: + args: changed + + - name: Checkout (Config) + if: steps.changed-files.outputs.stdout + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2 + with: + repository: eips-wg/theme + path: theme + + - name: Markdown Lint + if: steps.changed-files.outputs.stdout + uses: DavidAnson/markdownlint-cli2-action@05f32210e84442804257b2a6f20b273450ec8265 # 19.1.0 + with: + config: ./theme/config/config.markdownlint.yaml + globs: ${{ steps.changed-files.outputs.stdout }} diff --git a/.github/workflows/post-ci.yml b/.github/workflows/post-ci.yml index 6f90fbf5..535df2f7 100644 --- a/.github/workflows/post-ci.yml +++ b/.github/workflows/post-ci.yml @@ -5,13 +5,54 @@ on: types: - completed +# This is adapted from https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#workflow_run (2022-07-17) + name: Post Continuous Integration jobs: ci: if: github.event.workflow_run.repository.owner.login == 'eips-wg' - uses: eips-wg/build/.github/workflows/post-ci.yml@master - secrets: inherit - permissions: - issues: write - pull-requests: write + steps: + - name: Fetch PR Number + uses: dawidd6/action-download-artifact@20319c5641d495c8a52e688b7dc5fada6c3a9fbc # v8 + with: + name: pr_number + workflow: ci.yml + run_id: ${{ github.event.workflow_run.id }} + + - name: Save PR Data + id: save-pr-data + run: | + echo "pr_number=$(cat pr_number)" >> $GITHUB_OUTPUT + echo "pr_sha=$(cat pr_sha)" >> $GITHUB_OUTPUT + echo "merge_sha=$(cat merge_sha)" >> $GITHUB_OUTPUT + + - name: Add Comment + uses: marocchino/sticky-pull-request-comment@52423e01640425a022ef5fd42c6fb5f633a02728 # 2.9.1 + if: ${{ github.event.workflow_run.conclusion == 'failure' }} + with: + number: ${{ steps.save-pr-data.outputs.pr_number }} + recreate: true + message: | + The commit ${{ steps.save-pr-data.outputs.pr_sha }} (as a parent of ${{ steps.save-pr-data.outputs.merge_sha }}) contains errors. + Please inspect the [Run Summary](${{ github.event.workflow_run.html_url }}) for details. + + - name: Add Waiting Label + uses: actions-ecosystem/action-add-labels@18f1af5e3544586314bbe15c0273249c770b2daf # 1.1.3 + if: ${{ github.event.workflow_run.conclusion == 'failure' }} + with: + labels: w-ci + number: ${{ steps.save-pr-data.outputs.pr_number }} + repo: ${{ github.repository }} + github_token: ${{ github.token }} + + - name: Remove Waiting Label + uses: actions-ecosystem/action-remove-labels@d05162525702062b6bdef750ed8594fc024b3ed7 + if: ${{ github.event.workflow_run.conclusion != 'failure' }} + with: + labels: w-ci + number: ${{ steps.save-pr-data.outputs.pr_number }} + repo: ${{ github.repository }} + github_token: ${{ github.token }} + + diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 8123f716..6759ae5e 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -6,11 +6,38 @@ on: - master jobs: + build: + if: github.repository_owner == 'eips-wg' + name: Build Pages + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2 + + - name: EIPs Build (Build) + uses: ./.github/actions/build-eips + with: + args: build + + - name: Upload Artifact + id: artifact + uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa # 3.0.1 + with: + path: build/output + publish: if: github.repository_owner == 'eips-wg' - uses: eips-wg/build/.github/workflows/publish.yml@master - secrets: inherit + name: Publish Pages + runs-on: ubuntu-latest + needs: build permissions: pages: write id-token: write - + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + steps: + - name: Publish Pages + id: deployment + uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # 4.0.5 diff --git a/.github/workflows/review-trigger.yml b/.github/workflows/review-trigger.yml index 57e3d792..48a0cee5 100644 --- a/.github/workflows/review-trigger.yml +++ b/.github/workflows/review-trigger.yml @@ -13,8 +13,52 @@ on: types: - created +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + jobs: - review-trigger: + trigger: if: github.event.repository.owner.login == 'eips-wg' - uses: eips-wg/build/.github/workflows/review-trigger.yml@master - secrets: inherit + runs-on: ubuntu-latest + name: Trigger Review + steps: + - name: Write PR Number - PR Target + run: echo $PR_NUMBER > pr-number.txt + env: + PR_NUMBER: ${{ github.event.number }} + if: | + github.event_name == 'pull_request_target' && + !endsWith(github.event.sender.login, '-bot') && + !endsWith(github.event.sender.login, '[bot]') + + - name: Write PR Number - PR Review + run: echo $PR_NUMBER > pr-number.txt + env: + PR_NUMBER: ${{ github.event.pull_request.number }} + if: | + github.event_name == 'pull_request_review' && + !endsWith(github.event.sender.login, '-bot') && + !endsWith(github.event.sender.login, '[bot]') + + - name: Write PR Number - Workflow Dispatch + run: echo $PR_NUMBER > pr-number.txt + if: github.event_name == 'workflow_dispatch' + env: + PR_NUMBER: ${{ inputs.pr_number }} + + - name: Write PR Number - Comment Retrigger + run: echo $PR_NUMBER > pr-number.txt + env: + PR_NUMBER: ${{ github.event.issue.number }} + if: | + github.event_name == 'issue_comment' && + github.event.issue.pull_request && + contains(github.event.comment.body, '@eth-bot rerun') + + - name: Save PR Number + uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # 4.6.0 + with: + name: pr-number + path: pr-number.txt + if-no-files-found: ignore diff --git a/.github/workflows/review.yml b/.github/workflows/review.yml index 3dcbb741..2d2bb4ae 100644 --- a/.github/workflows/review.yml +++ b/.github/workflows/review.yml @@ -10,6 +10,24 @@ on: jobs: review: if: github.event.repository.owner.login == 'eips-wg' - uses: eips-wg/build/.github/workflows/review.yml@master - secrets: inherit + runs-on: ubuntu-latest + name: Review + steps: + - name: Fetch PR Number + uses: dawidd6/action-download-artifact@20319c5641d495c8a52e688b7dc5fada6c3a9fbc # v8 + with: + name: pr-number + workflow: review-trigger.yml + run_id: ${{ github.event.workflow_run.id }} + - name: Save PR Number + id: save-pr-number + run: echo "pr=$(cat pr-number.txt)" >> $GITHUB_OUTPUT + + - name: Auto Review Bot + id: auto-review-bot + uses: ethereum/eip-review-bot@eips-wg-dist + continue-on-error: true + with: + token: ${{ secrets.TOKEN }} + pr_number: ${{ steps.save-pr-number.outputs.pr }}