From 995af857447ebe7d5fd52b7e059e47d86dd293a0 Mon Sep 17 00:00:00 2001 From: jakethesnake420 Date: Mon, 29 Jan 2024 23:23:42 -0600 Subject: [PATCH] action --- .github/workflows/ui-compare.yaml | 88 +++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 .github/workflows/ui-compare.yaml diff --git a/.github/workflows/ui-compare.yaml b/.github/workflows/ui-compare.yaml new file mode 100644 index 00000000000000..a8abbdd6f8c4ef --- /dev/null +++ b/.github/workflows/ui-compare.yaml @@ -0,0 +1,88 @@ +name: ui + +on: + push: + branches: + - test-ui + pull_request: + types: [opened, synchronize, reopened] + +concurrency: + group: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' && github.run_id || github.head_ref || github.ref }}-${{ github.workflow }}-${{ github.event_name }} + cancel-in-progress: true + +env: + BASE_IMAGE: openpilot-base + CL_BASE_IMAGE: openpilot-base-cl + DOCKER_LOGIN: docker login ghcr.io -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }} + + BUILD: selfdrive/test/docker_build.sh base + + RUN: docker run --shm-size 1G -v $GITHUB_WORKSPACE:/tmp/openpilot -w /tmp/openpilot -e FILEREADER_CACHE=1 -e PYTHONPATH=/tmp/openpilot -e NUM_JOBS -e JOB_ID -e GITHUB_ACTION -e GITHUB_REF -e GITHUB_HEAD_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_RUN_ID -v $GITHUB_WORKSPACE/.ci_cache/scons_cache:/tmp/scons_cache -v $GITHUB_WORKSPACE/.ci_cache/comma_download_cache:/tmp/comma_download_cache -v $GITHUB_WORKSPACE/.ci_cache/openpilot_cache:/tmp/openpilot_cache $BASE_IMAGE /bin/bash -c + + BUILD_CL: selfdrive/test/docker_build.sh cl + + RUN_CL: docker run --shm-size 1G -v $GITHUB_WORKSPACE:/tmp/openpilot -w /tmp/openpilot -e PYTHONPATH=/tmp/openpilot -e NUM_JOBS -e JOB_ID -e GITHUB_ACTION -e GITHUB_REF -e GITHUB_HEAD_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_RUN_ID -v $GITHUB_WORKSPACE/.ci_cache/scons_cache:/tmp/scons_cache -v $GITHUB_WORKSPACE/.ci_cache/comma_download_cache:/tmp/comma_download_cache -v $GITHUB_WORKSPACE/.ci_cache/openpilot_cache:/tmp/openpilot_cache $CL_BASE_IMAGE /bin/bash -c + + +jobs: + screenshots: + name: screenshots + runs-on: ubuntu-20.04 + timeout-minutes: 20 + steps: + - uses: actions/checkout@v4 + with: + submodules: true + - run: git lfs pull + - uses: ./.github/workflows/setup-with-retry + - name: Build base docker image + run: eval "$BUILD" + - name: Build base cl image + run: eval "$BUILD_CL" + - name: Build openpilot + run: | + ${{ env.RUN }} "scons -j$(nproc)" + - name: Run UI Screenshots + run: | + ${{ env.RUN_CL }} "source selfdrive/test/setup_xvfb.sh && python selfdrive/ui/tests/test_ui/run.py" + - name: Upload Report + uses: actions/upload-artifact@v2 + with: + name: html-report + path: | + selfdrive/ui/tests/test_ui/report/index.html + selfdrive/ui/tests/test_ui/report/screenshots + - name: Deploy to GitHub Pages + uses: JamesIves/github-pages-deploy-action@4.1.4 + with: + branch: gh-pages + repository-name: ${{ github.repository }} + target-folder: pr--${{ github.sha }} + folder: selfdrive/ui/tests/test_ui/report + + - name: Append PR Link to Index + if: success() + run: | + git fetch origin gh-pages --depth=1 + git checkout gh-pages + echo "
  • PR #-${{ github.sha }}
  • " >> index.html + git config user.name "github-actions" + git config user.email "github-actions@github.com" + git add index.html + git commit -m "Update index.html with PR #-${{ github.sha }}" + + - name: Push Changes with Retry + if: success() + run: | + max_attempts=3 + attempt=0 + until git push origin gh-pages; do + git pull --rebase origin gh-pages + attempt=$((attempt+1)) + if [ "$attempt" -ge "$max_attempts" ]; then + echo "Push failed after $attempt attempts." + exit 1 + fi + sleep 3 + done \ No newline at end of file