From 00e2484118334bdf6bb042c0f8adb73ef60c9c75 Mon Sep 17 00:00:00 2001 From: Philipp Horstenkamp Date: Fri, 4 Sep 2026 22:29:31 +0200 Subject: [PATCH] feat: automate dist recompilation on Renovate PRs and configure concurrency limit --- .gitea/workflows/recompile-dist.yaml | 53 +++++++++++++++++++++++ .gitea/workflows/test.yaml | 1 + .github/workflows/recompile-dist.yml | 63 ++++++++++++++++++++++++++++ GEMINI.md | 1 + __tests__/index.test.js | 2 +- renovate.json | 21 +++------- 6 files changed, 125 insertions(+), 16 deletions(-) create mode 100644 .gitea/workflows/recompile-dist.yaml create mode 100644 .github/workflows/recompile-dist.yml diff --git a/.gitea/workflows/recompile-dist.yaml b/.gitea/workflows/recompile-dist.yaml new file mode 100644 index 0000000..4107b1f --- /dev/null +++ b/.gitea/workflows/recompile-dist.yaml @@ -0,0 +1,53 @@ +name: Recompile dist/ on Renovate PR + +on: + pull_request: + types: [opened, synchronize] + paths: + - package.json + - pnpm-lock.yaml + - index.js + - monitor.js + +permissions: + contents: write + +jobs: + recompile: + runs-on: pi + if: | + (github.actor == 'renovate[bot]' || contains(github.head_ref, 'renovate/')) && + !contains(github.event.head_commit.message, '[skip compile]') + steps: + - name: Checkout PR Branch + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + ref: ${{ github.head_ref }} + fetch-depth: 0 + + - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 + with: + node-version: '20' + + - uses: pnpm/action-setup@0977fd99725f1db4007ccb2928dbb4e90d06cc86 # v6.0.10 + + - name: Clean Install + run: pnpm install --frozen-lockfile --ignore-scripts + shell: bash + + - name: Build + run: pnpm run build + shell: bash + + - name: Commit dist/ + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git add dist/ + if git diff --staged --quiet; then + echo "No changes to dist/" + else + git commit -m "chore: compile action bundle [skip compile]" + git push origin HEAD:${{ github.head_ref }} + fi + shell: bash diff --git a/.gitea/workflows/test.yaml b/.gitea/workflows/test.yaml index 7fddd2c..cf2b559 100644 --- a/.gitea/workflows/test.yaml +++ b/.gitea/workflows/test.yaml @@ -2,6 +2,7 @@ name: Test on: push: + pull_request: workflow_dispatch: jobs: diff --git a/.github/workflows/recompile-dist.yml b/.github/workflows/recompile-dist.yml new file mode 100644 index 0000000..ff1b216 --- /dev/null +++ b/.github/workflows/recompile-dist.yml @@ -0,0 +1,63 @@ +name: Recompile dist/ on Renovate PR + +on: + pull_request: + types: [opened, synchronize] + paths: + - package.json + - pnpm-lock.yaml + - index.js + - monitor.js + +permissions: + contents: write + +jobs: + recompile: + # 1. Only run for Renovate branches + # 2. Never run if the last commit was already our automated build commit + if: | + (github.actor == 'renovate[bot]' || contains(github.head_ref, 'renovate/')) && + !startsWith(github.event.pull_request.head.label, 'recompile-dist') && + !contains(github.event.head_commit.message, '[skip compile]') + runs-on: ubuntu-latest + steps: + - name: Generate App Token + id: app-token + if: ${{ env.RECOMPILE_APP_ID != '' }} + uses: actions/create-github-app-token@v1 + with: + app-id: ${{ secrets.RECOMPILE_APP_ID }} + private-key: ${{ secrets.RECOMPILE_APP_PRIVATE_KEY }} + env: + RECOMPILE_APP_ID: ${{ secrets.RECOMPILE_APP_ID }} + + - name: Checkout PR Branch + uses: actions/checkout@v4 + with: + token: ${{ steps.app-token.outputs.token || github.token }} + ref: ${{ github.head_ref }} + fetch-depth: 0 + + - uses: pnpm/action-setup@v3 + with: + version: 9 + + - uses: actions/setup-node@v4 + with: + node-version: 20 + cache: pnpm + + - name: Clean Install (No Lifecycle Scripts) + run: pnpm install --frozen-lockfile --ignore-scripts + + - name: Build + run: pnpm run build + + - name: Commit dist/ + uses: stefanzweifel/git-auto-commit-action@v5 + with: + commit_user_name: github-actions[bot] + commit_user_email: github-actions[bot]@users.noreply.github.com + commit_message: 'chore: compile action bundle [skip compile]' + file_pattern: dist/* diff --git a/GEMINI.md b/GEMINI.md index 48ee198..13e1be7 100644 --- a/GEMINI.md +++ b/GEMINI.md @@ -7,6 +7,7 @@ This repository is maintained by Gemini. * **Test-Driven Development (TDD):** Wherever possible, Test-Driven Development principles should be followed. Write tests before writing the code they are intended to validate. * **Pre-commit Hooks:** Ensure that `pre-commit` hooks are installed and active before making any commits. This can be done by running `pre-commit install` in your local repository. * **Note for Gemini:** Git commits trigger pre-commit hooks, which can take several seconds (or minutes) to complete. Checking the command status for git commit is only appropriate every 120s. +* **Package Manager Preferences:** Always use `pnpm` and `pnpx`. Never use `npm` or `npx` under any circumstances. All package management operations, script runs, and tool invocations must use `pnpm` / `pnpx`. ## Repository Comparison diff --git a/__tests__/index.test.js b/__tests__/index.test.js index e3ae099..461bbc6 100644 --- a/__tests__/index.test.js +++ b/__tests__/index.test.js @@ -1,4 +1,4 @@ -import { vi, describe, it, expect, beforeEach } from "vitest"; +import { vi, describe, it, expect, beforeEach, afterEach } from "vitest"; // Mock @actions/core for all tests in this file vi.mock("@actions/core", () => ({ diff --git a/renovate.json b/renovate.json index 5e58483..39399fd 100644 --- a/renovate.json +++ b/renovate.json @@ -5,20 +5,11 @@ "config:recommended", ":automergeLinters" ], - "packageRules": [ - { - "matchManagers": [ - "pnpm" - ], - "postUpgradeTasks": { - "commands": [ - "pnpm install --frozen-lockfile", - "pnpm run build" - ], - "fileFilters": [ - "dist/index.js" - ] - } - } + "rebaseWhen": "behind-base-branch", + "branchConcurrentLimit": 2, + "prConcurrentLimit": 2, + "gitIgnoredAuthors": [ + "github-actions[bot]@users.noreply.github.com", + "bot@horstenkamp.eu" ] }