Skip to content

Commit d84beef

Browse files
authored
CI: Add job for pip check (home-assistant#64058)
1 parent a650340 commit d84beef

File tree

3 files changed

+66
-0
lines changed

3 files changed

+66
-0
lines changed

.core_files.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,12 @@ other: &other
119119
- .github/workflows/*
120120
- homeassistant/scripts/**
121121

122+
requirements:
123+
- .github/workflows/*
124+
- homeassistant/package_constraints.txt
125+
- requirements*.txt
126+
- setup.py
127+
122128
any:
123129
- *base_platforms
124130
- *components

.github/workflows/ci.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ jobs:
3636
tests_glob: ${{ steps.info.outputs.tests_glob }}
3737
test_groups: ${{ steps.info.outputs.test_groups }}
3838
test_group_count: ${{ steps.info.outputs.test_group_count }}
39+
requirements: ${{ steps.core.outputs.requirements }}
3940
runs-on: ubuntu-latest
4041
steps:
4142
- name: Check out code from GitHub
@@ -671,6 +672,38 @@ jobs:
671672
python --version
672673
mypy homeassistant/components/${{ needs.changes.outputs.integrations_glob }}
673674
675+
pip-check:
676+
runs-on: ubuntu-latest
677+
if: needs.changes.outputs.requirements == 'true'
678+
needs:
679+
- changes
680+
- prepare-tests
681+
strategy:
682+
fail-fast: false
683+
matrix:
684+
python-version: [3.9]
685+
name: Run pip check ${{ matrix.python-version }}
686+
container: homeassistant/ci-azure:${{ matrix.python-version }}
687+
steps:
688+
- name: Check out code from GitHub
689+
uses: actions/[email protected]
690+
- name: Restore full Python ${{ matrix.python-version }} virtual environment
691+
id: cache-venv
692+
uses: actions/[email protected]
693+
with:
694+
path: venv
695+
key: ${{ runner.os }}-${{ matrix.python-version }}-${{
696+
needs.prepare-tests.outputs.python-key }}
697+
- name: Fail job if Python cache restore failed
698+
if: steps.cache-venv.outputs.cache-hit != 'true'
699+
run: |
700+
echo "Failed to restore Python virtual environment from cache"
701+
exit 1
702+
- name: Run pip check
703+
run: |
704+
. venv/bin/activate
705+
./script/pip_check $PIP_CACHE
706+
674707
pytest:
675708
runs-on: ubuntu-latest
676709
if: needs.changes.outputs.test_full_suite == 'true' || needs.changes.outputs.tests_glob

script/pip_check

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/bash
2+
PIP_CACHE=$1
3+
4+
# Number of existing dependency conflicts
5+
# Update if a PR resolve one!
6+
DEPENDENCY_CONFLICTS=14
7+
8+
PIP_CHECK=$(pip check --cache-dir=$PIP_CACHE)
9+
LINE_COUNT=$(echo "$PIP_CHECK" | wc -l)
10+
echo "$PIP_CHECK"
11+
12+
if [[ $((LINE_COUNT)) -gt $DEPENDENCY_CONFLICTS ]]
13+
then
14+
echo "------"
15+
echo "Requirements change added another dependency conflict."
16+
echo "Make sure to check the 'pip check' output above!"
17+
exit 1
18+
elif [[ $((LINE_COUNT)) -lt $DEPENDENCY_CONFLICTS ]]
19+
then
20+
echo "------"
21+
echo "It seems like this PR resolves $((
22+
DEPENDENCY_CONFLICTS - LINE_COUNT)) dependency conflicts."
23+
echo "Please update the 'DEPENDENCY_CONFLICTS' constant "
24+
echo "in 'script/pip_check' to help prevent regressions."
25+
echo "Update it to: $((LINE_COUNT))"
26+
exit 1
27+
fi

0 commit comments

Comments
 (0)