Skip to content

Commit 84b6e25

Browse files
committed
Add style CI
1 parent df5d079 commit 84b6e25

File tree

2 files changed

+93
-47
lines changed

2 files changed

+93
-47
lines changed

.github/workflows/push.yml

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -42,53 +42,6 @@ env:
4242
CC: ccache gcc
4343
CXX: ccache g++
4444
jobs:
45-
CODE_FORMATTING_CHECK:
46-
name: CODE_FORMATTING_CHECK
47-
if: github.repository_owner == 'php' || github.event_name == 'pull_request'
48-
runs-on: ubuntu-latest
49-
steps:
50-
- name: git checkout
51-
uses: actions/checkout@v4
52-
with:
53-
fetch-depth: 0
54-
- name: apt
55-
run: |
56-
set -x
57-
sudo apt-get update
58-
sudo apt-get install \
59-
git \
60-
clang-format \
61-
php-cli \
62-
netcat-openbsd
63-
- name: check code formatting
64-
run: |
65-
set -x
66-
git fetch origin master
67-
git diff origin/master > ../master.diff
68-
if [ -f scripts/dev/format_pull_request.php ]; then
69-
cp scripts/dev/format_pull_request.php ..
70-
fi
71-
git checkout master
72-
if [ -f scripts/dev/format_pull_request.php ]; then
73-
cp scripts/dev/format_pull_request.php ..
74-
fi
75-
if [ ! -f ../format_pull_request.php ]; then
76-
echo "error: format_pull_request.php does not exist" 1>&2
77-
exit 1
78-
fi
79-
git reset --hard origin/master
80-
php ../format_pull_request.php ../master.diff > ../formatted.diff
81-
if [ -s ../formatted.diff ]; then
82-
cat ../formatted.diff
83-
echo "code formatting check failed :("
84-
patch_url=$(cat ../formatted.diff | nc termbin.com 9999)
85-
echo "Please run"
86-
echo "curl $patch_url | git apply -v"
87-
exit 1
88-
else
89-
echo "code formatting check succeeded :)"
90-
exit 0
91-
fi
9245
LINUX_X64:
9346
if: github.repository_owner == 'php' || github.event_name == 'pull_request'
9447
services:

.github/workflows/styling.yml

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: Code Styling Check
2+
on:
3+
push:
4+
paths-ignore:
5+
- docs/*
6+
- NEWS
7+
- UPGRADING
8+
- UPGRADING.INTERNALS
9+
- '**/README.*'
10+
- CONTRIBUTING.md
11+
- CODING_STANDARDS.md
12+
- .cirrus.yml
13+
- .travis.yml
14+
- travis/*
15+
- .circleci/*
16+
branches:
17+
- PHP-8.1
18+
- PHP-8.2
19+
- PHP-8.3
20+
- master
21+
pull_request:
22+
paths-ignore:
23+
- docs/*
24+
- NEWS
25+
- UPGRADING
26+
- UPGRADING.INTERNALS
27+
- '**/README.*'
28+
- CONTRIBUTING.md
29+
- CODING_STANDARDS.md
30+
- .cirrus.yml
31+
- .travis.yml
32+
- travis/*
33+
- .circleci/*
34+
branches:
35+
- '**'
36+
permissions:
37+
contents: read
38+
concurrency:
39+
group: ${{ github.workflow }}-${{ github.event.pull_request.url || github.run_id }}
40+
cancel-in-progress: true
41+
jobs:
42+
CODE_FORMATTING_CHECK:
43+
name: CODE_FORMATTING_CHECK
44+
# if: github.repository_owner == 'php' || github.event_name == 'pull_request'
45+
runs-on: ubuntu-latest
46+
steps:
47+
- name: git checkout
48+
uses: actions/checkout@v4
49+
with:
50+
fetch-depth: 0
51+
- name: apt
52+
run: |
53+
set -x
54+
sudo apt-get update
55+
sudo apt-get install \
56+
git \
57+
clang-format \
58+
php-cli \
59+
netcat-openbsd
60+
- name: check code formatting
61+
run: |
62+
set -x
63+
git fetch origin master
64+
git diff origin/master > ../master.diff
65+
if [ -f scripts/dev/format_pull_request.php ]; then
66+
cp scripts/dev/format_pull_request.php ..
67+
fi
68+
git checkout master
69+
if [ -f scripts/dev/format_pull_request.php ]; then
70+
cp scripts/dev/format_pull_request.php ..
71+
fi
72+
if [ ! -f ../format_pull_request.php ]; then
73+
echo "error: format_pull_request.php does not exist" 1>&2
74+
exit 1
75+
fi
76+
git reset --hard origin/master
77+
php ../format_pull_request.php ../master.diff > ../formatted.diff
78+
if [ -s ../formatted.diff ]; then
79+
cat ../formatted.diff
80+
echo "code formatting check failed :("
81+
patch_url=$(cat ../formatted.diff | nc termbin.com 9999)
82+
echo "Please run"
83+
echo "curl $patch_url | git apply -v"
84+
exit 1
85+
else
86+
echo "code formatting check succeeded :)"
87+
exit 0
88+
fi
89+
- name: 'Upload artifacts'
90+
uses: actions/upload-artifact@v4
91+
with:
92+
name: 'format.patch'
93+
path: ../formatted.diff

0 commit comments

Comments
 (0)