diff --git a/.github/workflows/selfdrive_tests.yaml b/.github/workflows/selfdrive_tests.yaml index d0e3486020..a0ecf017cf 100644 --- a/.github/workflows/selfdrive_tests.yaml +++ b/.github/workflows/selfdrive_tests.yaml @@ -352,7 +352,7 @@ jobs: - name: Build openpilot run: ${{ env.RUN }} "scons -j$(nproc)" - name: Create Test Report - timeout-minutes: ${{ ((steps.frames-cache.outputs.cache-hit == 'true') && 1 || 3) }} + timeout-minutes: ${{ ((steps.frames-cache.outputs.cache-hit == 'true') && 2 || 4) }} run: > ${{ env.RUN }} "PYTHONWARNINGS=ignore && source selfdrive/test/setup_xvfb.sh && diff --git a/.github/workflows/sunnypilot-build-model.yaml b/.github/workflows/sunnypilot-build-model.yaml index 9b700e186f..cef5badf2d 100644 --- a/.github/workflows/sunnypilot-build-model.yaml +++ b/.github/workflows/sunnypilot-build-model.yaml @@ -37,12 +37,15 @@ jobs: with: path: ${{env.SCONS_CACHE_DIR}} key: scons-${{ runner.os }}-${{ runner.arch }}-${{ github.head_ref || github.ref_name }}-model-${{ github.sha }} + # Note: GitHub Actions enforces cache isolation between different build sources (PR builds, workflow dispatches, etc.) + # for security. Only caches from the default branch are shared across all builds. This is by design and cannot be overridden. restore-keys: | - scons-${{ runner.os }}-${{ runner.arch }}-${{ github.head_ref || github.ref_name }}-model-${{ github.sha }} scons-${{ runner.os }}-${{ runner.arch }}-${{ github.head_ref || github.ref_name }}-model scons-${{ runner.os }}-${{ runner.arch }}-${{ github.head_ref || github.ref_name }} - scons-${{ runner.os }}-${{ runner.arch }}-master-new - scons-${{ runner.os }}-${{ runner.arch }}-master + scons-${{ runner.os }}-${{ runner.arch }}-${{ env.MASTER_NEW_BRANCH }}-model + scons-${{ runner.os }}-${{ runner.arch }}-${{ env.MASTER_BRANCH }}-model + scons-${{ runner.os }}-${{ runner.arch }}-${{ env.MASTER_NEW_BRANCH }} + scons-${{ runner.os }}-${{ runner.arch }}-${{ env.MASTER_BRANCH }} scons-${{ runner.os }}-${{ runner.arch }} - name: Setup build environment diff --git a/.github/workflows/sunnypilot-build-prebuilt.yaml b/.github/workflows/sunnypilot-build-prebuilt.yaml index 1c450425d7..8bb84cda83 100644 --- a/.github/workflows/sunnypilot-build-prebuilt.yaml +++ b/.github/workflows/sunnypilot-build-prebuilt.yaml @@ -51,9 +51,10 @@ jobs: with: path: ${{env.SCONS_CACHE_DIR}} key: scons-${{ runner.os }}-${{ runner.arch }}-${{ github.head_ref || github.ref_name }}-${{ github.sha }} + # Note: GitHub Actions enforces cache isolation between different build sources (PR builds, workflow dispatches, etc.) + # for security. Only caches from the default branch are shared across all builds. This is by design and cannot be overridden. restore-keys: | - scons-${{ runner.os }}-${{ runner.arch }}-${{ github.head_ref }} - scons-${{ runner.os }}-${{ runner.arch }}-${{ github.ref_name }} + scons-${{ runner.os }}-${{ runner.arch }}-${{ github.head_ref || github.ref_name }} scons-${{ runner.os }}-${{ runner.arch }}-${{ env.MASTER_NEW_BRANCH }} scons-${{ runner.os }}-${{ runner.arch }}-${{ env.MASTER_BRANCH }} scons-${{ runner.os }}-${{ runner.arch }} @@ -119,6 +120,7 @@ jobs: if [[ "${{ runner.debug }}" == "1" ]]; then printenv fi + PYTHONPATH=$PYTHONPATH:${{ github.workspace }}/ ${{ github.workspace }}/scripts/manage-powersave.py --disable - name: Build Panda run: | @@ -187,6 +189,11 @@ jobs: name: prebuilt path: prebuilt.tar.gz + - name: Re-enable powersave + if: always() + run: | + PYTHONPATH=$PYTHONPATH:${{ github.workspace }}/ ${{ github.workspace }}/scripts/manage-powersave.py --enable + publish: concurrency: group: publish-${{ github.head_ref || github.ref_name }} diff --git a/scripts/manage-powersave.py b/scripts/manage-powersave.py new file mode 100755 index 0000000000..1a82810a7f --- /dev/null +++ b/scripts/manage-powersave.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python3 +import argparse +import multiprocessing +from openpilot.system.hardware import HARDWARE + + +def main(): + parser = argparse.ArgumentParser(description='Control power saving mode') + parser.add_argument('--enable', action='store_true', help='Enable power saving mode') + parser.add_argument('--disable', action='store_true', help='Disable power saving mode') + args = parser.parse_args() + + if args.enable and args.disable: + parser.error("Cannot specify both --enable and --disable") + elif not (args.enable or args.disable): + parser.error("Must specify either --enable or --disable") + + print(f"Number of CPU cores available before: [{multiprocessing.cpu_count()}]") + HARDWARE.set_power_save(args.enable) + + state = "enabled" if args.enable else "disabled" + print(f"Power save mode set to: [{state}]") + print(f"Number of CPU cores available now: [{multiprocessing.cpu_count()}]") + + +if __name__ == "__main__": + main()