@@ -12,37 +12,54 @@ runs:
12
12
13
13
- name : Get changed files
14
14
id : changed-files
15
- uses : tj-actions/changed-files@v44
15
+ env :
16
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
17
+ run : |
18
+ PR_NUMBER=${{ github.event.pull_request.number }}
19
+ REPO_FULL_NAME=${{ github.repository }}
20
+ echo "Fetching changed files for PR #$PR_NUMBER in $REPO_FULL_NAME"
21
+
22
+ # Use GitHub API to get the list of changed files
23
+ CHANGED_FILES=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \
24
+ -H "Accept: application/vnd.github.v3+json" \
25
+ "https://api.github.com/repos/$REPO_FULL_NAME/pulls/$PR_NUMBER/files" \
26
+ | jq -r '.[].filename')
27
+
28
+ echo "Changed files:"
29
+ echo "$CHANGED_FILES"
30
+
31
+ # Set the output for the next steps
32
+ echo "::set-output name=all_changed_files::$CHANGED_FILES"
16
33
17
34
- name : List Files
18
35
shell : bash
19
36
env :
20
37
CHANGED_FILES : ${{ steps.changed-files.outputs.all_changed_files }}
21
38
run : |
22
- pattern_to_exclude_from_clang=".*clang/test/dpct"
23
- files_to_be_check=""
24
- echo "changed files are $CHANGED_FILES"
25
-
26
- for i in $CHANGED_FILES
27
- do
28
- if [[ "$i" =~ ${pattern_to_exclude_from_clang} ]];then
29
- echo "${i} will be excluded from format checking"
30
- else
31
- files_to_be_check="${files_to_be_check} $i"
32
- fi
33
-
34
- done
35
-
36
- echo " git clang-format ${{ github.event.pull_request.base.sha }} ${files_to_be_check}"
37
- git clang-format ${{ github.event.pull_request.base.sha }} ${files_to_be_check} || echo "Files need to be formated are detected. "
38
- echo "before git diff"
39
- git diff > ./clang-format.patch
40
- # Add patch with formatting fixes to CI job artifacts
39
+ pattern_to_exclude_from_clang=".*clang/test/dpct"
40
+ files_to_be_check=""
41
+ echo "changed files are $CHANGED_FILES"
42
+
43
+ for i in $CHANGED_FILES
44
+ do
45
+ if [[ "$i" =~ ${pattern_to_exclude_from_clang} ]]; then
46
+ echo "${i} will be excluded from format checking"
47
+ else
48
+ files_to_be_check="${files_to_be_check} $i"
49
+ fi
50
+ done
51
+
52
+ echo "git clang-format ${{ github.event.pull_request.base.sha }} ${files_to_be_check}"
53
+ git clang-format ${{ github.event.pull_request.base.sha }} ${files_to_be_check} || echo "Files need to be formatted are detected. "
54
+ echo "before git diff "
55
+ git diff > ./clang-format.patch
56
+
57
+ # Add patch with formatting fixes to CI job artifacts
41
58
- uses : actions/upload-artifact@v4
42
59
with :
43
60
name : clang-format-patch
44
61
path : ./clang-format.patch
62
+
45
63
- name : Check if clang-format patch is empty
46
64
shell : bash
47
65
run : bash -c "if [ -s ./clang-format.patch ]; then cat ./clang-format.patch; exit 1; fi"
48
-
0 commit comments