Skip to content

Commit

Permalink
do not use open-source actions
Browse files Browse the repository at this point in the history
  • Loading branch information
apolyakov committed Feb 5, 2025
1 parent 17d4574 commit f17d303
Showing 1 changed file with 14 additions and 30 deletions.
44 changes: 14 additions & 30 deletions .github/workflows/pr-code-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,44 +17,28 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Checkout through merge base
uses: rmacklin/fetch-through-merge-base@v0
with:
base_ref: ${{ github.event.pull_request.base.ref }}
head_ref: ${{ github.event.pull_request.head.sha }}
deepen_length: 500

- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v39
with:
separator: ","
skip_initial_fetch: true

- name: "Listed files"
env:
CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
run: |
echo "Formatting files:"
echo "$CHANGED_FILES"
fetch-depth: 0

- name: Install clang-format
uses: aminya/setup-cpp@v1
with:
clangformat: 18.1.8
run:
echo "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-18 main" | sudo tee -a /etc/apt/sources.list && \
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - && \
sudo apt update && sudo apt install -y --no-install-recommends clang-format-18.1.8*

- name: Run clang-format on changed files
run: |
# Get list of changed files
CHANGED_FILES=$(git diff --name-only --diff-filter=ACM origin/master...HEAD --)
CHANGED_CPP_FILES=$(echo "$CHANGED_FILES" | grep -E '^(runtime-light|runtime-common)/.*\.(cpp|h|inl)$')
# Apply clang-format to each changed source file
echo "$CHANGED_CPP_FILES" | xargs -r clang-format-18 -i
- name: Check for formatting changes
run: |
# Check if any files were modified by clang-format
if [[ `git status --porcelain` ]]; then
echo "Code is not formatted. Please run clang-format."
git diff
exit 1
git diff --exit-code
if [ $? -ne 0 ]; then
echo "Code is not formatted. Please run clang-format."
exit 1
fi

0 comments on commit f17d303

Please sign in to comment.