diff --git a/.github/workflows/selfdrive_tests.yaml b/.github/workflows/selfdrive_tests.yaml
index 42c1dbb5eb..1154948ace 100644
--- a/.github/workflows/selfdrive_tests.yaml
+++ b/.github/workflows/selfdrive_tests.yaml
@@ -338,6 +338,7 @@ jobs:
})
create_ui_report:
+ # This job name needs to be the same as UI_JOB_NAME in ui_preview.yaml
name: Create UI Report
runs-on: ubuntu-latest
steps:
@@ -355,55 +356,5 @@ jobs:
- name: Upload Test Report
uses: actions/upload-artifact@v4
with:
- name: report-${{ inputs.run_number || '1' }}
- path: selfdrive/ui/tests/test_ui/report_${{ inputs.run_number || '1' }}
- - name: Get changes to selfdrive/ui
- if: ${{ github.event_name == 'pull_request' }}
- id: changed-files
- uses: tj-actions/changed-files@v44
- with:
- files: |
- selfdrive/ui/**
- - name: Checkout ci-artifacts
- if: ${{ github.event_name == 'pull_request' && steps.changed-files.outputs.any_changed == 'true' }}
- uses: actions/checkout@v4
- with:
- repository: commaai/ci-artifacts
- ssh-key: ${{ secrets.CI_ARTIFACTS_DEPLOY_KEY }}
- path: ${{ github.workspace }}/ci-artifacts
- ref: master
- - name: Push Screenshots
- if: ${{ github.event_name == 'pull_request' && steps.changed-files.outputs.any_changed == 'true' }}
- working-directory: ${{ github.workspace }}/ci-artifacts
- run: |
- git checkout -b openpilot/pr-${{ github.event.pull_request.number }}
- git config user.name "GitHub Actions Bot"
- git config user.email "<>"
- sudo mv ${{ github.workspace }}/selfdrive/ui/tests/test_ui/report_1/screenshots/* .
- git add .
- git commit -m "screenshots for PR #${{ github.event.pull_request.number }}"
- git push origin openpilot/pr-${{ github.event.pull_request.number }} --force
- - name: Comment Screenshots on PR
- if: ${{ github.event_name == 'pull_request' && steps.changed-files.outputs.any_changed == 'true' }}
- uses: thollander/actions-comment-pull-request@v2
- with:
- message: |
-
- ## UI Screenshots
-
-
-  |
-  |
-
-
-  |
-  |
-
-
-  |
-  |
-
-
- comment_tag: run_id_screenshots
- pr_number: ${{ github.event.pull_request.number }}
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ name: report-${{ github.event.number }}
+ path: selfdrive/ui/tests/test_ui/report_1/screenshots
diff --git a/.github/workflows/ui_preview.yaml b/.github/workflows/ui_preview.yaml
new file mode 100644
index 0000000000..c05c01f3e3
--- /dev/null
+++ b/.github/workflows/ui_preview.yaml
@@ -0,0 +1,91 @@
+name: "ui preview"
+on:
+ pull_request_target:
+ types: [assigned, opened, synchronize, reopened, edited]
+ branches:
+ - 'master'
+ paths:
+ - 'selfdrive/ui/**'
+
+env:
+ UI_JOB_NAME: "Create UI Report"
+
+jobs:
+ preview:
+ if: github.repository == 'commaai/openpilot'
+ name: preview
+ runs-on: ubuntu-latest
+ timeout-minutes: 5
+ permissions:
+ contents: read
+ pull-requests: write
+ actions: read
+ steps:
+ - name: Waiting for ui test to start
+ run: sleep 30
+
+ - name: Wait for ui report
+ uses: lewagon/wait-on-check-action@v1.3.4
+ with:
+ ref: ${{ github.event.pull_request.head.sha }}
+ check-name: $UI_JOB_NAME
+ repo-token: ${{ secrets.GITHUB_TOKEN }}
+ allowed-conclusions: success
+ wait-interval: 20
+
+ - name: Get workflow run ID
+ id: get_run_id
+ run: |
+ echo "run_id=$(curl https://api.github.com/repos/${{ github.repository }}/commits/${{ github.event.pull_request.head.sha }}/check-runs | jq -r '.check_runs[] | select(.name == "$UI_JOB_NAME") | .html_url | capture("(?[0-9]+)") | .number')" >> $GITHUB_OUTPUT
+
+ - name: Checkout ci-artifacts
+ uses: actions/checkout@v4
+ with:
+ repository: commaai/ci-artifacts
+ ssh-key: ${{ secrets.CI_ARTIFACTS_DEPLOY_KEY }}
+ path: ${{ github.workspace }}/ci-artifacts
+ ref: master
+
+ - name: Download artifact
+ id: download-artifact
+ uses: dawidd6/action-download-artifact@v6
+ with:
+ github_token: ${{ secrets.GITHUB_TOKEN }}
+ run_id: ${{ steps.get_run_id.outputs.run_id }}
+ search_artifacts: true
+ name: report-${{ github.event.number }}
+ path: ${{ github.workspace }}/ci-artifacts
+
+ - name: Push Screenshots
+ working-directory: ${{ github.workspace }}/ci-artifacts
+ run: |
+ git checkout -b openpilot/pr-${{ github.event.number }}
+ git config user.name "GitHub Actions Bot"
+ git config user.email "<>"
+ git add ${{ github.workspace }}/ci-artifacts/*
+ git commit -m "screenshots for PR #${{ github.event.number }}"
+ git push origin openpilot/pr-${{ github.event.number }} --force
+
+ - name: Comment Screenshots on PR
+ uses: thollander/actions-comment-pull-request@v2
+ with:
+ message: |
+
+ ## UI Screenshots
+
+
+  |
+  |
+
+
+  |
+  |
+
+
+  |
+  |
+
+
+ comment_tag: run_id_screenshots
+ pr_number: ${{ github.event.number }}
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}