25090e003f
* pin ruff versions each to current latest * Update rocprofiler-compute-formatting.yml * Downgrade .pre-commit-config.yaml to match develop
138 regels
4.0 KiB
YAML
138 regels
4.0 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/**'
|
|
- '!**/*.md'
|
|
- '!**/*.rtf'
|
|
- '!**/*.rst'
|
|
- '!**/.markdownlint-ci2.yaml'
|
|
- '!**/.readthedocs.yaml'
|
|
- '!**/.spellcheck.local.yaml'
|
|
- '!**/.wordlist.txt'
|
|
- '!docs/**'
|
|
- '!projects/*/docs/**'
|
|
|
|
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==0.14.11
|
|
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
|
|
|
|
cxx:
|
|
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 clang-format
|
|
- name: clang-format
|
|
working-directory: projects/rocprofiler-compute
|
|
run: |
|
|
set +e
|
|
clang-format -i $(find src -type f | egrep '\.(h|hpp|hh|c|cc|cpp)(|\.in)$')
|
|
if [ $(git diff | wc -l) -gt 0 ]; then
|
|
echo -e "\nError! cxx code not formatted. Run clang-format...\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
|