Test selfdrive #13
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: Update Dev | |
on: | |
schedule: | |
- cron: '0 0 * * *' | |
push: | |
jobs: | |
update-dev: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.CI_GITHUB_TOKEN }} | |
- name: Set up Git | |
run: | | |
git config --global user.name "OPGM CI Automated" | |
git config --global user.email "ci@opgm.cc" | |
git remote add upstream https://github.com/commaai/openpilot.git | |
- name: Fetch branches | |
run: | | |
git fetch origin dev | |
git fetch upstream master | |
git fetch upstream master-ci | |
- name: Cache Docker layers | |
uses: actions/cache@v3 | |
with: | |
path: /tmp/.docker-cache | |
key: ${{ runner.os }}-docker-${{ hashFiles('**/Dockerfile') }} | |
restore-keys: | | |
${{ runner.os }}-docker- | |
- name: Push dev to backup branch | |
run: | | |
backup_branch_name="dev-bkp-$(date -u +%Y-%m-%d)" | |
git checkout -f dev | |
git switch -c $backup_branch_name | |
git push -f origin $backup_branch_name --no-verify | |
- name: Unsubmodule master | |
run: | | |
declare -a submodules=("panda" "msgq_repo" "opendbc" "body" "rednose_repo" "tinygrad_repo" "teleoprtc_repo") | |
function unsubmodule() { | |
for submodule in $submodules; do | |
mv $submodule .tmp | |
git submodule deinit -f $submodule | |
git rm -f $submodule | |
mv .tmp $submodule | |
rm -rf $submodule/.git | |
rm -rf $submodule/.github | |
git add $submodule | |
done | |
git rm -f .gitmodules | |
} | |
git checkout -f upstream/master | |
git reset --hard upstream/master | |
rm -rf $submodules | |
git submodule init | |
git submodule update | |
git branch -D unsubmoduled || : | |
git switch -c unsubmoduled | |
unsubmodule | |
git commit -am "I h8 submodules" --author="OPGM CI Automated" | |
- name: Prepare dev-new branch | |
run: | | |
git checkout -f upstream/master-ci | |
git reset --hard upstream/master-ci | |
git branch -D dev-new || : | |
git switch -c dev-new | |
git checkout unsubmoduled panda/tests/ | |
git commit -am "Re-add panda tests" --author="OPGM CI Automated" --no-verify | |
git checkout upstream/master tools | |
git checkout upstream/master .github | |
git checkout upstream/master Dockerfile.openpilot | |
git commit -am "Re-add tools" --author="OPGM CI Automated" --no-verify | |
- name: Cherry-pick dev commits onto dev-new | |
run: | | |
diverged_commits=$(git log --pretty=format:"%H" --reverse upstream/master-ci..origin/dev | tail -n +4) | |
if [ -z "$diverged_commits" ]; then | |
echo "Error: no commits to cherry-pick" | |
exit 1 | |
fi | |
git checkout -f dev-new | |
skip_commits=[] | |
for commit in $diverged_commits; do | |
if [[ $skip_commits =~ $commit ]]; then | |
echo "Skipping $commit" | |
continue | |
fi | |
echo "Cherry-picking $commit : $(git log -1 --pretty=format:"%s" $commit)" | |
git cherry-pick $commit || exit 1 | |
done | |
- name: Build docker image | |
run: | | |
docker build -t openpilot -f Dockerfile.openpilot --cache-from type=local,src=/tmp/.docker-cache . | |
- name: Test panda | |
run: | | |
docker run --rm openpilot panda/tests/safety/test.sh | |
- name: Test selfdrive | |
run: | | |
docker run --rm openpilot pytest selfdrive/car/tests/ | |
- name: Push dev-new to dev | |
run: | | |
git checkout -f dev-new | |
git branch -D dev || : | |
git switch -c dev | |
git push -f origin dev --no-verify | |
- name: Save Docker cache | |
if: success() | |
uses: actions/cache@v3 | |
with: | |
path: /tmp/.docker-cache | |
key: ${{ runner.os }}-docker-${{ hashFiles('**/Dockerfile') }} |