|
| 1 | +name: PR KT-Kernel Test |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + - develop |
| 8 | + types: [synchronize, labeled] |
| 9 | + workflow_dispatch: |
| 10 | + |
| 11 | +concurrency: |
| 12 | + group: pr-kt-kernel-test-${{ github.ref }} |
| 13 | + cancel-in-progress: true |
| 14 | + |
| 15 | +jobs: |
| 16 | + # =============================================== check changes ==================================================== |
| 17 | + check-changes: |
| 18 | + runs-on: ubuntu-latest |
| 19 | + outputs: |
| 20 | + kt_kernel: ${{ steps.filter.outputs.kt_kernel }} |
| 21 | + steps: |
| 22 | + - name: Checkout code |
| 23 | + uses: actions/checkout@v4 |
| 24 | + |
| 25 | + - name: Fail if the PR does not have the 'run-ci' label |
| 26 | + if: github.event_name == 'pull_request' && !contains(github.event.pull_request.labels.*.name, 'run-ci') |
| 27 | + run: | |
| 28 | + echo "This pull request does not have the 'run-ci' label. Failing the workflow." |
| 29 | + exit 1 |
| 30 | +
|
| 31 | + - name: Fail if the PR is a draft |
| 32 | + if: github.event_name == 'pull_request' && github.event.pull_request.draft == true |
| 33 | + run: | |
| 34 | + echo "This pull request is a draft. Failing the workflow." |
| 35 | + exit 1 |
| 36 | +
|
| 37 | + - name: Detect file changes |
| 38 | + id: filter |
| 39 | + uses: dorny/paths-filter@v3 |
| 40 | + with: |
| 41 | + filters: | |
| 42 | + kt_kernel: |
| 43 | + - "kt-kernel/**" |
| 44 | + - ".github/workflows/kt-kernel-tests.yml" |
| 45 | +
|
| 46 | + # =============================================== KT-Kernel tests ==================================================== |
| 47 | + per-commit-kt-kernel-cpu: |
| 48 | + needs: [check-changes] |
| 49 | + if: always() && !failure() && !cancelled() && |
| 50 | + (needs.check-changes.outputs.kt_kernel == 'true' || github.event_name == 'workflow_dispatch') |
| 51 | + runs-on: kt-cpu |
| 52 | + continue-on-error: false |
| 53 | + steps: |
| 54 | + - name: Cleanup |
| 55 | + run: | |
| 56 | + sudo rm -rf $GITHUB_WORKSPACE/* || true |
| 57 | +
|
| 58 | + - name: Checkout code |
| 59 | + uses: actions/checkout@v4 |
| 60 | + with: |
| 61 | + submodules: recursive |
| 62 | + |
| 63 | + - name: Install KT-Kernel |
| 64 | + run: | |
| 65 | + cd kt-kernel |
| 66 | + bash install.sh build |
| 67 | +
|
| 68 | + - name: Run KT-Kernel CPU tests |
| 69 | + timeout-minutes: 30 |
| 70 | + run: | |
| 71 | + cd kt-kernel/test |
| 72 | + python3 run_suite.py --hw cpu --suite default |
| 73 | +
|
| 74 | + # =============================================== finish ==================================================== |
| 75 | + pr-test-kt-kernel-finish: |
| 76 | + needs: [check-changes, per-commit-kt-kernel-cpu] |
| 77 | + if: always() |
| 78 | + runs-on: ubuntu-latest |
| 79 | + steps: |
| 80 | + - name: Check all dependent job statuses |
| 81 | + run: | |
| 82 | + # Convert the 'needs' context to a JSON string |
| 83 | + json_needs='${{ toJson(needs) }}' |
| 84 | +
|
| 85 | + # Get a list of all job names from the JSON keys |
| 86 | + job_names=$(echo "$json_needs" | jq -r 'keys_unsorted[]') |
| 87 | +
|
| 88 | + for job in $job_names; do |
| 89 | + # For each job, extract its result |
| 90 | + result=$(echo "$json_needs" | jq -r --arg j "$job" '.[$j].result') |
| 91 | +
|
| 92 | + # Print the job name and its result |
| 93 | + echo "$job: $result" |
| 94 | +
|
| 95 | + # Check for failure or cancellation and exit if found |
| 96 | + if [[ "$result" == "failure" || "$result" == "cancelled" ]]; then |
| 97 | + echo "The above jobs failed." |
| 98 | + exit 1 |
| 99 | + fi |
| 100 | + done |
| 101 | +
|
| 102 | + # If the loop completes, all jobs were successful |
| 103 | + echo "All jobs completed successfully" |
| 104 | + exit 0 |
0 commit comments