-
Notifications
You must be signed in to change notification settings - Fork 51
Open
Description
I wanted to post this in discussions but it's not enabled for the repo.
Here's how I am able to run the clang-tidy review script directly on the github runner environments without needing the ubuntu container.
Why would you do this?
- Saves time spent each run fetching the docker and installing packages with
apt
- You can take better advantage of github caches
- You can run this on any of the runners that github provides or that you host yourself.
- This works on different CI workflows than github actions
- You can use any version of clang-tidy that is available to you in this environment.
- Overall seems to run much faster
name: Clang Tidy
on:
pull_request_target: # Required to post comments on PR from forks
jobs:
clang-tidy-review:
runs-on: ubuntu-latest
if: startsWith(github.event_name, 'pull_request') # Posting a review only makes sense on PRs
steps:
# Repo config for pull_request_target
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
submodules: recursive
# Generate compilation database and make sure to have the source and all third party headers available
# Checkout the review source for the python package
- name: Checkout clang-tidy-review
uses: actions/checkout@v4
with:
repository: ZedThree/clang-tidy-review
ref: master
path: clang-tidy-review
- name: Install LLVM and Clang
uses: KyleMayes/install-llvm-action@v2
with:
version: '17'
- uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: 'pip'
# Install the python package and run review
- name: Non-docker clang-tidy-check
run: |
clang-tidy --version
pip install ${{github.workspace}}/clang-tidy-review/post/clang_tidy_review
review --token=${{ secrets.GITHUB_TOKEN }} --repo=${{ github.event.pull_request.head.repo.full_name }} --pr=${{ github.event.pull_request.number }} --clang_tidy_binary=clang-tidy --build_dir=cmake-build-presets/ninja-multi-vcpkg --config_file=.clang-tidy --split_workflow=True
env:
USER: ${{ github.event.pull_request.user.login }}
# Upload the review for the next job
- uses: actions/upload-artifact@v3
with:
name: ClangTidyReviewOutputs-${{matrix.os}}
path: |
clang-tidy-review-metadata.json
clang-tidy-review-output.json
clang_tidy_review.yaml
# Second part of the split job
clang-tidy-comments:
runs-on: ubuntu-latest
needs: clang-tidy-review
steps:
- name: Checkout clang-tidy-review
uses: actions/checkout@v4
with:
repository: ZedThree/clang-tidy-review
ref: master
path: clang-tidy-review
# Download all the reviews
- uses: actions/download-artifact@v3
with:
name: ClangTidyReviewOutputs-ubuntu-latest
path: ubuntu-latest
- uses: actions/download-artifact@v3
with:
name: ClangTidyReviewOutputs-macos-latest
path: macos-latest
- uses: actions/download-artifact@v3
with:
name: ClangTidyReviewOutputs-windows-latest
path: windows-latest
- uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: 'pip'
# Again install and run the python package to post the review
- name: Non-docker clang-tidy-check
run: |
clang-tidy --version
pip install ${{github.workspace}}/clang-tidy-review/post/clang_tidy_review
cp ubuntu-latest/clang-tidy-review-metadata.json .
post --token=${{ secrets.GITHUB_TOKEN }} --repo=${{ github.event.pull_request.head.repo.full_name }} ubuntu-latest/clang-tidy-review-output.json macos-latest/clang-tidy-review-output.json windows-latest/clang-tidy-review-output.json
Metadata
Metadata
Assignees
Labels
No labels