Skip to content

Commit

Permalink
Add clang-tidy (changes only) and docs PR jobs (#583)
Browse files Browse the repository at this point in the history
* Add clang-tidy (changes only) PR job
  • Loading branch information
alan-forbes-cp authored Nov 12, 2024
1 parent 6ca1e93 commit 7ce70e9
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/actions/setup_build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ runs:
if [ "${{ inputs.ubuntu_version }}" = "22.04" ]; then sudo wget -qO /etc/apt/sources.list.d/lunarg-vulkan-1.3.243-jammy.list https://packages.lunarg.com/vulkan/1.3.243/lunarg-vulkan-1.3.243-jammy.list; fi
if [ "${{ inputs.ubuntu_version }}" = "24.04" ]; then sudo wget -qO /etc/apt/sources.list.d/lunarg-vulkan-noble.list https://packages.lunarg.com/vulkan/lunarg-vulkan-noble.list; fi
sudo apt-get update
pip install lit clang-format==19.1.0 virtualenv
pip install lit clang-format==19.1.0 clang-tidy==19.1.0 virtualenv
sudo apt-get install --yes doxygen
sudo apt-get install --yes vulkan-sdk
if [ "${{ inputs.cross_arch }}" = "x86" ]; then \
Expand Down
67 changes: 64 additions & 3 deletions .github/workflows/run_pr_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:

steps:
- name: Checkout repo
uses: actions/checkout@v4
uses: actions/checkout@v4.1.0

# installs tools, ninja, installs llvm and sets up sccahe
- name: setup-ubuntu
Expand Down Expand Up @@ -75,7 +75,7 @@ jobs:

steps:
- name: Checkout repo
uses: actions/checkout@v4
uses: actions/checkout@v4.1.0

# installs tools, ninja, installs llvm and sets up sccahe
- name: setup-ubuntu
Expand All @@ -96,14 +96,75 @@ jobs:
run:
ninja -C build check-ock-UnitCL

# build and run clang-tidy
run_clang_tidy_changes:

runs-on: ubuntu-22.04

steps:
- name: Checkout repo
uses: actions/[email protected]

# installs tools, ninja, installs llvm and sets up sccahe
- name: setup-ubuntu
uses: ./.github/actions/setup_build
with:
llvm_version: 19
llvm_build_type: RelAssert

- name: build initial config files
uses: ./.github/actions/do_build_ock
with:
build_type: ReleaseAssert
host_image: ON
build_targets: build.ninja

# Here we compute the set difference between the output of the two
# temporary file descriptors using `awk`. Awk processes both files line by
# line, going through the first file, then the second file. The NR==FNR
# predicate executes its block only on the records of the first file,
# ensuring to call `next` (equivalent to `return`) to avoid running the
# second block on each line in the first file.
#
# The first input to `awk` lists all targets reported by ninja.
#
# The second input to awk collects all targets on which `tidy-` targets
# depend. This may include targets which are guarded by if() statements in
# CMake, hence why we need to compute a set difference with the targets that
# ninja reports.
- name: build actual targets needed
run:
ninja -C build
$(
awk -F':' 'NR==FNR { targets[$1] = 1; next } $1 in targets { print $1 }'
<(ninja -C build -t targets)
<(
find modules source -type f -name CMakeLists.txt -exec
awk -F"[()]" '/add_dependencies\(tidy-/ {sub(/[^ ]*/, "", $2);print $2}'
{} \+ | tr ' ' '\n'
)
)

- name: run clang-tidy
run: |
git fetch origin ${{ github.base_ref }}
./scripts/compute-dependants.py \
--exclude-filter='(/build/.*\.s$)|(.*/(external|cookie)/.*)' \
--build-dir="$PWD/build" \
`git diff --name-only --diff-filter=d \
HEAD..origin/${{ github.base_ref }} | \
grep -P '\.(c|cc|cxx|cpp|h|hh|hpp|hxx)$'` | \
tee /dev/stderr | \
parallel --verbose -- clang-tidy --quiet -p "$PWD/build/" "{}"
# run clang-format-diff on the repo
run_clang_format:

runs-on: ubuntu-22.04

steps:
- name: Checkout repo
uses: actions/checkout@v4
uses: actions/checkout@v4.1.0

- name: setup-ubuntu-clang-format
run:
Expand Down

0 comments on commit 7ce70e9

Please sign in to comment.