action #5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/[email protected] | |
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 "<li><a href='pr--${{ github.sha }}/index.html'>PR #-${{ github.sha }}</a></li>" >> index.html | |
git config user.name "github-actions" | |
git config user.email "[email protected]" | |
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 |