diff --git a/.github/workflows/example-report.yml b/.github/workflows/example-report.yml index d5972be9..d1384106 100644 --- a/.github/workflows/example-report.yml +++ b/.github/workflows/example-report.yml @@ -23,7 +23,7 @@ jobs: windows_percy_project: ${{ steps.env.outputs.windows_percy_project }} macos_percy_project: ${{ steps.env.outputs.macos_percy_project }} mobile_percy_project: ${{ steps.env.outputs.mobile_percy_project }} - mobile_nonce: ${{ steps.env.outputs.mobile_nonce }} + pixeleagle_project: ${{ steps.env.outputs.pixeleagle_project }} updated: ${{ steps.version-check.outputs.updated }} steps: - name: Checkout Bevy main branch @@ -43,8 +43,8 @@ jobs: echo "windows_percy_project=dede4209/Screenshots-Windows-DX12" >> $GITHUB_OUTPUT echo "macos_percy_project=dede4209/Screenshots-macOS-Metal" >> $GITHUB_OUTPUT echo "mobile_percy_project=dede4209/Bevy-Mobile-Example" >> $GITHUB_OUTPUT + echo "pixeleagle_project=B25A040A-A980-4602-B90C-D480AB84076D" >> $GITHUB_OUTPUT echo "pages=`python -c \"import json; print(json.dumps([i for i in range($page_count)]))\"`" >> $GITHUB_OUTPUT - echo "mobile_nonce=${{ github.run_id }}-$(date +%s)" >> $GITHUB_OUTPUT - uses: actions/checkout@v4 with: ref: 'results' @@ -530,8 +530,9 @@ jobs: uses: ./.github/workflows/workflow-mobile.yml with: gitref: ${{ needs.get-environment.outputs.gitref }} - nonce: ${{ needs.get-environment.outputs.mobile_nonce }} mobile_percy_project: ${{ needs.get-environment.outputs.mobile_percy_project }} + pixeleagle_project: ${{ needs.get-environment.outputs.pixeleagle_project }} + branch: "main" secrets: inherit send-to-pixel-eagle: @@ -567,9 +568,7 @@ jobs: - name: Send to Pixel Eagle if: steps.gather-examples.outcome == 'success' run: | - project="B25A040A-A980-4602-B90C-D480AB84076D" - - run=`curl https://pixel-eagle.vleue.com/$project/runs --json '{"os":"${{ matrix.os }}", "gitref": "${{ needs.get-environment.outputs.gitref }}", "branch": "main"}' | jq '.id'` + run=`curl https://pixel-eagle.vleue.com/${{ needs.get-environment.outputs.pixeleagle_project }}/runs --json '{"os":"${{ matrix.os }}", "gitref": "${{ needs.get-environment.outputs.gitref }}", "branch": "main"}' | jq '.id'` SAVEIFS=$IFS @@ -592,11 +591,11 @@ jobs: IFS=$SAVEIFS # Upload screenshots with unknown hashes - curl https://pixel-eagle.vleue.com/$project/runs/$run/hashes --json "$hashes" | jq '.[]|[.name] | @tsv' | + curl https://pixel-eagle.vleue.com/${{ needs.get-environment.outputs.pixeleagle_project }}/runs/$run/hashes --json "$hashes" | jq '.[]|[.name] | @tsv' | while IFS=$'\t' read -r name; do name=`echo $name | tr -d '"'` echo "Uploading $name" - curl https://pixel-eagle.vleue.com/$project/runs/$run/screenshots -F "data=@./$name" -F "screenshot=$name" + curl https://pixel-eagle.vleue.com/${{ needs.get-environment.outputs.pixeleagle_project }}/runs/$run/screenshots -F "data=@./$name" -F "screenshot=$name" echo done @@ -604,7 +603,7 @@ jobs: cd .. - curl https://pixel-eagle.vleue.com/$project/runs/$run/compare/auto --json '{"os":"", "branch": "main"}' | jq '{project_id: .project_id, from: .from, to: .to}' > pixeleagle-${{ matrix.os }}.json + curl https://pixel-eagle.vleue.com/${{ needs.get-environment.outputs.pixeleagle_project }}/runs/$run/compare/auto --json '{"os":"", "branch": "main"}' | jq '{project_id: .project_id, from: .from, to: .to}' > pixeleagle-${{ matrix.os }}.json cat pixeleagle-${{ matrix.os }}.json echo "created run $run" diff --git a/.github/workflows/run-on-pr.yml b/.github/workflows/run-on-pr.yml index e8f10f38..0eec39ad 100644 --- a/.github/workflows/run-on-pr.yml +++ b/.github/workflows/run-on-pr.yml @@ -8,9 +8,6 @@ on: required: true type: string -concurrency: - group: ${{ github.repository }}-example-report-PR - env: PER_PAGE: 20 @@ -22,6 +19,7 @@ jobs: pages: ${{ steps.env.outputs.pages }} gitref: ${{ steps.env.outputs.gitref }} date: ${{ steps.env.outputs.date }} + pixeleagle_project: ${{ steps.env.outputs.pixeleagle_project }} steps: - name: Checkout Bevy main branch uses: actions/checkout@v4 @@ -40,6 +38,7 @@ jobs: echo "gitref=`git rev-parse HEAD`" >> $GITHUB_OUTPUT echo "date=`date +%Y%m%d%H%M`" >> $GITHUB_OUTPUT echo "pages=`python -c \"import json; print(json.dumps([i for i in range($page_count)]))\"`" >> $GITHUB_OUTPUT + echo "pixeleagle_project=B25A040A-A980-4602-B90C-D480AB84076D" >> $GITHUB_OUTPUT take-screenshots: name: Take Screenshots @@ -235,3 +234,12 @@ jobs: cat pixeleagle-${{ matrix.os }}.json echo "created run $run" + + mobile-run: + needs: [get-environment] + uses: ./.github/workflows/workflow-mobile.yml + with: + gitref: ${{ needs.get-environment.outputs.gitref }} + pixeleagle_project: ${{ needs.get-environment.outputs.pixeleagle_project }} + branch: "PR-${{ inputs.pr }}" + secrets: inherit diff --git a/.github/workflows/workflow-mobile.yml b/.github/workflows/workflow-mobile.yml index 96e4c309..c3864875 100644 --- a/.github/workflows/workflow-mobile.yml +++ b/.github/workflows/workflow-mobile.yml @@ -6,10 +6,13 @@ on: gitref: required: true type: string - nonce: + mobile_percy_project: + required: false + type: string + pixeleagle_project: required: true type: string - mobile_percy_project: + branch: required: true type: string @@ -78,25 +81,29 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 30 needs: [build-for-iOS, build-for-Android] - env: - PERCY_PARALLEL_NONCE: ${{ inputs.nonce }} - PERCY_PARALLEL_TOTAL: ${{ strategy.job-total }} strategy: matrix: include: - - device: "iPhone 13" + - os: "iOS" + device: "iPhone 13" os_version: "15" - - device: "iPhone 14" + - os: "iOS" + device: "iPhone 14" os_version: "16" - - device: "iPhone 15" + - os: "iOS" + device: "iPhone 15" os_version: "17" - - device: "Xiaomi Redmi Note 11" + - os: "Android" + device: "Xiaomi Redmi Note 11" os_version: "11.0" - - device: "Google Pixel 6" + - os: "Android" + device: "Google Pixel 6" os_version: "12.0" - - device: "Samsung Galaxy S23" + - os: "Android" + device: "Samsung Galaxy S23" os_version: "13.0" - - device: "Google Pixel 8" + - os: "Android" + device: "Google Pixel 8" os_version: "14.0" steps: - uses: actions/checkout@v4 @@ -104,6 +111,10 @@ jobs: repository: 'bevyengine/bevy' ref: ${{ inputs.gitref }} + - name: Set Percy Token if needed + if: "${{ inputs.mobile_percy_project != '' }}" + run: echo "PERCY_TOKEN=${{ secrets.PERCY_TOKEN_MOBILE }}" >> $GITHUB_ENV + - name: Run Example run: | cd .github/start-mobile-example @@ -114,18 +125,56 @@ jobs: BROWSERSTACK_APP_ID: ${{ github.run_id }} BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }} BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }} - PERCY_TOKEN: ${{ secrets.PERCY_TOKEN_MOBILE }} DEVICE: ${{ matrix.device }} OS_VERSION: ${{ matrix.os_version }} PERCY_COMMIT: ${{ inputs.gitref }} - + PERCY_PARALLEL_NONCE: ${{ github.run_id }} + PERCY_PARALLEL_TOTAL: ${{ strategy.job-total }} + - name: Save screenshots if: ${{ always() }} - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: screenshots-${{ matrix.device }}-${{ matrix.os_version }} path: .github/start-mobile-example/*.png + + - name: Send to Pixel Eagle + run: | + run=`curl https://pixel-eagle.vleue.com/${{ inputs.pixeleagle_project }}/runs -H 'Content-Type: application/json' -d '{"device":"${{ matrix.device }}", "os":"${{ matrix.os }}-${{ matrix.os_version }}", "gitref": "${{ inputs.gitref }}", "branch": "${{ inputs.branch }}"}' | jq '.id'` + + SAVEIFS=$IFS + + IFS=$'\n' + + cd .github/start-mobile-example + # Build a json array of screenshots and their hashes + hashes='['; + for screenshot in $(find . -type f -maxdepth 1 -name "*.png"); + do + name=${screenshot:2} + echo $name + hash=`shasum -a 256 $screenshot | awk '{print $1}'` + hashes="$hashes [\"$name\",\"$hash\"]," + done + hashes=`echo $hashes | rev | cut -c 2- | rev` + hashes="$hashes]" + + IFS=$SAVEIFS + + # Upload screenshots with unknown hashes + curl https://pixel-eagle.vleue.com/${{ inputs.pixeleagle_project }}/runs/$run/hashes -H 'Content-Type: application/json' -d "$hashes" | jq '.[]|[.name] | @tsv' | + while IFS=$'\t' read -r name; do + name=`echo $name | tr -d '"'` + echo "Uploading $name" + curl https://pixel-eagle.vleue.com/${{ inputs.pixeleagle_project }}/runs/$run/screenshots -F "data=@./$name" -F "screenshot=$name" + echo + done + + IFS=$SAVEIFS + + curl https://pixel-eagle.vleue.com/$project/runs/$run/compare/auto -H 'Content-Type: application/json' -d '{"os":"", "device":"", "branch": "main"}' + mobile-check-result: runs-on: ubuntu-latest timeout-minutes: 30 @@ -133,6 +182,7 @@ jobs: if: always() steps: - name: Wait for screenshots comparison + if: ${{ inputs.mobile_percy_project != '' }} run: | npm install -g @percy/cli@latest npx percy build:wait --project ${{ inputs.mobile_percy_project }} --commit ${{ inputs.gitref }}