-
Notifications
You must be signed in to change notification settings - Fork 55
129 lines (111 loc) · 3.78 KB
/
ci.yml
File metadata and controls
129 lines (111 loc) · 3.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
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