Dosyalar
rocm-systems/.github/workflows/rocprofiler-compute-formatting.yml
T
Jason Bonnell eebf5ead8c Replace cmake-format with gersemi in rocprofiler-compute-formatting.yml (#1053)
* Replace cmake-format with gersemi in rocprofiler-compute-formatting.yml

* Run gersemi formatting on CMakeLists.txt files

* Remove .cmake-format.yaml, add .gersemirc file

* Add more options to .gersemirc

* Add new line to .gersemirc

* Add new line to CMakeLists.txt

* Run gersemi again with new options
2025-09-19 08:42:40 -04:00

102 satır
2.9 KiB
YAML

name: rocprofiler-compute Formatting
on:
push:
branches:
- develop
paths:
- 'projects/rocprofiler-compute/**'
pull_request:
paths:
- '.github/workflows/rocprofiler-compute-formatting.yml'
- 'projects/rocprofiler-compute/**'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
python:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4
with:
sparse-checkout: projects/rocprofiler-compute
- name: Set up Python '3.x'
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install dependencies
working-directory: projects/rocprofiler-compute
run: |
python -m pip install --upgrade pip
python -m pip install ruff
if [ -f requirements.txt ]; then python -m pip install -r requirements.txt; fi
- name: Run Ruff Linter and Import Sorter
run: |
ruff check . --fix --exit-zero
- name: Run Ruff Formatter
run: |
ruff format .
- name: Check for formatting/linting changes
run: |
git config --global user.name 'github-actions'
git config --global user.email 'github-actions@github.com'
git add -A .
if ! git diff --cached --quiet; then
echo "::error::Files were modified by ruff. Please run 'ruff check . --fix && ruff format .' locally and commit the changes."
git diff --cached --patch # Show the diff in the logs
exit 1
else
echo "Ruff found no issues or all issues were fixed and files are clean."
fi
cmake:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
sparse-checkout: projects/rocprofiler-compute
- name: Install dependencies
working-directory: projects/rocprofiler-compute
run: |
sudo apt-get update
sudo apt-get install -y python3-pip
python3 -m pip install gersemi
- name: gersemi
working-directory: projects/rocprofiler-compute
run: |
set +e
gersemi -i $(find . -type f | egrep 'CMakeLists.txt|\.cmake$')
if [ $(git diff | wc -l) -gt 0 ]; then
echo -e "\nError! CMake code not formatted. Run gersemi...\n"
echo -e "\nFiles:\n"
git diff --name-only
echo -e "\nFull diff:\n"
git diff
exit 1
fi
python-bytecode:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
sparse-checkout: projects/rocprofiler-compute
- name: find-bytecode
working-directory: projects/rocprofiler-compute
run: |
set +e
FILES=$(find . -type f | egrep '__pycache__|\.pyc$')
if [ -n "${FILES}" ]; then
echo -e "\nError! Python bytecode included in commit\n"
echo -e "### FILES: ###"
echo -e "${FILES}"
echo -e "##############"
exit 1
fi