From 475e914ab1603ad08d5b16e201157b5dcf8ad7d9 Mon Sep 17 00:00:00 2001 From: troinine Date: Tue, 9 Dec 2025 17:56:21 +0200 Subject: [PATCH 01/11] chore: optimize production builds --- package.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/package.json b/package.json index 33d1aa7..aaa59e9 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "source": [ "src/index.ts" ], + "optimize": true, "publicUrl": "/hacsfiles/ha-weather-forecast-card/", "includeNodeModules": true } @@ -17,6 +18,7 @@ "scripts": { "dev": "parcel serve test/app/index.html test/app/resources/img/*.svg --open", "build": "parcel build --no-source-maps --target module", + "build:debug": "parcel build --target module --no-optimize", "clean": "rm -rf ./dist/ ./.parcel-cache", "preview": "parcel serve test/app/index.html --no-hmr" }, From a6049825a06bf020f6ac70d9401999774db4b59d Mon Sep 17 00:00:00 2001 From: troinine Date: Tue, 9 Dec 2025 18:41:50 +0200 Subject: [PATCH 02/11] chore: add copilot instructions --- .github/instructions/copilot-instructions.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .github/instructions/copilot-instructions.md diff --git a/.github/instructions/copilot-instructions.md b/.github/instructions/copilot-instructions.md new file mode 100644 index 0000000..be60c05 --- /dev/null +++ b/.github/instructions/copilot-instructions.md @@ -0,0 +1,3 @@ +When working with this repository, make sure to review AGENTS.md guidelines + +When reviewing a Pull Request if I (Copilot) didn’t leave any open comments or unresolved issues, automatically add a review comment saying “Looks good to me!”. From bf5956f04907aa0846b2680ef14651c2fc80c700 Mon Sep 17 00:00:00 2001 From: troinine Date: Tue, 9 Dec 2025 18:42:17 +0200 Subject: [PATCH 03/11] ci: add auto PR approval if Copilot signals a good review --- .github/workflows/pr-approval.yml | 50 +++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 .github/workflows/pr-approval.yml diff --git a/.github/workflows/pr-approval.yml b/.github/workflows/pr-approval.yml new file mode 100644 index 0000000..2e38fe2 --- /dev/null +++ b/.github/workflows/pr-approval.yml @@ -0,0 +1,50 @@ +name: Approve Copilot reviews + +on: + pull_request_review: + types: [submitted] + +permissions: + contents: read + pull-requests: write + +jobs: + auto-approve: + runs-on: ubuntu-latest + if: github.event.pull_request.draft == false + steps: + - name: Check Copilot Review and Approval + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PR_URL: ${{ github.event.pull_request.html_url }} + REPO: ${{ github.repository }} + run: | + set -euo pipefail + + PR_DATA=$(gh pr view "$PR_URL" --repo "$REPO" --json reviews,reviewThreads) + + # Check for an APPROVED review from Copilot with "Looks good to me!" + COPILOT_APPROVAL=$(echo "$PR_DATA" | jq -r ' + (.reviews // [])[] + | select(.author.login | test("copilot"; "i")) + | select(.state == "APPROVED") + | select((.body // "") | contains("Looks good to me!")) + | .id + ' | head -n 1) + + if [ -z "$COPILOT_APPROVAL" ]; then + echo "No matching Copilot approval found. Skipping approval." + exit 0 + fi + + UNRESOLVED_COUNT=$(echo "$PR_DATA" | jq ' + [(.reviewThreads // [])[] | select(.isResolved == false)] | length + ') + + if [ "$UNRESOLVED_COUNT" -gt 0 ]; then + echo "Found $UNRESOLVED_COUNT unresolved conversation threads. Skipping approval." + exit 0 + fi + + echo "Copilot approved and all threads resolved. Approving PR..." + gh pr review "$PR_URL" --repo "$REPO" --approve --body "Auto-approved based on Copilot review" From 291466d7383c5b0178c6fff9a52717e01e9e6814 Mon Sep 17 00:00:00 2001 From: Tero Roininen Date: Tue, 9 Dec 2025 18:47:46 +0200 Subject: [PATCH 04/11] docs: fix review comment Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Tero Roininen --- .github/instructions/copilot-instructions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/instructions/copilot-instructions.md b/.github/instructions/copilot-instructions.md index be60c05..97f3295 100644 --- a/.github/instructions/copilot-instructions.md +++ b/.github/instructions/copilot-instructions.md @@ -1,3 +1,3 @@ When working with this repository, make sure to review AGENTS.md guidelines -When reviewing a Pull Request if I (Copilot) didn’t leave any open comments or unresolved issues, automatically add a review comment saying “Looks good to me!”. +When reviewing a Pull Request if I (Copilot) don't leave any open comments or unresolved issues, automatically add a review comment saying “Looks good to me!”. From 02072ab61761015fd81168153615b914b71aa23a Mon Sep 17 00:00:00 2001 From: troinine Date: Tue, 9 Dec 2025 19:23:26 +0200 Subject: [PATCH 05/11] ci: fix Copilot auto-approval workflow --- .github/workflows/pr-approval.yml | 36 +++++++++++++++---------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/.github/workflows/pr-approval.yml b/.github/workflows/pr-approval.yml index 2e38fe2..85a3e74 100644 --- a/.github/workflows/pr-approval.yml +++ b/.github/workflows/pr-approval.yml @@ -21,30 +21,28 @@ jobs: run: | set -euo pipefail - PR_DATA=$(gh pr view "$PR_URL" --repo "$REPO" --json reviews,reviewThreads) - - # Check for an APPROVED review from Copilot with "Looks good to me!" - COPILOT_APPROVAL=$(echo "$PR_DATA" | jq -r ' - (.reviews // [])[] - | select(.author.login | test("copilot"; "i")) - | select(.state == "APPROVED") - | select((.body // "") | contains("Looks good to me!")) - | .id - ' | head -n 1) - - if [ -z "$COPILOT_APPROVAL" ]; then - echo "No matching Copilot approval found. Skipping approval." + PR_DATA=$(gh pr view "$PR_URL" --repo "$REPO" --json reviews) + + LATEST_COPILOT_REVIEW=$(echo "$PR_DATA" | jq -r ' + [(.reviews // [])[] | select(.author.login == "copilot-pull-request-reviewer")] + | sort_by(.submittedAt) + | last + ') + + if [ "$LATEST_COPILOT_REVIEW" == "null" ]; then + echo "No reviews found from copilot-pull-request-reviewer. Skipping." exit 0 fi - UNRESOLVED_COUNT=$(echo "$PR_DATA" | jq ' - [(.reviewThreads // [])[] | select(.isResolved == false)] | length + IS_CLEAN=$(echo "$LATEST_COPILOT_REVIEW" | jq -r ' + .body | test("Copilot reviewed \\d+ out of \\d+ changed files in this pull request and generated no new comments."; "i") ') - if [ "$UNRESOLVED_COUNT" -gt 0 ]; then - echo "Found $UNRESOLVED_COUNT unresolved conversation threads. Skipping approval." + if [ "$IS_CLEAN" != "true" ]; then + echo "Latest Copilot review does not indicate a clean state (generated no new comments)." + echo "Review Body: $(echo "$LATEST_COPILOT_REVIEW" | jq -r .body)" exit 0 fi - echo "Copilot approved and all threads resolved. Approving PR..." - gh pr review "$PR_URL" --repo "$REPO" --approve --body "Auto-approved based on Copilot review" + echo "Copilot review is clean and all threads resolved. Approving PR..." + gh pr review "$PR_URL" --repo "$REPO" --approve --body "Auto-approved based on clean Copilot review." From 26e44c47d4f6b781f3421ca5f7bfee3601f2d1a3 Mon Sep 17 00:00:00 2001 From: Tero Roininen Date: Tue, 9 Dec 2025 19:39:42 +0200 Subject: [PATCH 06/11] Update .github/workflows/pr-approval.yml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Tero Roininen --- .github/workflows/pr-approval.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-approval.yml b/.github/workflows/pr-approval.yml index 85a3e74..69c4caf 100644 --- a/.github/workflows/pr-approval.yml +++ b/.github/workflows/pr-approval.yml @@ -35,7 +35,7 @@ jobs: fi IS_CLEAN=$(echo "$LATEST_COPILOT_REVIEW" | jq -r ' - .body | test("Copilot reviewed \\d+ out of \\d+ changed files in this pull request and generated no new comments."; "i") + .body | test("Copilot reviewed \\d+ out of \\d+ changed files in this pull request and generated no new comments\\.)"; "i") ') if [ "$IS_CLEAN" != "true" ]; then From bde745717fa563103ef6a84b97daafae0c50ab56 Mon Sep 17 00:00:00 2001 From: troinine Date: Tue, 9 Dec 2025 19:55:52 +0200 Subject: [PATCH 07/11] ci: review fixes --- .github/instructions/copilot-instructions.md | 3 --- .github/workflows/pr-approval.yml | 17 ++++++++++++++++- 2 files changed, 16 insertions(+), 4 deletions(-) delete mode 100644 .github/instructions/copilot-instructions.md diff --git a/.github/instructions/copilot-instructions.md b/.github/instructions/copilot-instructions.md deleted file mode 100644 index 97f3295..0000000 --- a/.github/instructions/copilot-instructions.md +++ /dev/null @@ -1,3 +0,0 @@ -When working with this repository, make sure to review AGENTS.md guidelines - -When reviewing a Pull Request if I (Copilot) don't leave any open comments or unresolved issues, automatically add a review comment saying “Looks good to me!”. diff --git a/.github/workflows/pr-approval.yml b/.github/workflows/pr-approval.yml index 69c4caf..93560bc 100644 --- a/.github/workflows/pr-approval.yml +++ b/.github/workflows/pr-approval.yml @@ -44,5 +44,20 @@ jobs: exit 0 fi - echo "Copilot review is clean and all threads resolved. Approving PR..." + echo "Copilot review is clean and all threads resolved. Checking for existing approvals..." + + EXISTING_APPROVAL=$(echo "$PR_DATA" | jq -r ' + [(.reviews // [])[] | select( + (.state == "APPROVED") and + (.author.login == "github-actions[bot]" or .author.login == "copilot-pull-request-reviewer") + )] + | length + ') + if [ "$EXISTING_APPROVAL" -gt 0 ]; then + echo "An approval review already exists from github-actions[bot] or copilot-pull-request-reviewer. Skipping approval." + exit 0 + fi + + echo "Copilot review is clean. Approving PR..." + gh pr review "$PR_URL" --repo "$REPO" --approve --body "Auto-approved based on clean Copilot review." From 08572bdcef1036fa6373232c7bd6d67d588c2718 Mon Sep 17 00:00:00 2001 From: Tero Roininen Date: Tue, 9 Dec 2025 20:00:01 +0200 Subject: [PATCH 08/11] Update .github/workflows/pr-approval.yml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Tero Roininen --- .github/workflows/pr-approval.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-approval.yml b/.github/workflows/pr-approval.yml index 93560bc..8d1ad88 100644 --- a/.github/workflows/pr-approval.yml +++ b/.github/workflows/pr-approval.yml @@ -58,6 +58,6 @@ jobs: exit 0 fi - echo "Copilot review is clean. Approving PR..." + echo "Copilot review is clean. Approving PR..." gh pr review "$PR_URL" --repo "$REPO" --approve --body "Auto-approved based on clean Copilot review." From 062589e4d743b44e4604d9872c1024741e02cf0a Mon Sep 17 00:00:00 2001 From: troinine Date: Tue, 9 Dec 2025 20:23:52 +0200 Subject: [PATCH 09/11] ci: fix broken jq syntax. add workflow triggers --- .github/workflows/pr-approval.yml | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pr-approval.yml b/.github/workflows/pr-approval.yml index 8d1ad88..1aa2493 100644 --- a/.github/workflows/pr-approval.yml +++ b/.github/workflows/pr-approval.yml @@ -3,6 +3,13 @@ name: Approve Copilot reviews on: pull_request_review: types: [submitted] + pull_request_review_comment: + types: [created] + workflow_dispatch: + +concurrency: + group: pr-approval-${{ github.head_ref }} + cancel-in-progress: false permissions: contents: read @@ -25,7 +32,7 @@ jobs: LATEST_COPILOT_REVIEW=$(echo "$PR_DATA" | jq -r ' [(.reviews // [])[] | select(.author.login == "copilot-pull-request-reviewer")] - | sort_by(.submittedAt) + | sort_by(.submittedAt) | last ') @@ -35,7 +42,7 @@ jobs: fi IS_CLEAN=$(echo "$LATEST_COPILOT_REVIEW" | jq -r ' - .body | test("Copilot reviewed \\d+ out of \\d+ changed files in this pull request and generated no new comments\\.)"; "i") + .body | test("Copilot reviewed \\d+ out of \\d+ changed files in this pull request and generated no new comments\\.") ') if [ "$IS_CLEAN" != "true" ]; then @@ -48,7 +55,7 @@ jobs: EXISTING_APPROVAL=$(echo "$PR_DATA" | jq -r ' [(.reviews // [])[] | select( - (.state == "APPROVED") and + (.state == "APPROVED") and (.author.login == "github-actions[bot]" or .author.login == "copilot-pull-request-reviewer") )] | length From 01600137b2725037a62eb15e16f52031489e422a Mon Sep 17 00:00:00 2001 From: troinine Date: Tue, 9 Dec 2025 20:31:08 +0200 Subject: [PATCH 10/11] ci: remove workflow_dispatch --- .github/workflows/pr-approval.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pr-approval.yml b/.github/workflows/pr-approval.yml index 1aa2493..f54ea79 100644 --- a/.github/workflows/pr-approval.yml +++ b/.github/workflows/pr-approval.yml @@ -5,7 +5,8 @@ on: types: [submitted] pull_request_review_comment: types: [created] - workflow_dispatch: + issue_comment: + types: [created] concurrency: group: pr-approval-${{ github.head_ref }} @@ -51,7 +52,7 @@ jobs: exit 0 fi - echo "Copilot review is clean and all threads resolved. Checking for existing approvals..." + echo "Copilot review is clean. Checking for existing approvals..." EXISTING_APPROVAL=$(echo "$PR_DATA" | jq -r ' [(.reviews // [])[] | select( From 8b1fe14c6fa7d9e9442438507a21885ba0a5a4cf Mon Sep 17 00:00:00 2001 From: troinine Date: Tue, 9 Dec 2025 20:45:23 +0200 Subject: [PATCH 11/11] chore: remove pr-approval for now --- .github/workflows/pr-approval.yml | 71 ------------------------------- 1 file changed, 71 deletions(-) delete mode 100644 .github/workflows/pr-approval.yml diff --git a/.github/workflows/pr-approval.yml b/.github/workflows/pr-approval.yml deleted file mode 100644 index f54ea79..0000000 --- a/.github/workflows/pr-approval.yml +++ /dev/null @@ -1,71 +0,0 @@ -name: Approve Copilot reviews - -on: - pull_request_review: - types: [submitted] - pull_request_review_comment: - types: [created] - issue_comment: - types: [created] - -concurrency: - group: pr-approval-${{ github.head_ref }} - cancel-in-progress: false - -permissions: - contents: read - pull-requests: write - -jobs: - auto-approve: - runs-on: ubuntu-latest - if: github.event.pull_request.draft == false - steps: - - name: Check Copilot Review and Approval - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - PR_URL: ${{ github.event.pull_request.html_url }} - REPO: ${{ github.repository }} - run: | - set -euo pipefail - - PR_DATA=$(gh pr view "$PR_URL" --repo "$REPO" --json reviews) - - LATEST_COPILOT_REVIEW=$(echo "$PR_DATA" | jq -r ' - [(.reviews // [])[] | select(.author.login == "copilot-pull-request-reviewer")] - | sort_by(.submittedAt) - | last - ') - - if [ "$LATEST_COPILOT_REVIEW" == "null" ]; then - echo "No reviews found from copilot-pull-request-reviewer. Skipping." - exit 0 - fi - - IS_CLEAN=$(echo "$LATEST_COPILOT_REVIEW" | jq -r ' - .body | test("Copilot reviewed \\d+ out of \\d+ changed files in this pull request and generated no new comments\\.") - ') - - if [ "$IS_CLEAN" != "true" ]; then - echo "Latest Copilot review does not indicate a clean state (generated no new comments)." - echo "Review Body: $(echo "$LATEST_COPILOT_REVIEW" | jq -r .body)" - exit 0 - fi - - echo "Copilot review is clean. Checking for existing approvals..." - - EXISTING_APPROVAL=$(echo "$PR_DATA" | jq -r ' - [(.reviews // [])[] | select( - (.state == "APPROVED") and - (.author.login == "github-actions[bot]" or .author.login == "copilot-pull-request-reviewer") - )] - | length - ') - if [ "$EXISTING_APPROVAL" -gt 0 ]; then - echo "An approval review already exists from github-actions[bot] or copilot-pull-request-reviewer. Skipping approval." - exit 0 - fi - - echo "Copilot review is clean. Approving PR..." - - gh pr review "$PR_URL" --repo "$REPO" --approve --body "Auto-approved based on clean Copilot review."