mirror of
https://github.com/dzid26/sunnypilot.git
synced 2026-06-08 07:44:55 +08:00
ci: dynamic submodule check for build_release (#1114)
* ci: dynamic submodule check for build_release * test opendbc diff * somem fix * this way * use path * use master branch instead * less verbose * test bump * test 1 more sub change * unbump * only echo if there's a diff
This commit is contained in:
18
.github/workflows/selfdrive_tests.yaml
vendored
18
.github/workflows/selfdrive_tests.yaml
vendored
@@ -67,7 +67,23 @@ jobs:
|
|||||||
- name: Check submodules
|
- name: Check submodules
|
||||||
if: github.repository == 'sunnypilot/sunnypilot'
|
if: github.repository == 'sunnypilot/sunnypilot'
|
||||||
timeout-minutes: 3
|
timeout-minutes: 3
|
||||||
run: release/check-submodules.sh
|
run: |
|
||||||
|
if [ "${{ github.ref }}" != "refs/heads/master" ]; then
|
||||||
|
git fetch origin master:refs/remotes/origin/master
|
||||||
|
|
||||||
|
SUBMODULE_PATHS=$(git diff origin/master HEAD --name-only | grep -E '^[^/]+$' | while read path; do
|
||||||
|
if git ls-files --stage "$path" | grep -q "^160000"; then
|
||||||
|
echo "$path"
|
||||||
|
fi
|
||||||
|
done | tr '\n' ' ')
|
||||||
|
|
||||||
|
if [ -n "$SUBMODULE_PATHS" ]; then
|
||||||
|
echo "Changed submodule paths: $SUBMODULE_PATHS"
|
||||||
|
export SUBMODULE_PATHS="$SUBMODULE_PATHS"
|
||||||
|
export CHECK_PR_REFS=true
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
release/check-submodules.sh
|
||||||
|
|
||||||
build:
|
build:
|
||||||
runs-on: ${{
|
runs-on: ${{
|
||||||
|
|||||||
@@ -1,17 +1,43 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
has_submodule_changes() {
|
||||||
|
local submodule_path="$1"
|
||||||
|
if [ -n "$SUBMODULE_PATHS" ]; then
|
||||||
|
echo "$SUBMODULE_PATHS" | grep -q "$submodule_path"
|
||||||
|
return $?
|
||||||
|
fi
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
while read hash submodule ref; do
|
while read hash submodule ref; do
|
||||||
|
if [ -z "$hash" ] || [ -z "$submodule" ]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
hash=$(echo "$hash" | sed 's/^[+-]//')
|
||||||
|
|
||||||
if [ "$submodule" = "tinygrad_repo" ]; then
|
if [ "$submodule" = "tinygrad_repo" ]; then
|
||||||
echo "Skipping $submodule"
|
echo "Skipping $submodule"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
git -C $submodule fetch --depth 100 origin master
|
if [ "$CHECK_PR_REFS" = "true" ] && has_submodule_changes "$submodule"; then
|
||||||
git -C $submodule branch -r --contains $hash | grep "origin/master"
|
echo "Checking $submodule (non-master): verifying hash $hash exists"
|
||||||
if [ "$?" -eq 0 ]; then
|
git -C $submodule fetch --depth 100 origin
|
||||||
echo "$submodule ok"
|
if git -C $submodule cat-file -e $hash 2>/dev/null; then
|
||||||
|
echo "$submodule ok (hash exists)"
|
||||||
|
else
|
||||||
|
echo "$submodule: $hash does not exist in the repository"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
echo "$submodule: $hash is not on master"
|
git -C $submodule fetch --depth 100 origin master
|
||||||
exit 1
|
git -C $submodule branch -r --contains $hash | grep "origin/master"
|
||||||
|
if [ "$?" -eq 0 ]; then
|
||||||
|
echo "$submodule ok"
|
||||||
|
else
|
||||||
|
echo "$submodule: $hash is not on master"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
done <<< $(git submodule status --recursive)
|
done <<< $(git submodule status --recursive)
|
||||||
|
|||||||
Reference in New Issue
Block a user