mirror of
https://github.com/esphome/esphome.git
synced 2026-06-04 01:18:26 +08:00
[ci] Skip memory impact target branch build when tests don't exist (#14316)
This commit is contained in:
+39
-10
@@ -686,7 +686,7 @@ jobs:
|
|||||||
ram_usage: ${{ steps.extract.outputs.ram_usage }}
|
ram_usage: ${{ steps.extract.outputs.ram_usage }}
|
||||||
flash_usage: ${{ steps.extract.outputs.flash_usage }}
|
flash_usage: ${{ steps.extract.outputs.flash_usage }}
|
||||||
cache_hit: ${{ steps.cache-memory-analysis.outputs.cache-hit }}
|
cache_hit: ${{ steps.cache-memory-analysis.outputs.cache-hit }}
|
||||||
skip: ${{ steps.check-script.outputs.skip }}
|
skip: ${{ steps.check-script.outputs.skip || steps.check-tests.outputs.skip }}
|
||||||
steps:
|
steps:
|
||||||
- name: Check out target branch
|
- name: Check out target branch
|
||||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||||
@@ -705,10 +705,39 @@ jobs:
|
|||||||
echo "::warning::ci_memory_impact_extract.py not found on target branch, skipping memory impact analysis"
|
echo "::warning::ci_memory_impact_extract.py not found on target branch, skipping memory impact analysis"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# All remaining steps only run if script exists
|
# Check if test files exist on the target branch for the requested
|
||||||
|
# components and platform. When a PR adds new test files for a platform,
|
||||||
|
# the target branch won't have them yet, so skip instead of failing.
|
||||||
|
# This check must be done here (not in determine-jobs.py) because
|
||||||
|
# determine-jobs runs on the PR branch and cannot see what the target
|
||||||
|
# branch has.
|
||||||
|
- name: Check for test files on target branch
|
||||||
|
id: check-tests
|
||||||
|
if: steps.check-script.outputs.skip != 'true'
|
||||||
|
run: |
|
||||||
|
components='${{ toJSON(fromJSON(needs.determine-jobs.outputs.memory_impact).components) }}'
|
||||||
|
platform="${{ fromJSON(needs.determine-jobs.outputs.memory_impact).platform }}"
|
||||||
|
found=false
|
||||||
|
for component in $(echo "$components" | jq -r '.[]'); do
|
||||||
|
# Check for test files matching the platform (test.platform.yaml or test-*.platform.yaml)
|
||||||
|
for f in tests/components/${component}/test*.${platform}.yaml; do
|
||||||
|
if [ -f "$f" ]; then
|
||||||
|
found=true
|
||||||
|
break 2
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
done
|
||||||
|
if [ "$found" = false ]; then
|
||||||
|
echo "skip=true" >> $GITHUB_OUTPUT
|
||||||
|
echo "::warning::No test files found on target branch for platform ${platform}, skipping memory impact analysis"
|
||||||
|
else
|
||||||
|
echo "skip=false" >> $GITHUB_OUTPUT
|
||||||
|
fi
|
||||||
|
|
||||||
|
# All remaining steps only run if script and tests exist
|
||||||
- name: Generate cache key
|
- name: Generate cache key
|
||||||
id: cache-key
|
id: cache-key
|
||||||
if: steps.check-script.outputs.skip != 'true'
|
if: steps.check-script.outputs.skip != 'true' && steps.check-tests.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)
|
||||||
@@ -735,14 +764,14 @@ jobs:
|
|||||||
|
|
||||||
- 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'
|
if: steps.check-script.outputs.skip != 'true' && steps.check-tests.outputs.skip != 'true'
|
||||||
uses: actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
|
uses: actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
|
||||||
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'
|
if: steps.check-script.outputs.skip != 'true' && steps.check-tests.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."
|
||||||
@@ -752,21 +781,21 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Restore Python
|
- name: Restore Python
|
||||||
if: steps.check-script.outputs.skip != 'true' && steps.cache-memory-analysis.outputs.cache-hit != 'true'
|
if: steps.check-script.outputs.skip != 'true' && steps.check-tests.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.check-script.outputs.skip != 'true' && steps.cache-memory-analysis.outputs.cache-hit != 'true'
|
if: steps.check-script.outputs.skip != 'true' && steps.check-tests.outputs.skip != 'true' && steps.cache-memory-analysis.outputs.cache-hit != 'true'
|
||||||
uses: actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
|
uses: actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
|
||||||
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.check-script.outputs.skip != 'true' && steps.cache-memory-analysis.outputs.cache-hit != 'true'
|
if: steps.check-script.outputs.skip != 'true' && steps.check-tests.outputs.skip != 'true' && steps.cache-memory-analysis.outputs.cache-hit != 'true'
|
||||||
id: build
|
id: build
|
||||||
run: |
|
run: |
|
||||||
. venv/bin/activate
|
. venv/bin/activate
|
||||||
@@ -800,7 +829,7 @@ jobs:
|
|||||||
--platform "$platform"
|
--platform "$platform"
|
||||||
|
|
||||||
- name: Save memory analysis to cache
|
- name: Save memory analysis to cache
|
||||||
if: steps.check-script.outputs.skip != 'true' && steps.cache-memory-analysis.outputs.cache-hit != 'true' && steps.build.outcome == 'success'
|
if: steps.check-script.outputs.skip != 'true' && steps.check-tests.outputs.skip != 'true' && steps.cache-memory-analysis.outputs.cache-hit != 'true' && steps.build.outcome == 'success'
|
||||||
uses: actions/cache/save@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
|
uses: actions/cache/save@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
|
||||||
with:
|
with:
|
||||||
path: memory-analysis-target.json
|
path: memory-analysis-target.json
|
||||||
@@ -808,7 +837,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Extract memory usage for outputs
|
- name: Extract memory usage for outputs
|
||||||
id: extract
|
id: extract
|
||||||
if: steps.check-script.outputs.skip != 'true'
|
if: steps.check-script.outputs.skip != 'true' && steps.check-tests.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)
|
||||||
|
|||||||
Reference in New Issue
Block a user