48
48
- name : Konfigurasi statik lint cpp
49
49
run : cmake -B build -S . -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
50
50
51
- - name : lint file yang telah di commit
52
- shell : python
53
- run : |
54
- import os
55
- import sys
56
- import subprocess
57
-
58
- print("Python {}.{}.{}".format(*sys.version_info))
59
- with open("git_diff.txt") as in_file:
60
- file_modifikasi = sorted(in_file.read().splitlines())
61
- print("{} file yang termodifikasi".format(len(file_modifikasi)))
62
-
63
- cpp_exts = tuple(".c .c++ .cc .cpp .cu .cuh .cxx .h .h++ .hh .hpp .hxx".split())
64
- cpp_files = [file for file in file_modifikasi if file.lower().endswith(cpp_exts)]
65
- print(f"{len(cpp_files)} C++ file yang termodifikasi")
66
- if not cpp_files:
67
- sys.exit(0)
68
-
69
- subprocess.run(["clang-tidy", "--fix", "-p=build", "--extra-arg=-std=c++11", *cpp_files, "--"],
70
- check=True, text=True, stderr=subprocess.STDOUT)
71
- subprocess.run(["clang-format", "-i", "-style=file", *cpp_files],
72
- check=True, text=True, stderr=subprocess.STDOUT)
73
- upper_files = [file for file in cpp_files if file != file.lower()]
74
- if upper_files:
75
- print(f"{len(upper_files)} files contain uppercase characters:")
76
- print("\n".join(upper_files) + "\n")
77
- space_files = [file for file in cpp_files if " " in file or "-" in file]
78
- if space_files:
79
- print(f"{len(space_files)} file mengandung spasi dan garis tengah:")
80
- print("\n".join(space_files) + "\n")
81
- nodir_files = [file for file in cpp_files if file.count(os.sep) != 1]
82
- if nodir_files:
83
- print(f"{len(nodir_files)} files are not in one and only one directory:")
84
- print("\n".join(nodir_files) + "\n")
85
- bad_files = len(upper_files + space_files + nodir_files)
86
- if bad_files:
87
- sys.exit(bad_files)
88
-
51
+ - name : cek lint hasil modifikasi
52
+ shell : bash
53
+ run : python3 .linter/file_linter.py
89
54
- name : commit
90
55
run : |
91
56
git commit -am "chore: clang formatter and clang-tidy fixing ${GITHUB_SHA:8}" || true
@@ -95,13 +60,28 @@ jobs:
95
60
name : cek compile
96
61
runs-on : ${{ matrix.os }}
97
62
needs : [TestingUtama]
63
+ permissions :
64
+ pull-requests : write
98
65
strategy :
99
66
matrix :
100
67
os : [ubuntu-latest, windows-latest, macOS-latest]
101
68
steps :
102
- - uses : actions/checkout@v3
103
- with :
104
- submodules : true
105
- - run : cmake -B ./build -S .
106
- - run : cmake --build build
69
+ - uses : actions/checkout@v4
70
+ with :
71
+ submodules : true
72
+ - name : build cpp
73
+ run : |
74
+ cmake -B ./build -S .
75
+ cmake --build build --parallel 4
76
+ - name : tambah label jika fail
77
+ uses : actions/github-script@v6
78
+ if : ${{ failure() && matrix.os == 'ubuntu-latest' && github.event_name == 'pull_request'}}
79
+ with :
80
+ script : |
81
+ github.rest.issue.addLabels({
82
+ issue_number: context.issue.number,
83
+ owner: context.repo.owner,
84
+ repo: context.repo.repo,
85
+ labels: ['testing fail!']
86
+ })
107
87
0 commit comments