|
24 | 24 | - unlabeled |
25 | 25 |
|
26 | 26 | jobs: |
27 | | - # Run pre-commit |
| 27 | + shellcheck: |
| 28 | + name: Shellcheck |
| 29 | + runs-on: ubuntu-latest |
| 30 | + steps: |
| 31 | + - uses: actions/checkout@v4.2.2 |
| 32 | + - name: Run ShellCheck |
| 33 | + uses: ludeeus/action-shellcheck@master |
| 34 | + |
28 | 35 | pre-commit: |
29 | 36 | name: Validate pre-commit requirements |
30 | 37 | runs-on: ubuntu-latest |
|
74 | 81 | name: Setup for HA-core (release/master) |
75 | 82 | needs: |
76 | 83 | - pre-commit |
| 84 | + outputs: |
| 85 | + release_failed: ${{ steps.ha_core_tests.outputs.failed }} |
77 | 86 | steps: |
78 | 87 | - name: Check out committed code |
79 | 88 | uses: actions/checkout@v4.2.2 |
@@ -108,15 +117,25 @@ jobs: |
108 | 117 | ${{ env.CACHE_VERSION}}-${{ runner.os }} |
109 | 118 | ${{ env.CACHE_VERSION}} |
110 | 119 | - name: Test through HA-core (master/release) - continue-on-error = ${{ env.STRICT_DEV == 'true' }} |
| 120 | + id: ha-core-tests |
111 | 121 | continue-on-error: ${{ env.STRICT_DEV == 'true' }} # Allow master failures only if dev is strict |
112 | 122 | run: | |
113 | 123 | GITHUB_ACTIONS="" scripts/core-testing.sh |
| 124 | + if [ $? -ne 0 ]; then |
| 125 | + echo "::warning::Release HA core incompatibility" |
| 126 | + echo "RELEASE_TESTS_FAILED=true" >> $GITHUB_ENV |
| 127 | + else |
| 128 | + echo "Successfully tested against released HA-core" |
| 129 | + echo "RELEASE_TESTS_FAILED=false" >> $GITHUB_ENV |
| 130 | + fi |
114 | 131 |
|
115 | 132 | ha-core-dev: |
116 | 133 | runs-on: ubuntu-latest |
117 | 134 | name: Setup for HA-core (dev) |
118 | 135 | needs: |
119 | 136 | - pre-commit |
| 137 | + outputs: |
| 138 | + dev_failed: ${{ steps.ha_core_tests.outputs.failed }} |
120 | 139 | steps: |
121 | 140 | - name: Check out committed code |
122 | 141 | uses: actions/checkout@v4.2.2 |
@@ -151,14 +170,80 @@ jobs: |
151 | 170 | ${{ env.CACHE_VERSION}}-${{ runner.os }} |
152 | 171 | ${{ env.CACHE_VERSION}} |
153 | 172 | - name: Test through HA-core (dev) - continue-on-error = ${{ env.STRICT_DEV == 'false' }} |
| 173 | + id: ha-core-tests |
154 | 174 | continue-on-error: ${{ env.STRICT_DEV == 'false' }} # Allow dev failures unless strict |
155 | 175 | run: | |
156 | 176 | GITHUB_ACTIONS="" BRANCH="dev" scripts/core-testing.sh |
| 177 | + if [ $? -ne 0 ]; then |
| 178 | + echo "::warning::Development HA core incompatibility" |
| 179 | + echo "DEV_TESTS_FAILED=true" >> $GITHUB_ENV |
| 180 | + else |
| 181 | + echo "Successfully tested against dev HA-core" |
| 182 | + echo "DEV_TESTS_FAILED=false" >> $GITHUB_ENV |
| 183 | + fi |
157 | 184 |
|
158 | | - shellcheck: |
159 | | - name: Shellcheck |
| 185 | + final-comment: |
160 | 186 | runs-on: ubuntu-latest |
| 187 | + needs: [ha-core-release, ha-core-dev] |
161 | 188 | steps: |
162 | | - - uses: actions/checkout@v4.2.2 |
163 | | - - name: Run ShellCheck |
164 | | - uses: ludeeus/action-shellcheck@master |
| 189 | + - name: Determine Branch Test Mode |
| 190 | + id: determine_mode |
| 191 | + run: | |
| 192 | + if [[ "${{ contains(github.event.pull_request.labels.*.name, 'require-dev-pass') }}" == "true" ]]; then |
| 193 | + echo "STRICT_DEV=true" >> $GITHUB_ENV |
| 194 | + else |
| 195 | + echo "STRICT_DEV=false" >> $GITHUB_ENV |
| 196 | + fi |
| 197 | + - name: Create combined comment |
| 198 | + run: | |
| 199 | + # Get the results of the previous scripts |
| 200 | + STRICT_DEV=$STRICT_DEV |
| 201 | + DEV_TESTS_FAILED=$DEV_TESTS_FAILED |
| 202 | + RELEASE_TESTS_FAILED=$RELEASE_TESTS_FAILED |
| 203 | + FAIL_COUNT=0 |
| 204 | +
|
| 205 | + COMMENT_BODY="**Error while testing for RELEASED HA-core:**\n" |
| 206 | + if [[ $DEV_TESTS_FAILED == "true" ]]; then |
| 207 | + COMMENT_BODY="**Error while testing for Development HA-core:**\n" |
| 208 | + fi |
| 209 | +
|
| 210 | + if [[ $DEV_TESTS_FAILED == "true" ]]; then |
| 211 | + if [[ $STRICT_DEV == "true" ]]; then |
| 212 | + COMMENT_BODY+="**Error:** Incompatible while testing against dev HA-core and required to pass.\n" |
| 213 | + FAIL_COUNT=2 |
| 214 | + else |
| 215 | + COMMENT_BODY+="**Warning:** Incompatible while testing against dev HA-core.\n" |
| 216 | + FAIL_COUNT=1 |
| 217 | + fi |
| 218 | + else |
| 219 | + COMMENT_BODY+="**Success:** No problem with testing against dev HA-core.\n" |
| 220 | + fi |
| 221 | +
|
| 222 | + if [[ $RELEASE_TESTS_FAILED == "true" ]]; then |
| 223 | + if [[ $STRICT_DEV == "false" ]]; then |
| 224 | + COMMENT_BODY+="**Error:** Incompatible while testing against released HA-core and required to pass.\n" |
| 225 | + FAIL_COUNT=2 |
| 226 | + else |
| 227 | + COMMENT_BODY+="**Warning:** Incompatible while testing against released HA-core.\n" |
| 228 | + FAIL_COUNT=1 |
| 229 | + fi |
| 230 | + else |
| 231 | + COMMENT_BODY+="**Success:** No problem with testing against released HA-core.\n" |
| 232 | + fi |
| 233 | +
|
| 234 | + if [[ FAIL_COUNT == 1 ]]; then |
| 235 | + # Create a comment on the pull request |
| 236 | + curl -s -X POST \ |
| 237 | + -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ |
| 238 | + -H "Content-Type: application/json" \ |
| 239 | + --data "{\"body\": \"$COMMENT_BODY\"}" \ |
| 240 | + "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments" |
| 241 | + fi |
| 242 | + if [[ FAIL_COUNT == 2 ]]; then |
| 243 | + # Request changes on the pull request |
| 244 | + curl -s -X POST \ |
| 245 | + -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ |
| 246 | + -H "Content-Type: application/json" \ |
| 247 | + --data ""{\"event\": \"REQUEST_ACTIONS\", \"body\": \"$COMMENT_BODY\"}" \ |
| 248 | + "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments" |
| 249 | + fi |
0 commit comments