From 0c17a4f4d0da15bd4388b913d90932b99bb725d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20R=C4=85czy?= Date: Tue, 22 Aug 2023 10:47:56 -0700 Subject: [PATCH] CI: prevent moc from running in cache population step (#29401) * Do not remove moc_files from cache * Add cache cleanup script * Use cache cleanup script * Dry-run in cache population command * Add newline * Temporarly disable master only constraint for cache cleanup step * Add test lines * one more * Fix shebang * Remove debug lines * Bring back master branch constraints old-commit-hash: d1aedccfbe3cb880ad54adea578f91c04857d81b --- .github/workflows/selfdrive_tests.yaml | 8 +++----- release/clean-cache.sh | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 5 deletions(-) create mode 100755 release/clean-cache.sh diff --git a/.github/workflows/selfdrive_tests.yaml b/.github/workflows/selfdrive_tests.yaml index 991ce74ca9..143f831995 100644 --- a/.github/workflows/selfdrive_tests.yaml +++ b/.github/workflows/selfdrive_tests.yaml @@ -82,9 +82,8 @@ jobs: run: ${{ env.RUN }} "scons -j$(nproc) --extras && release/check-dirty.sh" - name: Cleanup scons cache and rebuild timeout-minutes: ${{ ((steps.restore-scons-cache.outputs.cache-hit == 'true') && 2 || 30) }} # allow more time when we missed the scons cache - run: | - ${{ env.RUN }} "rm -rf /tmp/scons_cache/* && \ - scons -j$(nproc) --cache-populate" + if: github.ref == 'refs/heads/master' + run: ${{ env.RUN }} "release/clean-cache.sh" - name: Save scons cache uses: actions/cache/save@v3 if: github.ref == 'refs/heads/master' @@ -159,9 +158,8 @@ jobs: - name: Pre Cache - Cleanup scons cache if: github.ref == 'refs/heads/master' run: | - rm -rf /tmp/scons_cache/* eval "$(pyenv init --path)" - poetry run scons -j$(nproc) --cache-populate + poetry run release/clean-cache.sh - name: Save scons cache id: scons-save-cache uses: actions/cache/save@v3 diff --git a/release/clean-cache.sh b/release/clean-cache.sh new file mode 100755 index 0000000000..ec63ee95b1 --- /dev/null +++ b/release/clean-cache.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +set -e + +# delete outdated moc files +scons --dry-run --taskmastertrace /tmp/tasktrace.log >/dev/null +MOC_EXISTING_PROD="$(find /tmp/scons_cache/moc_files -type f | sort)" +MOC_CURRENT_PROD="$(egrep -o "'[^']*moc_files[^']*'" /tmp/tasktrace.log | sed "s/'//g" | sort | uniq)" +MOC_JUNK="$(comm -23 <(echo "$MOC_EXISTING_PROD") <(echo "$MOC_CURRENT_PROD"))" +echo "$MOC_JUNK" | xargs -I{} rm {} +rm /tmp/tasktrace.log + +# delete cache except for moc files +rm -rf $(find /tmp/scons_cache -maxdepth 1 ! -name moc_files ! -name scons_cache) + +# repopulate cache +scons --dry-run --cache-populate >/dev/null