11name : " Unittests Plugins"
2- # on: [workflow_dispatch, push]
32on :
43 workflow_dispatch :
54 push :
1110 - ' develop'
1211jobs :
1312 build :
14- runs-on : ubuntu-24.04 # latest
13+ runs-on : ubuntu-24.04
1514 strategy :
1615 fail-fast : false
1716 matrix :
18- python-version : [ '3.10', '3.11', '3.12', '3.13' ]
17+ python-version : ['3.10', '3.11', '3.12', '3.13', '3.14' ]
1918 name : Python ${{ matrix.python-version }}
2019 steps :
2120 - name : Setup OS (Ubuntu)
@@ -26,61 +25,80 @@ jobs:
2625 sudo apt-get install gcc --only-upgrade
2726 sudo apt-get install libglib2.0
2827
28+ # For push events github.ref_name is the branch name.
29+ # For PR events github.head_ref is the source branch name.
30+ # The previous GITHUB_REF strip produced 'refs/pull/N/merge' for PRs.
2931 - name : Get branch name
30- run : echo "branch=$(echo ${GITHUB_REF#refs/heads/})" >>$GITHUB_OUTPUT
3132 id : extract_branch
33+ run : |
34+ if [[ "${{ github.event_name }}" == "pull_request" ]]; then
35+ echo "branch=${{ github.head_ref }}" >>$GITHUB_OUTPUT
36+ else
37+ echo "branch=${{ github.ref_name }}" >>$GITHUB_OUTPUT
38+ fi
3239
3340 - name : Workflow Information
3441 run : |
35- echo github.event_name '${{ github.event_name }}'
36- echo github.workflow '${{ github.workflow }}'
37- echo github.action_repository '${{ github.action_repository }}'
38- echo github.actor '${{ github.actor }}'
39- echo github.ref_name '${{ github.ref_name }}'
40- echo github.ref '${{ github.ref }}'
41- echo github.base_ref '${{ github.base_ref }}'
42- echo github.head_ref '${{ github.head_ref }}'
43- echo github.pull_request.base.ref '${{ github.pull_request.base.ref }}'
44- echo steps.extract_branch.outputs.branch '${{ steps.extract_branch.outputs.branch }}'
42+ echo "event: ${{ github.event_name }}"
43+ echo "actor: ${{ github.actor }}"
44+ echo "ref: ${{ github.ref_name }}"
45+ echo "branch: ${{ steps.extract_branch.outputs.branch }}"
46+ echo "base: ${{ github.base_ref }}"
47+ echo "head: ${{ github.head_ref }}"
4548
4649 - name : Check if branch '${{ steps.extract_branch.outputs.branch }}' exists in smarthomeNG/smarthome
47- run : echo "code=$(git ls-remote --exit-code --heads https://github.com/smarthomeNG/smarthome ${{ steps.extract_branch.outputs.branch }} > /dev/null; echo $? )" >>$GITHUB_OUTPUT
4850 id : shng_branch_check
51+ run : echo "code=$(git ls-remote --exit-code --heads https://github.com/smarthomeNG/smarthome ${{ steps.extract_branch.outputs.branch }} > /dev/null; echo $? )" >>$GITHUB_OUTPUT
4952
50- - name : Checkout core from branch '${{ steps.extract_branch.outputs.branch }}' (for push on known smarthomeNG/smarthome branch)
53+ - name : Checkout core from branch '${{ steps.extract_branch.outputs.branch }}' (push on known smarthomeNG/smarthome branch)
5154 if : github.event_name != 'pull_request' && steps.shng_branch_check.outputs.code == '0'
52- uses : actions/checkout@v3
55+ uses : actions/checkout@v4
5356 with :
5457 repository : smarthomeNG/smarthome
5558 ref : ${{ steps.extract_branch.outputs.branch }}
5659
57- - name : Checkout core from branch 'develop' (for pull request or push on unknown smarthomeNG/smarthome branch)
60+ - name : Checkout core from branch 'develop' (pull request or push on unknown smarthomeNG/smarthome branch)
5861 if : github.event_name == 'pull_request' || steps.shng_branch_check.outputs.code == '2'
59- uses : actions/checkout@v3
62+ uses : actions/checkout@v4
6063 with :
6164 repository : smarthomeNG/smarthome
6265 ref : develop
6366
64- - name : Checkout plugins from branch '${{steps.extract_branch.outputs.branch}}'
65- uses : actions/checkout@v3
67+ # For push: check out the pushed branch of the plugins repo.
68+ # For PR: no ref specified — actions/checkout defaults to refs/pull/N/merge
69+ # (the merged result of the PR), which is what we want to test.
70+ - name : Checkout plugins (push)
71+ if : github.event_name != 'pull_request'
72+ uses : actions/checkout@v4
6673 with :
6774 repository : ${{ github.repository_owner }}/plugins
68- ref : ${{steps.extract_branch.outputs.branch}}
75+ ref : ${{ steps.extract_branch.outputs.branch }}
6976 path : plugins
7077
78+ - name : Checkout plugins (pull request — tests the merge result)
79+ if : github.event_name == 'pull_request'
80+ uses : actions/checkout@v4
81+ with :
82+ path : plugins
83+ # No ref: defaults to refs/pull/N/merge (PR code merged into develop)
84+
7185 - name : Set up Python
72- uses : actions/setup-python@v3
86+ uses : actions/setup-python@v5
7387 with :
7488 python-version : ${{ matrix.python-version }}
7589 architecture : x64
90+
7691 - run : python3 -m pip install --upgrade pip
7792
78- - name : Install setuptools (needed for Python 3.12)
93+ - name : Install setuptools
7994 run : pip install setuptools
95+
8096 - name : Install requirements for unit testing
8197 run : pip install -r tests/requirements.txt
98+
8299 - name : Build Requirements for SmartHomeNG
83100 run : python3 tools/build_requirements.py
101+
84102 - name : Install SmartHomeNG base requirements
85103 # base requirements are needed for pytest to run
86104 run : pip install -r requirements/base.txt
0 commit comments