mirror of
https://github.com/CoolProp/CoolProp.git
synced 2026-04-23 03:00:17 -04:00
- Use commit SHAs from GitHub context instead of remotes/origin/<branch> names, which don't exist for PRs from forks - Handle push events separately (GITHUB_HEAD/BASE_REF are empty on push) - Bump actions/checkout v3 -> v6, actions/upload-artifact v4 -> v7 - Remove redundant `git fetch --all` Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
47 lines
1.7 KiB
YAML
47 lines
1.7 KiB
YAML
name: Development Clang Format
|
|
|
|
on:
|
|
push:
|
|
branches: [ 'master', 'main', 'develop', 'dev_checks' ]
|
|
# tags: [ 'v*' ]
|
|
pull_request:
|
|
branches: [ 'master', 'main', 'develop' ]
|
|
#schedule:
|
|
# - cron: '15 8 * * 3' # Run weekly
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
with:
|
|
fetch-depth: 0 # Fetch all history (especially branches)
|
|
|
|
- name: Run clang-format against C++ files touched by the PR
|
|
shell: bash
|
|
run: |
|
|
echo "GITHUB_REF=$GITHUB_REF GITHUB_BASE_REF=$GITHUB_BASE_REF GITHUB_HEAD_REF=$GITHUB_HEAD_REF"
|
|
clang-format --version
|
|
if [ "${{ github.event_name }}" == "pull_request" ]; then
|
|
# Use SHAs directly so this works for both fork PRs and local-branch PRs.
|
|
# remotes/origin/<branch> is unreliable for fork PRs because the fork's
|
|
# branch is not fetched into origin.
|
|
BASE_SHA="${{ github.event.pull_request.base.sha }}"
|
|
HEAD_SHA="${{ github.sha }}"
|
|
echo "Comparing HEAD $HEAD_SHA against base $BASE_SHA"
|
|
./dev/ci/clang-format.sh "$HEAD_SHA" "$BASE_SHA"
|
|
else
|
|
# Push event: GITHUB_HEAD_REF/BASE_REF are empty, so use before/after SHAs.
|
|
BEFORE_SHA="${{ github.event.before }}"
|
|
AFTER_SHA="${{ github.sha }}"
|
|
echo "Comparing push $AFTER_SHA against before $BEFORE_SHA"
|
|
./dev/ci/clang-format.sh "$AFTER_SHA" "$BEFORE_SHA"
|
|
fi
|
|
|
|
- name: Upload clang-format patch as artifact
|
|
if: ${{ failure() }}
|
|
uses: actions/upload-artifact@v7
|
|
with:
|
|
name: CoolProp-${{ github.sha }}-clang_format.patch
|
|
path: clang_format.patch
|