Skip to content

[AIROCMLIR-597][CI] Extract Jenkinsfile helpers into helpers/*.groovy and load them in a Bootstrap stage #3308

[AIROCMLIR-597][CI] Extract Jenkinsfile helpers into helpers/*.groovy and load them in a Bootstrap stage

[AIROCMLIR-597][CI] Extract Jenkinsfile helpers into helpers/*.groovy and load them in a Bootstrap stage #3308

Workflow file for this run

name: rocMLIR GitHub Actions
on:
pull_request:
branches:
- develop
- 'release/**'
paths:
- "mlir/**"
- "external/**"
- "!external/llvm-project/**"
- ".github/workflows/**"
- "pip_requirements.txt"
push:
branches:
- develop
- 'release/**'
paths:
- "mlir/**"
- "external/**"
- "!external/llvm-project/**"
- ".github/workflows/**"
- "pip_requirements.txt"
jobs:
format-and-lint-checks:
name: Python format and lint checks
runs-on: ubuntu-latest
container:
image: python:3.10
options: --user root
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Fix git ownership
run: |
git config --global --add safe.directory "$GITHUB_WORKSPACE"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r pip_requirements.txt
- name: Get changed Python files under mlir/
id: changes
shell: bash
run: |
echo "Determining merge base..."
if [ "${{ github.event_name }}" = "pull_request" ]; then
BASE_REF="origin/${{ github.base_ref }}"
BASE_BRANCH="${{ github.base_ref }}"
else
BASE_REF="origin/${{ github.ref_name }}"
BASE_BRANCH="${{ github.ref_name }}"
fi
echo "BASE_REF=$BASE_REF"
echo "BASE_BRANCH=$BASE_BRANCH"
# Fetch the base branch explicitly
git fetch origin "$BASE_BRANCH:refs/remotes/origin/$BASE_BRANCH" || \
git fetch origin "$BASE_BRANCH" || true
# Verify that BASE_REF exists locally
if ! git rev-parse --verify "$BASE_REF" >/dev/null 2>&1; then
echo "Error: Base ref '$BASE_REF' does not exist locally. Fetch may have failed." >&2
exit 1
fi
BASE_SHA=$(git merge-base HEAD "$BASE_REF")
echo "BASE_SHA=$BASE_SHA"
# Get added/modified Python files under mlir/ (space-separated)
files=$(git diff --name-only --diff-filter=AM "$BASE_SHA"...HEAD \
| grep -E '^mlir/.*\.py$' | tr '\n' ' ' || true)
echo "files=$files" >> $GITHUB_OUTPUT
echo "Changed Python files:"
echo "$files"
- name: Run flake8
if: steps.changes.outputs.files != ''
run: |
files="${{ steps.changes.outputs.files }}"
if [ -n "$files" ]; then
flake8 --ignore=E501,E251,E124,W605,W504,E131,E126,W503,E123 $files
fi
- name: Run YAPF check
if: steps.changes.outputs.files != ''
run: |
files="${{ steps.changes.outputs.files }}"
if [ -n "$files" ]; then
yapf --diff $files \
|| (echo "Format issues found. Fix locally with: yapf -i <files>"; exit 1)
fi
- name: No Python changes in mlir/
if: steps.changes.outputs.files == ''
run: echo "No changed *.py files under mlir/ – skipping."
python-tests:
name: Python performance script tests
runs-on: ubuntu-latest
container:
image: python:3.10
options: --user root
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Fix git ownership
run: |
git config --global --add safe.directory "$GITHUB_WORKSPACE"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r pip_requirements.txt
- name: Run performance script tests (no GPU)
run: |
cd mlir/utils/performance && python -m pytest tests/ -v
env:
# Tests mock HIP/GPU; no ROCm or GPU required
PYTHONPATH: ${{ github.workspace }}/mlir/utils/performance