diff --git a/projects/amdsmi/.github/workflows/abi-check.yml b/projects/amdsmi/.github/workflows/abi-check.yml deleted file mode 100644 index 07ed7ac633..0000000000 --- a/projects/amdsmi/.github/workflows/abi-check.yml +++ /dev/null @@ -1,116 +0,0 @@ -name: Major ABI Compliance Check - -on: - pull_request: - branches: - - amd-staging - - release/rocm-rel-* - paths: - - 'include/amd_smi/amdsmi.h' - push: - branches: - - amd-staging - - release/rocm-rel-* - paths: - - 'include/amd_smi/amdsmi.h' - workflow_dispatch: - -permissions: - contents: read - pull-requests: write - -jobs: - check-abi: - runs-on: lstt5 - steps: - - name: Setup Environment - run: | - sudo rm -rf $GITHUB_WORKSPACE/* || true - sudo rm -rf $GITHUB_WORKSPACE/.[!.]* || true - sudo apt-get update - sudo apt-get install -y perl build-essential git universal-ctags - git clone https://github.com/lvc/abi-compliance-checker.git - cd abi-compliance-checker - sudo make install - abi-compliance-checker --version - - - name: Checkout feature branch - uses: actions/checkout@v4 - with: - ref: ${{ github.head_ref }} - submodules: true - - - name: Copy feature branch file as new - run: | - cp include/amd_smi/amdsmi.h amdsmi_new.h - - - name: Fetch old file - run: | - # Print debug info - echo "Pull request base branch: ${{ github.base_ref }}" - echo "Pull request head branch: ${{ github.head_ref }}" - - # Fetch the appropriate base branch - if [ "${{ github.base_ref }}" = "amd-staging" ]; then - # Pull request to amd-staging: use amd-staging as old - git fetch origin amd-staging - git checkout FETCH_HEAD -- include/amd_smi/amdsmi.h - mv include/amd_smi/amdsmi.h amdsmi_old.h - fi - - - name: Run ABI Compliance Check - id: abi-check - run: | - # Create a status file with default failure - echo "abi_exit_code=1" > $GITHUB_WORKSPACE/abi_status.txt - - if [ "${{ github.base_ref }}" = "amd-staging" ]; then - echo "Comparing amd-staging (old) with ${{ github.head_ref }} (new)" - abi-compliance-checker -lib amdsmi -old amdsmi_old.h -new amdsmi_new.h -v1 amd-staging -v2 ${{ github.head_ref }} -report-path abi-report.html && echo "abi_exit_code=0" > $GITHUB_WORKSPACE/abi_status.txt - fi - continue-on-error: true - - - name: Display ABI Check Logs - if: always() - run: | - echo "Displaying ABI compliance check logs" - find logs -type f -name "*.txt" -exec cat {} \; - - - name: Label PR as ABI BREAKAGE - if: always() && github.event_name == 'pull_request' - run: | - if [ -f $GITHUB_WORKSPACE/abi_status.txt ]; then - source $GITHUB_WORKSPACE/abi_status.txt - if [ "$abi_exit_code" -ne 0 ]; then - echo "ABI check failed, adding ABI BREAKAGE label to PR #${{ github.event.pull_request.number }}" - gh pr edit ${{ github.event.pull_request.number }} --add-label "MAJOR ABI BREAKAGE" - fi - fi - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Upload ABI Report - if: always() - uses: actions/upload-artifact@v4 - with: - name: abi-report - path: abi-report.html - - - name: Fail Workflow on ABI Check Failure - if: always() - run: | - echo "Checking ABI check exit code..." - if [ -f $GITHUB_WORKSPACE/abi_status.txt ]; then - source $GITHUB_WORKSPACE/abi_status.txt - echo "ABI check exit code: $abi_exit_code" - if [ "$abi_exit_code" -ne 0 ]; then - echo "::error::⚠️ ABI BREAKAGE FOUND ⚠️ CHECK \"Run ABI Compliance Check\" LOGS OR THE abi-report ARTIFACT ATTACHED TO THIS WORKFLOW FOR MORE DETAILS" - echo "::error::View the HTML report in the Artifacts section of this workflow run for detailed ABI compatibility analysis" - exit 1 - else - echo "✅ ABI check succeeded" - fi - else - echo "ABI status file not found at $GITHUB_WORKSPACE/abi_status.txt, assuming failure" - exit 1 - fi diff --git a/projects/amdsmi/.github/workflows/abi-check2.yml b/projects/amdsmi/.github/workflows/abi-check2.yml deleted file mode 100644 index d98f82222e..0000000000 --- a/projects/amdsmi/.github/workflows/abi-check2.yml +++ /dev/null @@ -1,185 +0,0 @@ -name: Minor ABI Compliance Check - -on: - pull_request: - branches: - - amd-staging - - release/rocm-rel-* - paths: - - 'include/amd_smi/amdsmi.h' - push: - branches: - - amd-staging - - release/rocm-rel-* - paths: - - 'include/amd_smi/amdsmi.h' - workflow_dispatch: - -permissions: - contents: read - pull-requests: write - -jobs: - check-abi: - runs-on: lstt5 - steps: - - name: Setup Environment - run: | - sudo rm -rf $GITHUB_WORKSPACE/* || true - sudo rm -rf $GITHUB_WORKSPACE/.[!.]* || true - sudo apt-get update - sudo apt-get install -y perl build-essential git universal-ctags - git clone https://github.com/lvc/abi-compliance-checker.git - cd abi-compliance-checker - sudo make install - abi-compliance-checker --version - - name: Checkout feature branch - uses: actions/checkout@v4 - with: - ref: ${{ github.head_ref || github.ref_name }} - submodules: true - - - name: Copy feature branch file as new - run: | - cp include/amd_smi/amdsmi.h amdsmi_new.h - - - name: Fetch old file - run: | - # Print debug info - echo "Pull request base branch: ${{ github.base_ref }}" - echo "Pull request head branch: ${{ github.head_ref }}" - - if [ "${{ github.event_name }}" = "pull_request" ]; then - # For pull requests, use the target branch as the old file - if [ "${{ github.base_ref }}" = "amd-staging" ]; then - # Pull request to amd-staging: use amd-staging as old - git fetch origin amd-staging - git checkout FETCH_HEAD -- include/amd_smi/amdsmi.h - mv include/amd_smi/amdsmi.h amdsmi_old.h - fi - elif [ "${{ github.event_name }}" = "push" ]; then - # For pushes, determine which branch was pushed to - if [ "${{ github.ref_name }}" = "amd-staging" ]; then - # Push to amd-staging: use amd-staging as old - git fetch origin amd-staging - git checkout FETCH_HEAD -- include/amd_smi/amdsmi.h - mv include/amd_smi/amdsmi.h amdsmi_old.h - fi - fi - - - name: Run ABI Compliance Check - id: abi-check - run: | - # Create a custom descriptor with strict options - cat > strict_descriptor.xml << EOF - - - - amdsmi - - amdsmi_old.h - - - assert.h - - - - - EOF - - # Set comparison message and run the appropriate check - if [ "${{ github.event_name }}" = "pull_request" ]; then - if [ "${{ github.base_ref }}" = "amd-staging" ]; then - COMPARE_MSG="amd-staging vs ${{ github.head_ref }}" - abi-compliance-checker -l amdsmi -old amdsmi_old.h -new amdsmi_new.h -v1 amd-staging -v2 ${{ github.head_ref }} -report-path abi-report.html -strict || { EXIT_CODE=$?; echo "abi_exit_code=$EXIT_CODE" > $GITHUB_WORKSPACE/abi_status.txt; exit $EXIT_CODE; } - fi - elif [ "${{ github.event_name }}" = "push" ]; then - if [ "${{ github.ref_name }}" = "amd-staging" ]; then - COMPARE_MSG="amd-staging vs ${{ github.ref_name }}" - abi-compliance-checker -l amdsmi -old amdsmi_old.h -new amdsmi_new.h -v1 amd-staging -v2 ${{ github.ref_name }} -report-path abi-report.html -strict || { EXIT_CODE=$?; echo "abi_exit_code=$EXIT_CODE" > $GITHUB_WORKSPACE/abi_status.txt; exit $EXIT_CODE; } - fi - fi - - # If the report was generated, check for ANY changes - if [ -f abi-report.html ]; then - echo "Report generated successfully" - # Check for ANY changes in the ABI by examining specific patterns in the report - CHANGED=0 - # Check for added symbols - if grep -q "Added Symbols.*[1-9]" abi-report.html; then - echo "::error::STRICT ABI CHECK FAILED: Found added symbols comparing $COMPARE_MSG" - CHANGED=1 - fi - # Check for removed symbols - if grep -q "Removed Symbols.*[1-9]" abi-report.html; then - echo "::error::STRICT ABI CHECK FAILED: Found removed symbols comparing $COMPARE_MSG" - CHANGED=1 - fi - # Check for problems with data types - if grep -q "Problems with.*Data Types.*[1-9]" abi-report.html; then - echo "::error::STRICT ABI CHECK FAILED: Found problems with data types comparing $COMPARE_MSG" - CHANGED=1 - fi - # Check for problems with symbols - if grep -q "Problems with.*Symbols.*[1-9]" abi-report.html; then - echo "::error::STRICT ABI CHECK FAILED: Found problems with symbols comparing $COMPARE_MSG" - CHANGED=1 - fi - # Check for problems with constants - if grep -q "Problems with.*Constants.*[1-9]" abi-report.html; then - echo "::error::STRICT ABI CHECK FAILED: Found problems with constants comparing $COMPARE_MSG" - CHANGED=1 - fi - # Fail if any changes were found - if [ "$CHANGED" -eq 1 ]; then - echo "abi_exit_code=1" > $GITHUB_WORKSPACE/abi_status.txt - exit 1 - fi - fi - # If successful, write exit code 0 - echo "abi_exit_code=0" > $GITHUB_WORKSPACE/abi_status.txt - echo "ABI check wrote exit code to $GITHUB_WORKSPACE/abi_status.txt" - continue-on-error: true - - - name: Display ABI Check Logs - if: always() - run: | - echo "Displaying ABI compliance check logs for ${{ github.ref_name }}" - if [ -f logs/amdsmi/${{ github.ref_name }}/log.txt ]; then - cat logs/amdsmi/${{ github.ref_name }}/log.txt - else - echo "No ABI check log found at logs/amdsmi/${{ github.ref_name }}/log.txt" - fi - - name: Label PR as ABI BREAKAGE - if: github.event_name == 'pull_request' && steps.abi-check.outcome == 'failure' - run: | - echo "ABI check failed, adding ABI BREAKAGE label to PR #${{ github.event.pull_request.number }}" - gh pr edit ${{ github.event.pull_request.number }} --add-label "MINOR ABI BREAKAGE" - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Upload ABI Report - if: always() - uses: actions/upload-artifact@v4 - with: - name: abi-report - path: abi-report.html - - - name: Fail Workflow on ABI Check Failure - if: always() - run: | - echo "Checking ABI check exit code..." - if [ -f $GITHUB_WORKSPACE/abi_status.txt ]; then - source $GITHUB_WORKSPACE/abi_status.txt - echo "ABI check exit code: $abi_exit_code" - if [ "$abi_exit_code" -ne 0 ]; then - echo "::error::⚠️ CHANGES TO AMDSMI.H FILE FOUND ⚠️ CHECK \"Run ABI Compliance Check\" LOGS OR THE abi-report ARTIFACT ATTACHED TO THIS WORKFLOW FOR MORE DETAILS" - echo "::error::View the HTML report in the Artifacts section of this workflow run for detailed ABI compatibility analysis" - exit 1 - else - echo "✅ ABI check succeeded" - fi - else - echo "::error::ABI status file not found at $GITHUB_WORKSPACE/abi_status.txt, assuming failure" - exit 1 - fi diff --git a/projects/amdsmi/.github/workflows/abi-compliance-check.yml b/projects/amdsmi/.github/workflows/abi-compliance-check.yml new file mode 100644 index 0000000000..cb7f5c1eb1 --- /dev/null +++ b/projects/amdsmi/.github/workflows/abi-compliance-check.yml @@ -0,0 +1,316 @@ +name: ABI Compliance Check + +on: + pull_request: + branches: + - amd-staging + - release/rocm-rel-* + paths: + - 'include/amd_smi/amdsmi.h' + push: + branches: + - amd-staging + - release/rocm-rel-* + paths: + - 'include/amd_smi/amdsmi.h' + workflow_dispatch: + +permissions: + contents: read + pull-requests: write + +jobs: + major_abi_check: + name: Major ABI Compliance Check + runs-on: lstt5 + steps: + - name: Setup Environment + run: | + sudo rm -rf $GITHUB_WORKSPACE/* || true + sudo rm -rf $GITHUB_WORKSPACE/.[!.]* || true + sudo apt-get update -qq + sudo apt-get install -y -qq perl build-essential git universal-ctags + git clone https://github.com/lvc/abi-compliance-checker.git + cd abi-compliance-checker + sudo make install + abi-compliance-checker --version + + - name: Checkout current code (new version) + uses: actions/checkout@v4 + with: + fetch-depth: 0 + ref: ${{ github.event.pull_request.head.sha || github.sha }} + + - name: Fetch base branch for PR + if: github.event_name == 'pull_request' + run: | + echo "Fetching base branch: ${{ github.base_ref }}" + git fetch origin ${{ github.base_ref }}:${{ github.base_ref }} + git branch -a + + - name: Prepare amdsmi.h files for comparison + id: prepare_files + run: | + echo "Preparing amdsmi.h files..." + echo "abi_exit_code=1" > $GITHUB_WORKSPACE/major_abi_status.txt + + if [ -f include/amd_smi/amdsmi.h ]; then + cp include/amd_smi/amdsmi.h amdsmi_new.h + echo "Copied current amdsmi.h to amdsmi_new.h" + else + echo "::error::New amdsmi.h (include/amd_smi/amdsmi.h) not found in current checkout." + touch amdsmi_new.h + exit 0 + fi + + OLD_VERSION_REF="" + V1_NAME_SUFFIX="" + if [[ "${{ github.event_name }}" == "pull_request" ]]; then + OLD_VERSION_REF="${{ github.base_ref }}" + V1_NAME_SUFFIX="base_${{ github.base_ref }}" + echo "Event is Pull Request. Old version source is base branch: ${OLD_VERSION_REF}" + elif [[ "${{ github.event_name }}" == "push" ]]; then + if [[ "${{ github.event.before }}" != "0000000000000000000000000000000000000000" ]]; then + OLD_VERSION_REF="${{ github.event.before }}" + V1_NAME_SUFFIX="before_$(echo ${{ github.event.before }} | cut -c1-7)" + echo "Event is Push. Old version source is commit before push: ${OLD_VERSION_REF}" + else + echo "Push event is for a new branch or forced push. Cannot determine 'old' version." + touch amdsmi_old.h + echo "Created dummy amdsmi_old.h. Assuming no ABI breakage as no baseline." + echo "abi_exit_code=0" > $GITHUB_WORKSPACE/major_abi_status.txt + echo "skip_check=true" >> $GITHUB_OUTPUT + exit 0 + fi + else + echo "::warning::Unsupported event type: ${{ github.event_name }}. Cannot determine old version." + touch amdsmi_old.h + echo "abi_exit_code=0" > $GITHUB_WORKSPACE/major_abi_status.txt + echo "skip_check=true" >> $GITHUB_OUTPUT + exit 0 + fi + + echo "Fetching amdsmi.h from ref: $OLD_VERSION_REF (as amdsmi_old.h)" + git show $OLD_VERSION_REF:include/amd_smi/amdsmi.h > amdsmi_old.h 2>/dev/null + if [ $? -ne 0 ] || [ ! -s amdsmi_old.h ]; then + echo "::warning::Failed to fetch 'include/amd_smi/amdsmi.h' from ref '$OLD_VERSION_REF' or file is empty/missing." + echo "Proceeding with an empty amdsmi_old.h. This may result in all symbols reported as 'added'." + echo -n "" > amdsmi_old.h + if [ ! -s amdsmi_new.h ]; then + echo "abi_exit_code=0" > $GITHUB_WORKSPACE/major_abi_status.txt + fi + else + echo "Successfully fetched amdsmi.h from $OLD_VERSION_REF to amdsmi_old.h" + fi + echo "v1_name_suffix=${V1_NAME_SUFFIX}" >> $GITHUB_OUTPUT + echo "skip_check=false" >> $GITHUB_OUTPUT + + - name: Run Major ABI Compliance Check + if: steps.prepare_files.outputs.skip_check == 'false' + run: | + V1_NAME_SUFFIX_CLEAN=$(echo "${{ steps.prepare_files.outputs.v1_name_suffix }}" | tr '/' '-') + V2_NAME_CLEAN=$(echo "${{ github.ref_name || github.head_ref }}" | tr '/' '-') + + echo "Comparing $V1_NAME_SUFFIX_CLEAN (old) with $V2_NAME_CLEAN (new) for Major ABI Check" + abi-compliance-checker -lib amdsmi -old amdsmi_old.h -new amdsmi_new.h -v1 "$V1_NAME_SUFFIX_CLEAN" -v2 "$V2_NAME_CLEAN" -report-path major-abi-report.html && echo "abi_exit_code=0" > $GITHUB_WORKSPACE/major_abi_status.txt + continue-on-error: true + + - name: Display ABI Check Logs (Major) + if: always() && steps.prepare_files.outputs.skip_check == 'false' + run: | + echo "Displaying Major ABI compliance check logs (if any)" + find logs -type f -name "*.txt" -exec echo "--- {} ---" \; -exec cat {} \; || echo "No .txt logs found in logs/ directory." + + - name: Label PR on Major ABI Breakage + if: always() && github.event_name == 'pull_request' + run: | + source $GITHUB_WORKSPACE/major_abi_status.txt + if [ "$abi_exit_code" -ne 0 ]; then + echo "Major ABI check failed, adding 'MAJOR ABI BREAKAGE' label to PR #${{ github.event.pull_request.number }}" + gh pr edit ${{ github.event.pull_request.number }} --add-label "MAJOR ABI BREAKAGE" + fi + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Upload Major ABI Report + if: always() + uses: actions/upload-artifact@v4 + with: + name: major-abi-report + path: major-abi-report.html + if-no-files-found: ignore + + - name: Fail Workflow on Major ABI Check Failure + if: always() + run: | + echo "Checking Major ABI check exit code..." + source $GITHUB_WORKSPACE/major_abi_status.txt + echo "Major ABI check exit code: $abi_exit_code" + if [ "$abi_exit_code" -ne 0 ]; then + echo "::error::⚠️ MAJOR ABI BREAKAGE FOUND ⚠️ CHECK \"Run Major ABI Compliance Check\" LOGS OR THE major-abi-report ARTIFACT FOR DETAILS." + exit 1 + else + echo "✅ Major ABI check succeeded." + fi + + minor_abi_check: + name: Minor ABI Compliance Check + runs-on: lstt5 + steps: + - name: Setup Environment + run: | + sudo rm -rf $GITHUB_WORKSPACE/* || true + sudo rm -rf $GITHUB_WORKSPACE/.[!.]* || true + sudo apt-get update -qq + sudo apt-get install -y -qq perl build-essential git universal-ctags + git clone https://github.com/lvc/abi-compliance-checker.git + cd abi-compliance-checker + sudo make install + abi-compliance-checker --version + + - name: Checkout current code (new version) + uses: actions/checkout@v4 + with: + fetch-depth: 0 + ref: ${{ github.event.pull_request.head.sha || github.sha }} + + - name: Fetch base branch for PR + if: github.event_name == 'pull_request' + run: | + echo "Fetching base branch: ${{ github.base_ref }}" + git fetch origin ${{ github.base_ref }}:${{ github.base_ref }} + git branch -a + + - name: Prepare amdsmi.h files for comparison + id: prepare_files_minor + run: | + echo "Preparing amdsmi.h files for Minor check..." + echo "abi_exit_code=1" > $GITHUB_WORKSPACE/minor_abi_status.txt + + if [ -f include/amd_smi/amdsmi.h ]; then + cp include/amd_smi/amdsmi.h amdsmi_new.h + echo "Copied current amdsmi.h to amdsmi_new.h for Minor check" + else + echo "::error::New amdsmi.h (include/amd_smi/amdsmi.h) not found in current checkout for Minor check." + touch amdsmi_new.h + exit 0 + fi + + OLD_VERSION_REF_MINOR="" + V1_NAME_SUFFIX_MINOR="" + if [[ "${{ github.event_name }}" == "pull_request" ]]; then + OLD_VERSION_REF_MINOR="${{ github.base_ref }}" + V1_NAME_SUFFIX_MINOR="base_${{ github.base_ref }}" + elif [[ "${{ github.event_name }}" == "push" ]]; then + if [[ "${{ github.event.before }}" != "0000000000000000000000000000000000000000" ]]; then + OLD_VERSION_REF_MINOR="${{ github.event.before }}" + V1_NAME_SUFFIX_MINOR="before_$(echo ${{ github.event.before }} | cut -c1-7)" + else + echo "Push event is for a new branch (Minor check). Assuming no ABI changes as no baseline." + touch amdsmi_old.h + echo "abi_exit_code=0" > $GITHUB_WORKSPACE/minor_abi_status.txt + echo "skip_check_minor=true" >> $GITHUB_OUTPUT + exit 0 + fi + else + echo "::warning::Unsupported event type for Minor ABI check: ${{ github.event_name }}." + touch amdsmi_old.h + echo "abi_exit_code=0" > $GITHUB_WORKSPACE/minor_abi_status.txt + echo "skip_check_minor=true" >> $GITHUB_OUTPUT + exit 0 + fi + + echo "Fetching amdsmi.h from ref: $OLD_VERSION_REF_MINOR (as amdsmi_old.h) for Minor check" + git show $OLD_VERSION_REF_MINOR:include/amd_smi/amdsmi.h > amdsmi_old.h 2>/dev/null + if [ $? -ne 0 ] || [ ! -s amdsmi_old.h ]; then + echo "::warning::Failed to fetch 'include/amd_smi/amdsmi.h' from ref '$OLD_VERSION_REF_MINOR' or file is empty/missing for Minor check." + echo "Proceeding with an empty amdsmi_old.h for Minor check." + echo -n "" > amdsmi_old.h + if [ ! -s amdsmi_new.h ]; then + echo "abi_exit_code=0" > $GITHUB_WORKSPACE/minor_abi_status.txt + fi + else + echo "Successfully fetched amdsmi.h from $OLD_VERSION_REF_MINOR to amdsmi_old.h for Minor check" + fi + echo "v1_name_suffix_minor=${V1_NAME_SUFFIX_MINOR}" >> $GITHUB_OUTPUT + echo "skip_check_minor=false" >> $GITHUB_OUTPUT + + - name: Run Minor ABI Compliance Check (Strict) + if: steps.prepare_files_minor.outputs.skip_check_minor == 'false' + run: | + V1_NAME_SUFFIX_CLEAN=$(echo "${{ steps.prepare_files_minor.outputs.v1_name_suffix_minor }}" | tr '/' '-') + V2_NAME_CLEAN=$(echo "${{ github.ref_name || github.head_ref }}" | tr '/' '-') + COMPARE_MSG="$V1_NAME_SUFFIX_CLEAN vs $V2_NAME_CLEAN" + + echo "Comparing $COMPARE_MSG for Minor ABI Check (Strict)" + + abi-compliance-checker -lib amdsmi -old amdsmi_old.h -new amdsmi_new.h -v1 "$V1_NAME_SUFFIX_CLEAN" -v2 "$V2_NAME_CLEAN" -report-path minor-abi-report.html -strict || { + ACC_EXIT_CODE=$? + echo "abi-compliance-checker -strict failed with exit code $ACC_EXIT_CODE." + echo "abi_exit_code=$ACC_EXIT_CODE" > $GITHUB_WORKSPACE/minor_abi_status.txt + } + + current_abi_status=$(cat $GITHUB_WORKSPACE/minor_abi_status.txt) + current_exit_code=${current_abi_status#*=} + + if [ "$current_exit_code" -eq 0 ] && [ -f minor-abi-report.html ]; then + echo "ACC strict check passed. Parsing HTML report for any changes..." + CHANGED=0 + if grep -q "Added Symbols.*[1-9]" minor-abi-report.html; then CHANGED=1; echo "::warning::STRICT ABI: Found added symbols"; fi + if grep -q "Removed Symbols.*[1-9]" minor-abi-report.html; then CHANGED=1; echo "::warning::STRICT ABI: Found removed symbols"; fi + if grep -q "Problems with.*Data Types.*[1-9]" minor-abi-report.html; then CHANGED=1; echo "::warning::STRICT ABI: Found problems with data types"; fi + if grep -q "Problems with.*Symbols.*[1-9]" minor-abi-report.html; then CHANGED=1; echo "::warning::STRICT ABI: Found problems with symbols"; fi + if grep -q "Problems with.*Constants.*[1-9]" minor-abi-report.html; then CHANGED=1; echo "::warning::STRICT ABI: Found problems with constants"; fi + + if [ "$CHANGED" -eq 1 ]; then + echo "::error::STRICT ABI CHECK FAILED: Found changes in ABI report comparing $COMPARE_MSG" + echo "abi_exit_code=1" > $GITHUB_WORKSPACE/minor_abi_status.txt + else + echo "No strict ABI changes found in HTML report." + echo "abi_exit_code=0" > $GITHUB_WORKSPACE/minor_abi_status.txt + fi + elif [ ! -f minor-abi-report.html ] && [ "$current_exit_code" -eq 0 ]; then + echo "::warning::Minor ABI report (minor-abi-report.html) not found, but ACC reported success. Assuming no changes." + echo "abi_exit_code=0" > $GITHUB_WORKSPACE/minor_abi_status.txt + elif [ "$current_exit_code" -ne 0 ]; then + echo "ACC strict check already indicated failure (exit code $current_exit_code). HTML parsing for further changes skipped or confirmed failure." + fi + continue-on-error: true + + - name: Display ABI Check Logs (Minor) + if: always() && steps.prepare_files_minor.outputs.skip_check_minor == 'false' + run: | + echo "Displaying Minor ABI compliance check logs (if any)" + find logs -type f -name "*.txt" -exec echo "--- {} ---" \; -exec cat {} \; || echo "No .txt logs found in logs/ directory." + + - name: Label PR on Minor ABI Breakage + if: always() && github.event_name == 'pull_request' + run: | + source $GITHUB_WORKSPACE/minor_abi_status.txt + if [ "$abi_exit_code" -ne 0 ]; then + echo "Minor ABI check failed, adding 'MINOR ABI BREAKAGE' label to PR #${{ github.event.pull_request.number }}" + gh pr edit ${{ github.event.pull_request.number }} --add-label "MINOR ABI BREAKAGE" + fi + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Upload Minor ABI Report + if: always() + uses: actions/upload-artifact@v4 + with: + name: minor-abi-report + path: minor-abi-report.html + if-no-files-found: ignore + + - name: Fail Workflow on Minor ABI Check Failure + if: always() + run: | + echo "Checking Minor ABI check exit code..." + source $GITHUB_WORKSPACE/minor_abi_status.txt + echo "Minor ABI check exit code: $abi_exit_code" + if [ "$abi_exit_code" -ne 0 ]; then + echo "::error::⚠️ MINOR ABI CHANGES FOUND (STRICT CHECK) ⚠️ CHECK \"Run Minor ABI Compliance Check (Strict)\" LOGS OR THE minor-abi-report ARTIFACT FOR DETAILS." + exit 1 + else + echo "✅ Minor ABI check (Strict) succeeded or found no changes." + fi \ No newline at end of file diff --git a/projects/amdsmi/.github/workflows/amdsmi-build.yml b/projects/amdsmi/.github/workflows/amdsmi-build.yml index ab4e89508e..bd578b98c2 100644 --- a/projects/amdsmi/.github/workflows/amdsmi-build.yml +++ b/projects/amdsmi/.github/workflows/amdsmi-build.yml @@ -32,10 +32,6 @@ jobs: steps: - uses: actions/checkout@v4 - with: - clean: false - path: $GITHUB_WORKSPACE - fetch-depth: 0 - name: Build AMDSMI run: | @@ -43,13 +39,13 @@ jobs: echo 'Building on ${{ matrix.os }}' BUILD_FOLDER=$GITHUB_WORKSPACE/build RETRIES=3 - + for i in $(seq 1 $RETRIES); do echo "Build attempt $i for ${{ matrix.os }}..." rm -rf $BUILD_FOLDER mkdir -p $BUILD_FOLDER cd $BUILD_FOLDER - + if cmake $GITHUB_WORKSPACE -DBUILD_TESTS=ON -DENABLE_ESMI_LIB=ON && \ make -j $(nproc) && \ make package; then @@ -70,14 +66,14 @@ jobs: run: | cd $GITHUB_WORKSPACE/build apt update - + RETRIES=3 for i in $(seq 1 $RETRIES); do echo "Installation attempt $i for ${{ matrix.os }}..." if apt install -y ./amd-smi-lib*99999-local_amd64.deb; then echo "Installation successful on attempt $i" ln -s /opt/rocm/bin/amd-smi /usr/local/bin - + # Verify Installation echo 'Verifying installation:' amd-smi version @@ -125,10 +121,6 @@ jobs: steps: - uses: actions/checkout@v4 - with: - clean: false - path: $GITHUB_WORKSPACE - fetch-depth: 0 - name: Build and Install for Test run: | @@ -136,13 +128,13 @@ jobs: echo 'Building for test on ${{ matrix.os }}' BUILD_FOLDER=$GITHUB_WORKSPACE/build RETRIES=3 - + for i in $(seq 1 $RETRIES); do echo "Build attempt $i for ${{ matrix.os }} test..." rm -rf $BUILD_FOLDER mkdir -p $BUILD_FOLDER cd $BUILD_FOLDER - + if cmake $GITHUB_WORKSPACE -DBUILD_TESTS=ON -DENABLE_ESMI_LIB=ON && \ make -j $(nproc) && \ make package; then @@ -160,7 +152,7 @@ jobs: echo 'Installing for test on ${{ matrix.os }}' apt update - + for i in $(seq 1 $RETRIES); do echo "Installation attempt $i for test on ${{ matrix.os }}..." if apt install -y $BUILD_FOLDER/amd-smi-lib*99999-local_amd64.deb; then @@ -212,6 +204,13 @@ jobs: done echo "AMDSMI commands done on ${{ matrix.os }}" + - name: Upload AMDSMI Command Test Results + if: always() + uses: actions/upload-artifact@v4 + with: + name: amdsmi-command-tests-${{ matrix.os }} + path: /tmp/test-results-${{ matrix.os }} + - name: Run AMDSMI, Python, and Example Tests shell: bash run: | @@ -330,10 +329,6 @@ jobs: steps: - uses: actions/checkout@v4 - with: - clean: false - path: $GITHUB_WORKSPACE - fetch-depth: 0 - name: Set PkgMgr run: | @@ -510,10 +505,6 @@ jobs: steps: - uses: actions/checkout@v4 - with: - clean: false - path: $GITHUB_WORKSPACE - fetch-depth: 0 - name: Set PkgMgr run: | @@ -660,6 +651,14 @@ jobs: done echo "AMDSMI commands done on ${{ matrix.os }}" + - name: Upload AMDSMI Command Test Results + if: always() + uses: actions/upload-artifact@v4 + with: + name: amdsmi-command-tests-${{ matrix.os }} + path: /tmp/test-results-${{ matrix.os }} + retention-days: 30 + - name: Run AMDSMI, Python, and Example Tests shell: bash run: | @@ -755,54 +754,3 @@ jobs: run: | echo "Displaying Example NoDRM test results for ${{ matrix.os }}" cat /tmp/test-results-${{ matrix.os }}/amd_smi_nodrm_ex.log || echo "No NoDRM example test results found for ${{ matrix.os }}" - - generate-docs: - name: Generate Documentation - runs-on: - - self-hosted - - ${{ vars.RUNNER_TYPE2 }} - needs: [debian-test, rpm-test] - container: - image: ${{ vars.UBUNTU22_DOCKER_IMAGE }} - options: --privileged - steps: - - name: Checkout Repository - uses: actions/checkout@v4 - with: - clean: true - path: $GITHUB_WORKSPACE - fetch-depth: 0 - - name: Set Up Python Environment - run: | - python3 -m pip install --upgrade pip - python3 -m pip install -r $GITHUB_WORKSPACE/docs/sphinx/requirements.txt - - name: Build Documentation - working-directory: ${{ github.workspace }} - run: | - echo "Building documentation..." - cd $GITHUB_WORKSPACE - echo "Current directory: $(pwd)" - echo "Git repository verification:" - ls -la .git/ || echo "No .git directory found" - git status --porcelain || echo "Git status failed, but continuing..." - if [ ! -e "docs/.git" ]; then - ln -s ../.git docs/.git - echo "Created symbolic link to .git in docs directory" - fi - cd docs - python3 -m sphinx -T -E -b html -d _build/doctrees -D language=en . _build/html - echo "Documentation build complete." - - name: Verify Build Output - run: | - echo "Verifying build output..." - ls -la $GITHUB_WORKSPACE/docs/_build/html - if [ ! -f "$GITHUB_WORKSPACE/docs/_build/html/index.html" ]; then - echo "Error: index.html not found in the build output directory." - exit 1 - fi - echo "Build output verification complete. index.html found." - - name: Upload Documentation Artifact - uses: actions/upload-artifact@v4 - with: - name: generated-docs - path: ${{ github.workspace }}/docs/_build/html diff --git a/projects/amdsmi/.github/workflows/auto-label.yml b/projects/amdsmi/.github/workflows/auto-label.yml new file mode 100644 index 0000000000..3b6190cf20 --- /dev/null +++ b/projects/amdsmi/.github/workflows/auto-label.yml @@ -0,0 +1,70 @@ +name: Auto Label PRs + +on: + pull_request: + types: [opened, synchronize, reopened, closed] + +jobs: + apply-labels: + runs-on: lstt5 + permissions: + pull-requests: write + steps: + - name: Add labels based on branch names + uses: actions/github-script@v6 + with: + script: | + const pr = context.payload.pull_request; + const baseBranch = pr.base.ref; + const headBranch = pr.head.ref; + let labelsApplied = false; + + // Debug information + console.log(`Processing PR #${pr.number}: Head: ${headBranch}, Base: ${baseBranch}`); + + // Condition 1: PR targeting amd-mainline + if (baseBranch === 'amd-mainline') { + const labelToAdd = 'Merge amd-mainline'; + try { + await github.rest.issues.addLabels({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: pr.number, + labels: [labelToAdd] + }); + console.log(`Added label "${labelToAdd}" to PR #${pr.number}`); + labelsApplied = true; + } catch (error) { + console.error(`Error adding label "${labelToAdd}": ${error.message}`); + } + } + + // Condition 2: Cherry-pick based on head branch name or release target + const isCherryPickHead = /cherry.*pick/i.test(headBranch); + const isReleaseTargetBase = baseBranch.startsWith('release/'); + + if (isCherryPickHead || isReleaseTargetBase) { + const labelToAdd = 'cherry-pick'; + try { + // Check if the label already exists to avoid redundant API calls if another condition also adds it (though unlikely here) + const existingLabels = pr.labels.map(label => label.name); + if (!existingLabels.includes(labelToAdd)) { + await github.rest.issues.addLabels({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: pr.number, + labels: [labelToAdd] + }); + console.log(`Added label "${labelToAdd}" to PR #${pr.number}`); + labelsApplied = true; + } else { + console.log(`Label "${labelToAdd}" already exists on PR #${pr.number}`); + } + } catch (error) { + console.error(`Error adding label "${labelToAdd}": ${error.message}`); + } + } + + if (!labelsApplied) { + console.log(`PR #${pr.number} did not match criteria for automatic labeling by this workflow.`); + } \ No newline at end of file diff --git a/projects/amdsmi/.github/workflows/generate-docs.yml b/projects/amdsmi/.github/workflows/generate-docs.yml new file mode 100644 index 0000000000..6fc0c8fc8d --- /dev/null +++ b/projects/amdsmi/.github/workflows/generate-docs.yml @@ -0,0 +1,101 @@ +name: Generate Documentation + +on: + pull_request: + branches: [amd-staging, amd-mainline, release/rocm-rel-*] + push: + branches: [amd-staging, amd-mainline, release/rocm-rel-*] + workflow_dispatch: + +permissions: + contents: write + +env: + DEBIAN_FRONTEND: noninteractive + DEBCONF_NONINTERACTIVE_SEEN: true + BUILD_TYPE: Release + +jobs: + generate-docs: + name: Generate Documentation + runs-on: ubuntu-22.04 + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Get branch name and path + id: get_branch_info + run: | + BRANCH_NAME="" + if [[ "${{ github.event_name }}" == "pull_request" ]]; then + BRANCH_NAME="${{ github.head_ref }}" + else + BRANCH_NAME="${{ github.ref_name }}" + fi + SANITIZED_PATH=$(echo "$BRANCH_NAME" | sed -e 's|/|-|g' -e 's|[^a-zA-Z0-9._-]||g' | sed -e 's|^-*||' -e 's|-*$||') + if [[ -z "$SANITIZED_PATH" ]]; then + SANITIZED_PATH="docs-$(date +%s)" + fi + echo "original_branch_name=${BRANCH_NAME}" >> $GITHUB_OUTPUT + echo "deployment_path=${SANITIZED_PATH}" >> $GITHUB_OUTPUT + echo "Deploying docs for branch '${BRANCH_NAME}' to path '${SANITIZED_PATH}'" + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.10' + + - name: Install System Dependencies + run: | + sudo apt-get update + sudo apt-get install -y doxygen graphviz + + - name: Set Up Python Environment + run: | + python3 -m pip install --upgrade pip + python3 -m pip install -r docs/sphinx/requirements.txt + + - name: Build Documentation + run: | + echo "Building documentation..." + echo "Current directory: $(pwd)" + echo "Git repository verification:" + ls -la .git/ || echo "No .git directory found" + git status --porcelain || echo "Git status failed, but continuing..." + if [ ! -e "docs/.git" ]; then + if [ -d ".git" ]; then + ln -s ../.git docs/.git + echo "Created symbolic link to .git in docs directory" + else + echo "Warning: Main .git directory not found. Git-based versioning in docs might not work." + fi + fi + cd docs + python3 -m sphinx -T -E -b html -d _build/doctrees -D language=en . _build/html + echo "Documentation build complete." + + - name: Verify Build Output + run: | + echo "Verifying build output..." + ls -la docs/_build/html + if [ ! -f "docs/_build/html/index.html" ]; then + echo "Error: index.html not found in the build output directory." + exit 1 + fi + echo "Build output verification complete. index.html found." + + - name: Create Artifact Directory with Index Only + run: | + echo "Creating artifact directory with only index.html..." + mkdir -p artifact-output + cp docs/_build/html/index.html artifact-output/ + echo "Artifact contents:" + ls -la artifact-output/ + + - name: Upload Documentation Artifact (Index Only) + uses: actions/upload-artifact@v4 + with: + name: generated-docs-index-${{ steps.get_branch_info.outputs.deployment_path }} + path: artifact-output/ diff --git a/projects/amdsmi/.github/workflows/label_cherrypicks.yml b/projects/amdsmi/.github/workflows/label_cherrypicks.yml deleted file mode 100644 index 4048b66c7e..0000000000 --- a/projects/amdsmi/.github/workflows/label_cherrypicks.yml +++ /dev/null @@ -1,46 +0,0 @@ -# caution: this whole file was written using Claude 3.7 Sonnet -name: Auto Label Cherry-Pick - -on: - pull_request: - types: [opened, synchronize, reopened] - -jobs: - add-label: - runs-on: ubuntu-latest - container: - image: node:16-alpine - permissions: - pull-requests: write - steps: - - name: Add label to cherry-pick and release PRs - uses: actions/github-script@v6 - with: - script: | - const pr = context.payload.pull_request; - const headBranch = pr.head.ref; - const baseBranch = pr.base.ref; - - // Check if head branch contains cherry-pick pattern or base branch starts with release/ - const isCherryPick = /cherry.*pick/i.test(headBranch); - const isReleaseTarget = baseBranch.startsWith('release/'); - - if (isCherryPick || isReleaseTarget) { - // Label to apply - const labelToAdd = 'cherry-pick'; - - // Try to add the label - try { - await github.rest.issues.addLabels({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: pr.number, - labels: [labelToAdd] - }); - console.log(`Added label "${labelToAdd}" to PR #${pr.number}`); - } catch (error) { - console.error(`Error adding label: ${error.message}`); - } - } else { - console.log('PR does not match criteria for automatic labeling'); - } diff --git a/projects/amdsmi/.github/workflows/label_mainline.yml b/projects/amdsmi/.github/workflows/label_mainline.yml deleted file mode 100644 index 21e4f48ee3..0000000000 --- a/projects/amdsmi/.github/workflows/label_mainline.yml +++ /dev/null @@ -1,46 +0,0 @@ -name: Auto Label Mainline PRs - -on: - pull_request: - types: [opened, synchronize, reopened, closed] - -jobs: - add-label: - runs-on: ubuntu-latest - container: - image: node:16-alpine - permissions: - pull-requests: write - steps: - - name: Add label to PRs targeting amd-mainline - uses: actions/github-script@v6 - with: - script: | - const pr = context.payload.pull_request; - const baseBranch = pr.base.ref; - - // Debug information - console.log(`Base Branch: ${baseBranch}`); - - // Check if PR is targeting amd-mainline branch - const isMainlineTarget = baseBranch === 'amd-mainline'; - - if (isMainlineTarget) { - // Label to apply - const labelToAdd = 'Merge amd-mainline'; - - // Try to add the label - try { - await github.rest.issues.addLabels({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: pr.number, - labels: [labelToAdd] - }); - console.log(`Added label "${labelToAdd}" to PR #${pr.number}`); - } catch (error) { - console.error(`Error adding label: ${error.message}`); - } - } else { - console.log('PR does not match criteria for automatic labeling'); - }