mirror of
https://github.com/jomjol/AI-on-the-edge-device.git
synced 2025-12-20 22:48:26 +03:00
improve caching (#1836)
* improve caching See https://github.com/actions/cache/blob/main/tips-and-workarounds.md#update-a-cache * Update build.yaml * Update build.yaml * Update build.yaml * Update README.md * Update build.yaml * Update build.yaml * Update README.md * Update build.yaml
This commit is contained in:
145
.github/workflows/build.yaml
vendored
145
.github/workflows/build.yaml
vendored
@@ -24,19 +24,37 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
|
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Cache PIP
|
- name: Update PIP cache on every commit
|
||||||
uses: actions/cache@v3.2.3
|
uses: actions/cache@v3.2.3
|
||||||
with:
|
with:
|
||||||
path: ~/.cache/pip
|
path: ~/.cache/pip
|
||||||
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
|
key: pip-${{ github.run_id }}
|
||||||
restore-keys: |
|
restore-keys: pip # This matches above key as it is only used as a prefix. it the restores the nearest cache, see https://github.com/restore-keys:/blob/main/tips-and-workarounds.md#update-a-cache
|
||||||
${{ runner.os }}-pip-
|
|
||||||
|
|
||||||
- name: Cache PlatformIO
|
- name: Update PlatformIO cache on every commit
|
||||||
uses: actions/cache@v3.2.3
|
uses: actions/cache@v3.2.3
|
||||||
with:
|
with:
|
||||||
path: ~/.platformio
|
path: ~/.platformio
|
||||||
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}
|
key: platformio-${{ github.run_id }}
|
||||||
|
restore-keys: platformio # This matches above key as it is only used as a prefix. it the restores the nearest cache, see https://github.com/restore-keys:/blob/main/tips-and-workarounds.md#update-a-cache
|
||||||
|
|
||||||
|
- name: Update Build cache on every commit
|
||||||
|
uses: actions/cache@v3.2.3
|
||||||
|
with:
|
||||||
|
path: ./code/.pio/
|
||||||
|
key: build-${{ github.run_id }}
|
||||||
|
restore-keys: build # This matches above key as it is only used as a prefix. it the restores the nearest cache, see https://github.com/restore-keys:/blob/main/tips-and-workarounds.md#update-a-cache
|
||||||
|
|
||||||
|
- name: Update generated-files cache on every commit
|
||||||
|
uses: actions/cache@v3.2.3
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
./code/.pio/build/esp32cam/firmware.bin
|
||||||
|
./code/.pio/build/esp32cam/partitions.bin
|
||||||
|
./code/.pio/build/esp32cam/bootloader.bin
|
||||||
|
./sd-card/html/*
|
||||||
|
key: generated-files-${{ github.run_id }}
|
||||||
|
restore-keys: generated-files # This matches above key as it is only used as a prefix. it the restores the nearest cache, see https://github.com/restore-keys:/blob/main/tips-and-workarounds.md#update-a-cache
|
||||||
|
|
||||||
- name: Set up Python
|
- name: Set up Python
|
||||||
uses: actions/setup-python@v4
|
uses: actions/setup-python@v4
|
||||||
@@ -48,12 +66,6 @@ jobs:
|
|||||||
python -m pip install --upgrade pip
|
python -m pip install --upgrade pip
|
||||||
pip install --upgrade platformio
|
pip install --upgrade platformio
|
||||||
|
|
||||||
- name: Use Build Cache
|
|
||||||
uses: actions/cache@v3.2.3
|
|
||||||
with:
|
|
||||||
path: ./code/.pio/
|
|
||||||
key: ${{ runner.os }}-pio-${{ github.ref_name }}
|
|
||||||
|
|
||||||
- name: Build Firmware
|
- name: Build Firmware
|
||||||
#run: echo "Testing... ${{ github.ref_name }}, ${{ steps.vars.outputs.sha_short }}" > ./sd-card/html/version.txt; mkdir -p ./code/.pio/build/esp32cam/; cd ./code/.pio/build/esp32cam/; echo "${{ steps.vars.outputs.sha_short }}" > firmware.bin; cp firmware.bin partitions.bin; cp firmware.bin bootloader.bin # Testing
|
#run: echo "Testing... ${{ github.ref_name }}, ${{ steps.vars.outputs.sha_short }}" > ./sd-card/html/version.txt; mkdir -p ./code/.pio/build/esp32cam/; cd ./code/.pio/build/esp32cam/; echo "${{ steps.vars.outputs.sha_short }}" > firmware.bin; cp firmware.bin partitions.bin; cp firmware.bin bootloader.bin # Testing
|
||||||
run: cd code; platformio run --environment esp32cam
|
run: cd code; platformio run --environment esp32cam
|
||||||
@@ -62,16 +74,6 @@ jobs:
|
|||||||
run: cd sd-card/html; find . -type f -exec sed -i 's/$COMMIT_HASH/${{ steps.vars.outputs.sha_short }}/g' {} \;
|
run: cd sd-card/html; find . -type f -exec sed -i 's/$COMMIT_HASH/${{ steps.vars.outputs.sha_short }}/g' {} \;
|
||||||
|
|
||||||
|
|
||||||
- name: Store generated files in cache
|
|
||||||
uses: actions/cache@v3.2.3
|
|
||||||
with:
|
|
||||||
path: |
|
|
||||||
./code/.pio/build/esp32cam/firmware.bin
|
|
||||||
./code/.pio/build/esp32cam/partitions.bin
|
|
||||||
./code/.pio/build/esp32cam/bootloader.bin
|
|
||||||
./sd-card/html/*
|
|
||||||
key: ${{ github.run_number }}
|
|
||||||
|
|
||||||
|
|
||||||
#########################################################################################
|
#########################################################################################
|
||||||
## Pack for Update
|
## Pack for Update
|
||||||
@@ -88,7 +90,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Get generated files from cache
|
- name: Update generated-files cache on every commit
|
||||||
uses: actions/cache@v3.2.3
|
uses: actions/cache@v3.2.3
|
||||||
with:
|
with:
|
||||||
path: |
|
path: |
|
||||||
@@ -96,8 +98,16 @@ jobs:
|
|||||||
./code/.pio/build/esp32cam/partitions.bin
|
./code/.pio/build/esp32cam/partitions.bin
|
||||||
./code/.pio/build/esp32cam/bootloader.bin
|
./code/.pio/build/esp32cam/bootloader.bin
|
||||||
./sd-card/html/*
|
./sd-card/html/*
|
||||||
key: ${{ github.run_number }}
|
key: generated-files-${{ github.run_id }}
|
||||||
|
restore-keys: generated-files # This matches above key as it is only used as a prefix. it the restores the nearest cache, see https://github.com/restore-keys:/blob/main/tips-and-workarounds.md#update-a-cache
|
||||||
|
|
||||||
|
- name: Update update cache on every commit
|
||||||
|
uses: actions/cache@v3.2.3
|
||||||
|
with:
|
||||||
|
path: update
|
||||||
|
key: update-${{ github.run_id }}
|
||||||
|
restore-keys: update # This matches above key as it is only used as a prefix. it the restores the nearest cache, see https://github.com/restore-keys:/blob/main/tips-and-workarounds.md#update-a-cache
|
||||||
|
|
||||||
- name: Set Variables
|
- name: Set Variables
|
||||||
id: vars
|
id: vars
|
||||||
run: |
|
run: |
|
||||||
@@ -114,7 +124,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Add CNN to update
|
- name: Add CNN to update
|
||||||
run: |
|
run: |
|
||||||
mkdir ./update/config/
|
mkdir -p ./update/config/
|
||||||
cp ./sd-card/config/*.tfl ./update/config/ 2>/dev/null || true
|
cp ./sd-card/config/*.tfl ./update/config/ 2>/dev/null || true
|
||||||
cp ./sd-card/config/*.tflite ./update/config/ 2>/dev/null || true
|
cp ./sd-card/config/*.tflite ./update/config/ 2>/dev/null || true
|
||||||
|
|
||||||
@@ -124,11 +134,6 @@ jobs:
|
|||||||
name: "AI-on-the-edge-device__update__${{ steps.vars.outputs.branch }}_(${{ steps.vars.outputs.sha_short }})"
|
name: "AI-on-the-edge-device__update__${{ steps.vars.outputs.branch }}_(${{ steps.vars.outputs.sha_short }})"
|
||||||
path: ./update/*
|
path: ./update/*
|
||||||
|
|
||||||
- name: Store generated files in cache
|
|
||||||
uses: actions/cache@v3.2.3
|
|
||||||
with:
|
|
||||||
path: update
|
|
||||||
key: ${{ github.run_number }}-update
|
|
||||||
|
|
||||||
|
|
||||||
#########################################################################################
|
#########################################################################################
|
||||||
@@ -146,7 +151,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Get generated files from cache
|
- name: Update generated-files cache on every commit
|
||||||
uses: actions/cache@v3.2.3
|
uses: actions/cache@v3.2.3
|
||||||
with:
|
with:
|
||||||
path: |
|
path: |
|
||||||
@@ -154,7 +159,15 @@ jobs:
|
|||||||
./code/.pio/build/esp32cam/partitions.bin
|
./code/.pio/build/esp32cam/partitions.bin
|
||||||
./code/.pio/build/esp32cam/bootloader.bin
|
./code/.pio/build/esp32cam/bootloader.bin
|
||||||
./sd-card/html/*
|
./sd-card/html/*
|
||||||
key: ${{ github.run_number }}
|
key: generated-files-${{ github.run_id }}
|
||||||
|
restore-keys: generated-files # This matches above key as it is only used as a prefix. it the restores the nearest cache, see https://github.com/restore-keys:/blob/main/tips-and-workarounds.md#update-a-cache
|
||||||
|
|
||||||
|
- name: Update remote_setup cache on every commit
|
||||||
|
uses: actions/cache@v3.2.3
|
||||||
|
with:
|
||||||
|
path: remote_setup
|
||||||
|
key: remote_setup-${{ github.run_id }}
|
||||||
|
restore-keys: remote_setup # This matches above key as it is only used as a prefix. it the restores the nearest cache, see https://github.com/restore-keys:/blob/main/tips-and-workarounds.md#update-a-cache
|
||||||
|
|
||||||
- name: Set Variables
|
- name: Set Variables
|
||||||
id: vars
|
id: vars
|
||||||
@@ -172,7 +185,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Add whole config folder to remote_setup
|
- name: Add whole config folder to remote_setup
|
||||||
run: |
|
run: |
|
||||||
mkdir ./remote_setup/config/
|
mkdir -p ./remote_setup/config/
|
||||||
cp ./sd-card/config/* ./remote_setup/config/ 2>/dev/null || true
|
cp ./sd-card/config/* ./remote_setup/config/ 2>/dev/null || true
|
||||||
|
|
||||||
- name: Upload remote_setup as remote_setup.zip artifact (Firmware + Web UI + Config)
|
- name: Upload remote_setup as remote_setup.zip artifact (Firmware + Web UI + Config)
|
||||||
@@ -181,12 +194,6 @@ jobs:
|
|||||||
name: "AI-on-the-edge-device__remote-setup__${{ steps.vars.outputs.branch }}_(${{ steps.vars.outputs.sha_short }})"
|
name: "AI-on-the-edge-device__remote-setup__${{ steps.vars.outputs.branch }}_(${{ steps.vars.outputs.sha_short }})"
|
||||||
path: ./remote_setup/*
|
path: ./remote_setup/*
|
||||||
|
|
||||||
- name: Store generated files in cache
|
|
||||||
uses: actions/cache@v3.2.3
|
|
||||||
with:
|
|
||||||
path: remote_setup
|
|
||||||
key: ${{ github.run_number }}-remote_setup
|
|
||||||
|
|
||||||
|
|
||||||
#########################################################################################
|
#########################################################################################
|
||||||
## Pack for a fresh install (USB flashing) (manual_setup)
|
## Pack for a fresh install (USB flashing) (manual_setup)
|
||||||
@@ -199,7 +206,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Get generated files from cache
|
- name: Update generated-files cache on every commit
|
||||||
uses: actions/cache@v3.2.3
|
uses: actions/cache@v3.2.3
|
||||||
with:
|
with:
|
||||||
path: |
|
path: |
|
||||||
@@ -207,7 +214,15 @@ jobs:
|
|||||||
./code/.pio/build/esp32cam/partitions.bin
|
./code/.pio/build/esp32cam/partitions.bin
|
||||||
./code/.pio/build/esp32cam/bootloader.bin
|
./code/.pio/build/esp32cam/bootloader.bin
|
||||||
./sd-card/html/*
|
./sd-card/html/*
|
||||||
key: ${{ github.run_number }}
|
key: generated-files-${{ github.run_id }}
|
||||||
|
restore-keys: generated-files # This matches above key as it is only used as a prefix. it the restores the nearest cache, see https://github.com/restore-keys:/blob/main/tips-and-workarounds.md#update-a-cache
|
||||||
|
|
||||||
|
- name: Update manual_setup cache on every commit
|
||||||
|
uses: actions/cache@v3.2.3
|
||||||
|
with:
|
||||||
|
path: manual_setup
|
||||||
|
key: manual_setup-${{ github.run_id }}
|
||||||
|
restore-keys: manual_setup # This matches above key as it is only used as a prefix. it the restores the nearest cache, see https://github.com/restore-keys:/blob/main/tips-and-workarounds.md#update-a-cache
|
||||||
|
|
||||||
- name: Set Variables
|
- name: Set Variables
|
||||||
id: vars
|
id: vars
|
||||||
@@ -233,12 +248,6 @@ jobs:
|
|||||||
name: "AI-on-the-edge-device__manual-setup__${{ steps.vars.outputs.branch }}_(${{ steps.vars.outputs.sha_short }})"
|
name: "AI-on-the-edge-device__manual-setup__${{ steps.vars.outputs.branch }}_(${{ steps.vars.outputs.sha_short }})"
|
||||||
path: ./manual_setup
|
path: ./manual_setup
|
||||||
|
|
||||||
- name: Store generated files in cache
|
|
||||||
uses: actions/cache@v3.2.3
|
|
||||||
with:
|
|
||||||
path: manual_setup
|
|
||||||
key: ${{ github.run_number }}-manual_setup
|
|
||||||
|
|
||||||
|
|
||||||
#########################################################################################
|
#########################################################################################
|
||||||
## Prepare and create release
|
## Prepare and create release
|
||||||
@@ -247,30 +256,36 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: [pack-for-update, pack-for-manual_setup, pack-for-remote_setup]
|
needs: [pack-for-update, pack-for-manual_setup, pack-for-remote_setup]
|
||||||
if: startsWith(github.ref, 'refs/tags/')
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
|
|
||||||
|
# Sets permissions of the GITHUB_TOKEN to allow updating the branches
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
pages: write
|
||||||
|
id-token: write
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
# import update
|
- name: Update update cache on every commit
|
||||||
- name: Get generated update files from cache
|
|
||||||
uses: actions/cache@v3.2.3
|
uses: actions/cache@v3.2.3
|
||||||
with:
|
with:
|
||||||
path: update
|
path: update
|
||||||
key: ${{ github.run_number }}-update
|
key: update-${{ github.run_id }}
|
||||||
|
restore-keys: update # This matches above key as it is only used as a prefix. it the restores the nearest cache, see https://github.com/restore-keys:/blob/main/tips-and-workarounds.md#update-a-cache
|
||||||
# import remote_setup
|
|
||||||
- name: Get generated files from cache
|
- name: Update remote_setup cache on every commit
|
||||||
uses: actions/cache@v3.2.3
|
uses: actions/cache@v3.2.3
|
||||||
with:
|
with:
|
||||||
path: remote_setup
|
path: remote_setup
|
||||||
key: ${{ github.run_number }}-remote_setup
|
key: remote_setup-${{ github.run_id }}
|
||||||
|
restore-keys: remote_setup # This matches above key as it is only used as a prefix. it the restores the nearest cache, see https://github.com/restore-keys:/blob/main/tips-and-workarounds.md#update-a-cache
|
||||||
# import manual_setup
|
|
||||||
- name: Get generated files from cache
|
- name: Update manual_setup cache on every commit
|
||||||
uses: actions/cache@v3.2.3
|
uses: actions/cache@v3.2.3
|
||||||
with:
|
with:
|
||||||
path: manual_setup
|
path: manual_setup
|
||||||
key: ${{ github.run_number }}-manual_setup
|
key: manual_setup-${{ github.run_id }}
|
||||||
|
restore-keys: manual_setup # This matches above key as it is only used as a prefix. it the restores the nearest cache, see https://github.com/restore-keys:/blob/main/tips-and-workarounds.md#update-a-cache
|
||||||
|
|
||||||
- name: Set Variables
|
- name: Set Variables
|
||||||
id: vars
|
id: vars
|
||||||
@@ -320,6 +335,10 @@ jobs:
|
|||||||
# all artifacts in firmware folder pushed to the release
|
# all artifacts in firmware folder pushed to the release
|
||||||
- name: Release
|
- name: Release
|
||||||
uses: softprops/action-gh-release@v1
|
uses: softprops/action-gh-release@v1
|
||||||
|
# Note:
|
||||||
|
# If you get the error "Resource not accessible by integration",
|
||||||
|
# The access rights are not sufficient, see
|
||||||
|
# https://github.com/softprops/action-gh-release/issues/232#issuecomment-1131379440
|
||||||
if: startsWith(github.ref, 'refs/tags/')
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
with:
|
with:
|
||||||
name: ${{ steps.get_version.outputs.version-without-v }}
|
name: ${{ steps.get_version.outputs.version-without-v }}
|
||||||
@@ -359,12 +378,12 @@ jobs:
|
|||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
# import update
|
- name: Update update cache on every commit
|
||||||
- name: Get generated update files from cache
|
|
||||||
uses: actions/cache@v3.2.3
|
uses: actions/cache@v3.2.3
|
||||||
with:
|
with:
|
||||||
path: update
|
path: update
|
||||||
key: ${{ github.run_number }}-update
|
key: update-${{ github.run_id }}
|
||||||
|
restore-keys: update # This matches above key as it is only used as a prefix. it the restores the nearest cache, see https://github.com/restore-keys:/blob/main/tips-and-workarounds.md#update-a-cache
|
||||||
|
|
||||||
- name: Set Variables
|
- name: Set Variables
|
||||||
id: vars
|
id: vars
|
||||||
|
|||||||
Reference in New Issue
Block a user