name: Test component on: workflow_call: inputs: artifact_run_id: type: string default: "" therock_ref: type: string required: true amdgpu_families: type: string test_runs_on: type: string platform: type: string component: type: string permissions: contents: read jobs: test_component: name: 'Test ${{ fromJSON(inputs.component).job_name }} (shard ${{ matrix.shard }} of ${{ fromJSON(inputs.component).total_shards }})' runs-on: ${{ inputs.test_runs_on }} timeout-minutes: 210 container: image: ${{ inputs.platform == 'linux' && 'ghcr.io/rocm/no_rocm_image_ubuntu24_04@sha256:4150afe4759d14822f0e3f8930e1124f26e11f68b5c7b91ec9a02b20b1ebbb98' || null }} options: --ipc host --group-add video --device /dev/kfd --device /dev/dri --group-add 993 --group-add 992 --group-add 110 --env-file /etc/podinfo/gha-gpu-isolation-settings -e ROCR_VISIBLE_DEVICES -e KUBE_CPU_REQUEST strategy: fail-fast: false matrix: # The shard array is based on "total_shards" from "fetch_test_configurations.py" # The test executable will shard based on the array. (ex: [1, 2, 3, 4] = four test shards) shard: ${{ fromJSON(inputs.component).shard_arr }} defaults: run: shell: bash env: VENV_DIR: ${{ github.workspace }}/.venv ARTIFACT_RUN_ID: "${{ inputs.artifact_run_id != '' && inputs.artifact_run_id || github.run_id }}" OUTPUT_ARTIFACTS_DIR: "./build" THEROCK_BIN_DIR: "./build/bin" AMDGPU_FAMILIES: ${{ inputs.amdgpu_families }} ARTIFACT_GROUP: ${{ inputs.amdgpu_families }} TEST_COMPONENT: ${{ fromJSON(inputs.component).job_name }} steps: - name: "Fetch 'build_tools' from repository" uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: repository: "ROCm/TheRock" sparse-checkout: build_tools path: "prejob" - name: Pre-job cleanup processes on Windows if: ${{ runner.os == 'Windows' }} timeout-minutes: 5 shell: powershell run: . '${{ github.workspace }}\prejob\build_tools\github_actions\cleanup_processes.ps1' - name: Pre-job cleanup GPU processes on Linux if: ${{ runner.os == 'Linux' }} timeout-minutes: 5 run: bash ./prejob/build_tools/github_actions/cleanup_processes.sh - name: Checkout Repository uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: repository: "ROCm/TheRock" ref: ${{ inputs.therock_ref }} - name: Configure git for long paths on Windows if: ${{ runner.os == 'Windows' }} run: git config --global core.longpaths true - name: Checkout rocm-libraries repository for scripts uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: path: rocm-libraries - name: Run setup test environment workflow timeout-minutes: 15 uses: './.github/actions/setup_test_environment' with: ARTIFACT_RUN_ID: ${{ env.ARTIFACT_RUN_ID }} ARTIFACT_GROUP: ${{ inputs.amdgpu_families }} OUTPUT_ARTIFACTS_DIR: ${{ env.OUTPUT_ARTIFACTS_DIR }} VENV_DIR: ${{ env.VENV_DIR }} FETCH_ARTIFACT_ARGS: ${{ fromJSON(inputs.component).fetch_artifact_args }} IS_PR_FROM_FORK: ${{ github.event.pull_request.head.repo.fork }} - name: Driver / GPU sanity check timeout-minutes: 3 run: | python ./build_tools/print_driver_gpu_info.py # Set thread limits from KUBE_CPU_REQUEST (Kubernetes-injected) to avoid oversubscription. # Must be done at runtime since container env vars aren't in GitHub's env context. - name: Set thread limits run: | if [[ -n "${KUBE_CPU_REQUEST:-}" ]]; then CPU_COUNT="${KUBE_CPU_REQUEST%.*}" echo "OPENBLAS_NUM_THREADS=${CPU_COUNT}" >> $GITHUB_ENV echo "OMP_NUM_THREADS=${CPU_COUNT}" >> $GITHUB_ENV echo "Thread limits set: OPENBLAS_NUM_THREADS=${CPU_COUNT}, OMP_NUM_THREADS=${CPU_COUNT} (from KUBE_CPU_REQUEST=${KUBE_CPU_REQUEST})" else echo "KUBE_CPU_REQUEST not set, thread limits not configured" fi - name: Test timeout-minutes: ${{ fromJSON(inputs.component).timeout_minutes }} env: SHARD_INDEX: ${{ matrix.shard }} TOTAL_SHARDS: ${{ fromJSON(inputs.component).total_shards }} TEST_TYPE: ${{ fromJSON(inputs.component).test_type }} run: | # Create logs directory mkdir -p ./test_logs # Run test and capture output (still display to console) python ./build_tools/memory_monitor.py --phase "Test ${{ fromJSON(inputs.component).job_name }}" -- \ bash -c '${{ fromJSON(inputs.component).test_script }}' 2>&1 | tee ./test_logs/test_output.log - name: Notify Teams Channel on Failure if: ${{ failure() && !github.event.pull_request.head.repo.fork }} env: PR_NUMBER: ${{ github.event.pull_request.number }} PR_TITLE: ${{ github.event.pull_request.title }} MIOPEN_WEBHOOK_URL: ${{ secrets.MIOPEN_CI_WEBHOOK_URL }} HIPDNN_WEBHOOK_URL: ${{ secrets.HIPDNN_CI_WEBHOOK_URL }} COMPONENT_NAME: ${{ fromJSON(inputs.component).job_name }} JOB_NAME: "${{ fromJSON(inputs.component).job_name }} (shard ${{ matrix.shard }}/${{ fromJSON(inputs.component).total_shards }})" run: | python3 rocm-libraries/.github/scripts/notify_teams.py \ --failure-stage test \ --log-path ./test_logs/test_output.log \ --webhook-urls "{\"miopen\":\"${MIOPEN_WEBHOOK_URL}\",\"hipdnn\":\"${HIPDNN_WEBHOOK_URL}\"}" \ --pr-number "${PR_NUMBER}" \ --pr-title "${PR_TITLE}" \ --component-name "${COMPONENT_NAME}" \ --job-name "${JOB_NAME}" # GitHub's 'Complete job' step is unaware of launched executables # and will fail to clean up orphan processes. - name: Post-job cleanup processes on Windows if: ${{ always() && runner.os == 'Windows' }} timeout-minutes: 5 shell: powershell run: . '${{ github.workspace }}\build_tools\github_actions\cleanup_processes.ps1' - name: Post-job cleanup GPU processes on Linux if: ${{ always() && runner.os == 'Linux' }} timeout-minutes: 5 run: bash ./build_tools/github_actions/cleanup_processes.sh