From 0c22c9ffb3aee4494a9221537b984bc3419f320e Mon Sep 17 00:00:00 2001 From: rusefillc Date: Tue, 4 Jan 2022 11:51:06 -0500 Subject: [PATCH] GHA execution throttling #3739 --- .github/workflows/build-firmware.yaml | 15 +++++++++++++++ misc/actions/execution-throttle.sh | 23 +++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 misc/actions/execution-throttle.sh diff --git a/.github/workflows/build-firmware.yaml b/.github/workflows/build-firmware.yaml index 603db070c3..7ba45f6d55 100644 --- a/.github/workflows/build-firmware.yaml +++ b/.github/workflows/build-firmware.yaml @@ -108,6 +108,7 @@ jobs: - build-target: mre_f4_recovery folder: microrusefi ini-file: rusefi_mre_f4.ini + skip-rate: 90 - build-target: mre_f4_hardware_QC_special_build folder: microrusefi @@ -117,6 +118,7 @@ jobs: folder: microrusefi ini-file: rusefi_mre_f7.ini console-settings: firmware/config/boards/nucleo_f767/rusefi_console_properties.xml + skip-rate: 90 - build-target: prometheus_405 folder: prometheus @@ -125,6 +127,7 @@ jobs: - build-target: prometheus_469 folder: prometheus ini-file: rusefi_prometheus_469.ini + skip-rate: 50 - build-target: proteus_f4 folder: proteus @@ -133,6 +136,7 @@ jobs: - build-target: proteus_f4_hardware_QC_special_build folder: proteus ini-file: rusefi_proteus_f4.ini + skip-rate: 90 - build-target: proteus_f7 folder: proteus @@ -149,17 +153,20 @@ jobs: - build-target: proteus_legacy folder: proteus ini-file: rusefi_proteus_f7.ini + skip-rate: 50 - build-target: stm32f767_nucleo folder: nucleo_f767 ini-file: no console-settings: firmware/config/boards/nucleo_f767/rusefi_console_properties.xml skip-config: yes + skip-rate: 50 - build-target: stm32h743_nucleo folder: nucleo_h743 ini-file: no skip-config: yes + skip-rate: 50 - build-target: subaru_eg33_f7 folder: subaru_eg33 @@ -168,17 +175,25 @@ jobs: - build-target: atlas folder: atlas ini-file: rusefi_atlas.ini + skip-rate: 90 steps: + - id: throttle + name: Execution throttle early exit + run: bash misc/actions/execution-throttle.sh ${{ matrix.skip-rate }} + - uses: actions/checkout@v1 + if: steps.throttle.conclusion == 'success' with: submodules: recursive - uses: actions/setup-java@v1 + if: steps.throttle.conclusion == 'success' with: java-version: '8' - name: Install multilib, mingw, sshpass and mtools + if: steps.throttle.conclusion == 'success' run: | sudo apt-get update sudo apt-get install gcc-multilib g++-multilib g++-mingw-w64 gcc-mingw-w64 sshpass mtools diff --git a/misc/actions/execution-throttle.sh b/misc/actions/execution-throttle.sh new file mode 100644 index 0000000000..df6611f0d2 --- /dev/null +++ b/misc/actions/execution-throttle.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +# +# we use this script to reduce github actions load by executing some tasks less frequent than always +# param: THRESHOLD, rate of SKIPPING task, from 0 to 100. No skipping if zero, always skipping if 100. +# + +THRESHOLD=$1 +if [ -z $THRESHOLD ] ; then + echo "Throttle threshold not specified, allowing always" + exit 0 +fi + +RANDOM100=$(($RANDOM % 100)) +msg="Random ${RANDOM100} while threshold $THRESHOLD:" + +if (( ${RANDOM100} > $THRESHOLD )); then + echo "$msg Allowing" + exit 0 +else + echo "$msg Not this time, maybe next time" + exit -1 +fi