|
1 |
| -name: Wokwi tests |
| 1 | +name: Hardware and Wokwi tests |
2 | 2 |
|
3 | 3 | on:
|
4 | 4 | workflow_run:
|
@@ -188,6 +188,179 @@ jobs:
|
188 | 188 | })).data;
|
189 | 189 | core.info(`${name} is ${state}`);
|
190 | 190 |
|
| 191 | + hardware-test: |
| 192 | + name: Hardware ${{ matrix.chip }} ${{ matrix.type }} tests |
| 193 | + if: | |
| 194 | + github.event.workflow_run.conclusion == 'success' || |
| 195 | + github.event.workflow_run.conclusion == 'failure' || |
| 196 | + github.event.workflow_run.conclusion == 'timed_out' |
| 197 | + runs-on: ubuntu-latest |
| 198 | + needs: get-artifacts |
| 199 | + env: |
| 200 | + id: ${{ needs.get-artifacts.outputs.ref }}-${{ github.event.workflow_run.head_sha || github.sha }}-${{ matrix.chip }}-${{ matrix.type }} |
| 201 | + permissions: |
| 202 | + actions: read |
| 203 | + statuses: write |
| 204 | + strategy: |
| 205 | + fail-fast: false |
| 206 | + matrix: |
| 207 | + type: ${{ fromJson(needs.get-artifacts.outputs.types) }} |
| 208 | + chip: ${{ fromJson(needs.get-artifacts.outputs.targets) }} |
| 209 | + steps: |
| 210 | + - name: Report pending |
| 211 | + uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 |
| 212 | + with: |
| 213 | + script: | |
| 214 | + const owner = '${{ github.repository_owner }}'; |
| 215 | + const repo = '${{ github.repository }}'.split('/')[1]; |
| 216 | + const sha = '${{ github.event.workflow_run.head_sha }}'; |
| 217 | + core.debug(`owner: ${owner}`); |
| 218 | + core.debug(`repo: ${repo}`); |
| 219 | + core.debug(`sha: ${sha}`); |
| 220 | + const { context: name, state } = (await github.rest.repos.createCommitStatus({ |
| 221 | + context: 'Runtime Tests / Hardware (${{ matrix.type }}, ${{ matrix.chip }}) / Hardware ${{ matrix.chip }} ${{ matrix.type }} tests (${{ github.event.workflow_run.event }} -> workflow_run)', |
| 222 | + owner: owner, |
| 223 | + repo: repo, |
| 224 | + sha: sha, |
| 225 | + state: 'pending', |
| 226 | + target_url: 'https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}' |
| 227 | + })).data; |
| 228 | + core.info(`${name} is ${state}`); |
| 229 | +
|
| 230 | + - name: Check if already passed |
| 231 | + id: get-cache-results |
| 232 | + if: needs.get-artifacts.outputs.pr_num |
| 233 | + uses: actions/cache/restore@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 |
| 234 | + with: |
| 235 | + key: test-${{ env.id }}-results-hw |
| 236 | + path: | |
| 237 | + tests/**/*.xml |
| 238 | + tests/**/result_*.json |
| 239 | +
|
| 240 | + - name: Evaluate if tests should be run |
| 241 | + id: check-tests |
| 242 | + run: | |
| 243 | + cache_exists=${{ steps.get-cache-results.outputs.cache-hit == 'true' }} |
| 244 | + enabled=true |
| 245 | +
|
| 246 | + if [[ $cache_exists == 'true' ]]; then |
| 247 | + echo "Already ran, skipping GitLab pipeline trigger" |
| 248 | + enabled=false |
| 249 | + else |
| 250 | + echo "Cache miss, will trigger GitLab pipeline for hardware tests" |
| 251 | + fi |
| 252 | +
|
| 253 | + echo "enabled=$enabled" >> $GITHUB_OUTPUT |
| 254 | +
|
| 255 | + - name: Checkout repository |
| 256 | + if: ${{ steps.check-tests.outputs.enabled == 'true' }} |
| 257 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 258 | + with: |
| 259 | + ref: ${{ needs.get-artifacts.outputs.base || github.ref }} |
| 260 | + |
| 261 | + - name: Get test binaries |
| 262 | + if: ${{ steps.check-tests.outputs.enabled == 'true' }} |
| 263 | + uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4.2.1 |
| 264 | + with: |
| 265 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 266 | + run-id: ${{ github.event.workflow_run.id }} |
| 267 | + name: test-bin-${{ matrix.chip }}-${{ matrix.type }} |
| 268 | + path: test-binaries |
| 269 | + |
| 270 | + - name: Trigger GitLab Pipeline and Download Artifacts |
| 271 | + if: ${{ steps.check-tests.outputs.enabled == 'true' }} |
| 272 | + uses: digital-blueprint/[email protected] |
| 273 | + id: gitlab-trigger |
| 274 | + with: |
| 275 | + host: ${{ secrets.GITLAB_URL }} |
| 276 | + id: ${{ secrets.GITLAB_PROJECT_ID }} |
| 277 | + ref: 'ci/hw_gitlab' |
| 278 | + #ref: 'master' |
| 279 | + trigger_token: ${{ secrets.GITLAB_TRIGGER_TOKEN }} |
| 280 | + access_token: ${{ secrets.GITLAB_ACCESS_TOKEN }} |
| 281 | + download_artifacts: 'true' |
| 282 | + download_artifacts_on_failure: 'true' |
| 283 | + download_path: './gitlab-artifacts' |
| 284 | + variables: | |
| 285 | + '{ |
| 286 | + "TEST_TYPE":"${{ matrix.type }}", |
| 287 | + "TEST_CHIP":"${{ matrix.chip }}", |
| 288 | + "PIPELINE_ID":"${{ env.id }}", |
| 289 | + "BINARIES_RUN_ID":"${{ github.event.workflow_run.id }}", |
| 290 | + "GITHUB_REPOSITORY":"${{ github.repository }}" |
| 291 | + }' |
| 292 | +
|
| 293 | + - name: Process Downloaded Artifacts |
| 294 | + if: ${{ steps.check-tests.outputs.enabled == 'true' }} |
| 295 | + run: | |
| 296 | + echo "GitLab Pipeline Status: ${{ steps.gitlab-trigger.outputs.status }}" |
| 297 | + echo "Artifacts Downloaded: ${{ steps.gitlab-trigger.outputs.artifacts_downloaded }}" |
| 298 | +
|
| 299 | + # Create tests directory structure expected by GitHub caching |
| 300 | + mkdir -p tests |
| 301 | +
|
| 302 | + # Process downloaded GitLab artifacts |
| 303 | + if [ "${{ steps.gitlab-trigger.outputs.artifacts_downloaded }}" = "true" ]; then |
| 304 | + echo "Processing downloaded GitLab artifacts..." |
| 305 | +
|
| 306 | + # The action downloads artifacts organized by job: |
| 307 | + # gitlab-artifacts/job_123_job_name_1/artifacts/... |
| 308 | + # gitlab-artifacts/job_124_job_name_2/artifacts/... |
| 309 | +
|
| 310 | + # Print the contents of the gitlab-artifacts directory to debug |
| 311 | + echo "Contents of gitlab-artifacts directory:" |
| 312 | + ls -la ./gitlab-artifacts/ |
| 313 | +
|
| 314 | + # Find and copy test result files |
| 315 | + find ./gitlab-artifacts -name "*.xml" -exec cp {} tests/ \; |
| 316 | + find ./gitlab-artifacts -name "result_*.json" -exec cp {} tests/ \; |
| 317 | +
|
| 318 | + echo "Test results found:" |
| 319 | + ls -la tests/ || echo "No test results found" |
| 320 | + else |
| 321 | + echo "No artifacts were downloaded from GitLab" |
| 322 | + fi |
| 323 | +
|
| 324 | + - name: Upload ${{ matrix.chip }} ${{ matrix.type }} hardware results as cache |
| 325 | + uses: actions/cache/save@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 |
| 326 | + if: steps.check-tests.outputs.enabled == 'true' && needs.get-artifacts.outputs.pr_num |
| 327 | + with: |
| 328 | + key: test-${{ env.id }}-results-hw |
| 329 | + path: | |
| 330 | + tests/**/*.xml |
| 331 | + tests/**/result_*.json |
| 332 | +
|
| 333 | + - name: Upload ${{ matrix.chip }} ${{ matrix.type }} hardware results as artifacts |
| 334 | + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 |
| 335 | + if: always() |
| 336 | + with: |
| 337 | + name: test-results-hw-${{ matrix.chip }}-${{ matrix.type }} |
| 338 | + overwrite: true |
| 339 | + path: | |
| 340 | + tests/**/*.xml |
| 341 | + tests/**/result_*.json |
| 342 | +
|
| 343 | + - name: Report conclusion |
| 344 | + uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 |
| 345 | + if: always() |
| 346 | + with: |
| 347 | + script: | |
| 348 | + const owner = '${{ github.repository_owner }}'; |
| 349 | + const repo = '${{ github.repository }}'.split('/')[1]; |
| 350 | + const sha = '${{ github.event.workflow_run.head_sha }}'; |
| 351 | + core.debug(`owner: ${owner}`); |
| 352 | + core.debug(`repo: ${repo}`); |
| 353 | + core.debug(`sha: ${sha}`); |
| 354 | + const { context: name, state } = (await github.rest.repos.createCommitStatus({ |
| 355 | + context: 'Runtime Tests / Hardware (${{ matrix.type }}, ${{ matrix.chip }}) / Hardware ${{ matrix.chip }} ${{ matrix.type }} tests (${{ github.event.workflow_run.event }} -> workflow_run)', |
| 356 | + owner: owner, |
| 357 | + repo: repo, |
| 358 | + sha: sha, |
| 359 | + state: '${{ job.status }}', |
| 360 | + target_url: 'https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}' |
| 361 | + })).data; |
| 362 | + core.info(`${name} is ${state}`); |
| 363 | +
|
191 | 364 | wokwi-test:
|
192 | 365 | name: Wokwi ${{ matrix.chip }} ${{ matrix.type }} tests
|
193 | 366 | if: |
|
|
0 commit comments