1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-21 19:23:45 +01:00
This commit is contained in:
J. Nick Koston
2025-10-17 16:39:10 -10:00
parent 558d4eb9dd
commit 1ec9383abe

View File

@@ -540,13 +540,22 @@ jobs:
with: with:
ref: ${{ github.base_ref }} ref: ${{ github.base_ref }}
# Create cache key based on: # Check if memory impact extraction script exists on target branch
# 1. Target branch commit SHA # If not, skip the analysis (this handles older branches that don't have the feature)
# 2. Hash of build infrastructure files (scripts and CI workflow) - name: Check for memory impact script
# 3. Platform being tested id: check-script
# 4. Component list run: |
if [ -f "script/ci_memory_impact_extract.py" ]; then
echo "skip=false" >> $GITHUB_OUTPUT
else
echo "skip=true" >> $GITHUB_OUTPUT
echo "::warning::ci_memory_impact_extract.py not found on target branch, skipping memory impact analysis"
fi
# All remaining steps only run if script exists
- name: Generate cache key - name: Generate cache key
id: cache-key id: cache-key
if: steps.check-script.outputs.skip != 'true'
run: | run: |
# Get the commit SHA of the target branch # Get the commit SHA of the target branch
target_sha=$(git rev-parse HEAD) target_sha=$(git rev-parse HEAD)
@@ -571,15 +580,16 @@ jobs:
echo "cache-key=${cache_key}" >> $GITHUB_OUTPUT echo "cache-key=${cache_key}" >> $GITHUB_OUTPUT
echo "Cache key: ${cache_key}" echo "Cache key: ${cache_key}"
# Try to restore cached analysis results
- name: Restore cached memory analysis - name: Restore cached memory analysis
id: cache-memory-analysis id: cache-memory-analysis
if: steps.check-script.outputs.skip != 'true'
uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with: with:
path: memory-analysis-target.json path: memory-analysis-target.json
key: ${{ steps.cache-key.outputs.cache-key }} key: ${{ steps.cache-key.outputs.cache-key }}
- name: Cache status - name: Cache status
if: steps.check-script.outputs.skip != 'true'
run: | run: |
if [ "${{ steps.cache-memory-analysis.outputs.cache-hit }}" == "true" ]; then if [ "${{ steps.cache-memory-analysis.outputs.cache-hit }}" == "true" ]; then
echo "✓ Cache hit! Using cached memory analysis results." echo "✓ Cache hit! Using cached memory analysis results."
@@ -588,23 +598,22 @@ jobs:
echo "✗ Cache miss. Will build and analyze memory usage." echo "✗ Cache miss. Will build and analyze memory usage."
fi fi
# Only restore Python and build if cache miss
- name: Restore Python - name: Restore Python
if: steps.cache-memory-analysis.outputs.cache-hit != 'true' if: steps.check-script.outputs.skip != 'true' && steps.cache-memory-analysis.outputs.cache-hit != 'true'
uses: ./.github/actions/restore-python uses: ./.github/actions/restore-python
with: with:
python-version: ${{ env.DEFAULT_PYTHON }} python-version: ${{ env.DEFAULT_PYTHON }}
cache-key: ${{ needs.common.outputs.cache-key }} cache-key: ${{ needs.common.outputs.cache-key }}
- name: Cache platformio - name: Cache platformio
if: steps.cache-memory-analysis.outputs.cache-hit != 'true' if: steps.check-script.outputs.skip != 'true' && steps.cache-memory-analysis.outputs.cache-hit != 'true'
uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with: with:
path: ~/.platformio path: ~/.platformio
key: platformio-memory-${{ fromJSON(needs.determine-jobs.outputs.memory_impact).platform }}-${{ hashFiles('platformio.ini') }} key: platformio-memory-${{ fromJSON(needs.determine-jobs.outputs.memory_impact).platform }}-${{ hashFiles('platformio.ini') }}
- name: Build, compile, and analyze memory - name: Build, compile, and analyze memory
if: steps.cache-memory-analysis.outputs.cache-hit != 'true' if: steps.check-script.outputs.skip != 'true' && steps.cache-memory-analysis.outputs.cache-hit != 'true'
id: build id: build
run: | run: |
. venv/bin/activate . venv/bin/activate
@@ -631,17 +640,16 @@ jobs:
--output-env \ --output-env \
--output-json memory-analysis-target.json --output-json memory-analysis-target.json
# Save build results to cache for future runs
- name: Save memory analysis to cache - name: Save memory analysis to cache
if: steps.cache-memory-analysis.outputs.cache-hit != 'true' && steps.build.outcome == 'success' if: steps.check-script.outputs.skip != 'true' && steps.cache-memory-analysis.outputs.cache-hit != 'true' && steps.build.outcome == 'success'
uses: actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 uses: actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with: with:
path: memory-analysis-target.json path: memory-analysis-target.json
key: ${{ steps.cache-key.outputs.cache-key }} key: ${{ steps.cache-key.outputs.cache-key }}
# Extract outputs from cached or freshly built analysis
- name: Extract memory usage for outputs - name: Extract memory usage for outputs
id: extract id: extract
if: steps.check-script.outputs.skip != 'true'
run: | run: |
if [ -f memory-analysis-target.json ]; then if [ -f memory-analysis-target.json ]; then
ram=$(jq -r '.ram_bytes' memory-analysis-target.json) ram=$(jq -r '.ram_bytes' memory-analysis-target.json)