forked from mt8163/android_kernel_amazon_karnak_4.9
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
2737 lines (2701 loc) · 163 KB
/
action.yml
File metadata and controls
2737 lines (2701 loc) · 163 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
name: Check File Action
description: 'Check file - Add filename to check for errors or text Word to search for within workspace files'
inputs:
repository:
description: 'Auto clone user remote repo locally for checks'
type: boolean
required: false
default: 'true'
absolute:
description: 'Search will use absolute over relative path from github workspace'
type: boolean
required: false
default: 'true'
analyzer:
description: 'Analyze all project files using options 1 - 2 - 3 - 4'
required: false
default: 0
type: choice
options:
- 0 # disable project analyzer
- 1 # run-clang-tidy.py - fastest for large project file checks. fix-its
- 2 # clang-tidy - faster for small an large project file checks. fix-its
- 3 # clangd-tidy - fast large project file checks.
- 4 # codechecker - compiler project file check reports.
makefile:
description: 'Make filename for building project source'
type: string
required: false
default: 'build/CMakeFiles/Makefile2'
filename:
description: 'Check for filename or search for text word matches'
type: string
required: false
default: ''
filetype:
description: 'Check only these file extension types when searching for text word matches'
type: string
required: false
default: 'none'
database:
description: 'Use file database over find commands slower performance for searches'
type: boolean
required: false
default: 'false'
dirname:
description: 'Directory to check files or if using project option the dir to include for header checks & builds'
type: string
required: false
default: ''
pattern:
description: 'Search for pattern matches in filetypes or all files'
type: string
required: false
default: ''
project:
description: 'Fix Errors found while building project or check build only'
type: boolean
required: false
default: 'false'
recheck:
description: 'Recheck files repaired by check-file'
type: boolean
required: false
default: 'false'
repair:
description: 'Check file and fix if able when searching for errors'
type: boolean
required: false
default: 'false'
report:
description: 'Errors found will be logged and sent to repository releases'
type: boolean
required: false
default: 'false'
compiler:
description: 'Clang compiler used for project building only'
type: string
required: false
default: 'clang-latest'
content:
description: 'Search will list dir contents of found filename'
type: boolean
required: false
default: 'false'
include:
description: 'Check include file when checking source C/C++ filename'
type: boolean
required: false
default: 'true'
source:
description: 'Check all soucre files for include directories to auto add for clang/cmake'
required: false
default: 2
type: choice
options:
- 1 # Locate all includes in sources and display all content found about files.
- 2 # Locate all includes in sources and display more content found about files.
- 3 # Locate all includes in sources and display less content found about files.
- 4 # Locate all includes in sources and create object dependencies displaying content found about files.
- 5 # Create file to fix all source files and includes for compile commands json content.
number:
description: 'Number of files to check before stopping action'
type: number
required: false
default: 0
stored:
description: 'Checked files with errors repaired are skipped if ran again'
type: boolean
required: false
default: 'false'
update:
description: 'Errors repaired with check-file will push changes to remote repository'
type: boolean
required: false
default: 'false'
upload:
description: 'Upload build files for compile_commands.json'
type: boolean
required: false
default: 'false'
output:
description: 'Output log stdout type 1,2 or 3'
required: false
default: 1
type: choice
options:
- 1 # Output to terminal log and error/project file.
- 2 # Output to error/project file only.
- 3 # Output to terminal log only.
- 4 # Disable most output.
build:
description: 'Fix Errors found while building repository project'
type: choice
required: false
default: '0'
options:
- 0 # Disable building projects.
- 1 # Build & check project. [CodeChecker Dry-Run Multiple-Files]
- 2 # Build new compile_commands_json & check project. [CodeChecker Build Multiple-Files]
- 3 # Build check includes & check project. [Deheader Dry-Run Multiple-Files]
- 4 # Build fix includes & check project. [Deheader Build Single-Files]
clean:
description: 'Clean workflow on checkout'
type: boolean
required: false
default: 'true'
cache:
description: 'Cache Needed Project Files'
type: boolean
required: false
default: 'false'
runs:
using: composite
steps:
- name: Linux Distro Check
run: |
echo '';
echo 'export ANSIBLE_FORCE_COLOR=true' | sudo tee -a ~/.bashrc >/dev/null;
echo -e "####################\n\033[31mCheck-File-Action-Pro version 2.0.0 [Beta Stable]\033[0m\n####################\n";
echo -e "Check-File Started: ${{ github.event.repository.updated_at }}\n";
if [[ -r '/etc/os-release' ]]; then
. /etc/os-release
if [[ "${ID}" == 'ubuntu' ]]; then
echo "Name: ${NAME}"
echo "Version: ${VERSION}"
echo "ID: ${ID}"
echo "ID Like: ${ID_LIKE}"
echo "Pretty Name: ${PRETTY_NAME}"
echo "Version ID: ${VERSION_ID}"
else
echo "Not running an Ubuntu distribution. ID=${ID}, VERSION=${VERSION}"
fi;
else
echo "Not running a distribution with /etc/os-release available"
fi;
echo '';
shell: bash
continue-on-error: true
- name: Clone Recovery Repo
if: inputs.repository == 'true'
uses: actions/checkout@v6
with:
repository: ${{ github.repository }}
ref: ${{ github.ref }}
clean: ${{ inputs.clean }}
fetch-depth: 1
show-progress: false
continue-on-error: false
- name: Restore Project
if: inputs.cache == 'true' && ( inputs.stored == 'true' || inputs.source == 'true' )
id: restore
uses: actions/cache/restore@v5
env:
cache-name: check-file-action
with:
path: |
./build
compile_commands.json
check-file-sources.txt
check-file-includes.txt
check-file-repaired.txt
key: ${{ runner.os }}-${{ env.cache-name }}
restore-keys: |
${{ runner.os }}
enableCrossOsArchive: true
continue-on-error: true
- name: Access repo info and branch
run: |
echo '';
if ${{ steps.restore.outputs.cache-hit == 'true' }}; then
echo -e "####################\n\033[32mCheck-File Restored Project Configuration From Cache!\033[0m\n####################\n";
fi;
echo "Repository Owner and Name: ${GITHUB_REPOSITORY}";
echo "Branch Name: ${{ github.ref_name }}";
echo "GitHub URL: ${{ github.server_url }}";
echo "Repository URL via context: ${{ github.server_url }}/${{ github.repository }}";
echo -e "Ref (branch/tag) via context: ${{ github.ref }}\n";
shell: bash
continue-on-error: true
- name: Set up Go 1.25.3
if: inputs.filename != ''
uses: actions/setup-go@v2
with:
go-version: '1.25.3'
continue-on-error: true
- name: Setup Clang Compiler
if: inputs.project == 'true'
uses: rlalik/setup-cpp-compiler@master
with:
compiler: ${{ inputs.compiler }}
continue-on-error: true
- name: Installing Dependencies
if: inputs.pattern != '' || inputs.filename != '' || inputs.project != 'false'
run: |
echo '';
set -o pipefail
echo 'export ALLOW_MISSING_DEPENDENCIES=true' | sudo tee -a ~/.bashrc >/dev/null;
echo 'export GIT_DISCOVERY_ACROSS_FILESYSTEM=1' | sudo tee -a ~/.bashrc >/dev/null;
echo 'export DEBIAN_FRONTEND=noninteractive' | sudo tee -a ~/.bashrc >/dev/null;
echo 'export LLVM_ENABLE_THREADS=ON' | sudo tee -a ~/.bashrc >/dev/null;
echo 'export WITH_TIDY=1' | sudo tee -a ~/.bashrc >/dev/null;
echo 'export LC_ALL=C' | sudo tee -a ~/.bashrc >/dev/null;
sudo apt-get clean
sudo add-apt-repository universe >/dev/null;
sudo apt-get update -yq 2>&1 >/dev/null | sed '/Running/,/host./d';
if ${{ inputs.project }} && [[ ! $(which cmake) ]]; then
sudo apt-get -yq install cmake make 2>&1 >/dev/null | sed '/Running/,/host./d' && echo -e "####################\ncmake dependencies installed\n####################" || echo -e '::error::No cmake installed for project build';
[[ ! $(which cmake) ]] && exit 1
fi;
cmake_version=$(cmake --version 2>/dev/null | grep version | awk '{print $3}');
required_version="4.2.1";
linux_distro1="24.04";
linux_distro2="22.04";
linux_distro3="20.04";
linux_verison=$(lsb_release -r | awk '{print $2}');
if ${{ inputs.project }}; then
if [[ "${cmake_version}" < "${required_version}" ]] && ${{ inputs.project }}; then
echo -e "Current CMake version (${cmake_version}) is older than ${required_version}. Updating...";
sudo apt-get remove --purge -yq cmake 2>&1 >/dev/null | sed '/Running/,/host./d'
sudo apt-get install -yq ca-certificates gpg wget 2>&1 >/dev/null | sed '/Running/,/host./d'
[[ ! $(which make) ]] && sudo apt-get install -yq make >/dev/null && echo -e "####################\nmake dependencies already installed\n####################\n";
sudo bash -c "$(sudo wget -qO - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | sudo tee /usr/share/keyrings/kitware-archive-keyring.gpg >/dev/null)";
if [[ "${linux_verison}" == "${linux_distro1}" ]]; then
echo 'deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ noble main' | sudo tee -a /etc/apt/sources.list.d/kitware.list >/dev/null;
elif [[ "${linux_verison}" == "${linux_distro2}" ]]; then
echo 'deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ jammy main' | sudo tee -a /etc/apt/sources.list.d/kitware.list >/dev/null;
elif [[ "${linux_verison}" == "${linux_distro3}" ]]; then
echo 'deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ focal main' | sudo tee -a /etc/apt/sources.list.d/kitware.list >/dev/null;
else
echo -e "\nKitWare Keyring: Noble ${linux_verison}\n";
echo 'deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ noble main' | sudo tee -a /etc/apt/sources.list.d/kitware.list >/dev/null;
fi;
fi;
fi;
text0="####################\ngit dependencies installed\n####################";
text1="####################\nripgrep dependencies installed\n####################";
text2="####################\nansi2txt dependencies installed\n####################";
text3="####################\nca-certificates dependencies installed\n####################";
text4="####################\ncppcheck dependencies installed\n####################";
text5="####################\nclang-tools dependencies installed\n####################";
text6="####################\nshellharden dependencies installed\n####################";
text7="####################\nshellcheck dependencies installed\n####################";
text8="####################\ncheckmake dependencies installed\n####################";
text9="####################\nbatcat dependencies installed\n####################";
file_name="${{ inputs.filename }}";
file_type="${file_name##*.}";
github=${GITHUB_WORKSPACE};
if [[ ! $(which python3) ]]; then
sudo apt-get -yq install python3 2>&1 >/dev/null | sed '/Running/,/host./d' && echo -e "####################\npython3 dependencies installed\n####################" || echo -e '::error::No python3 installed for project checks';
[[ ! $(which python3) ]] && exit 1
fi;
if ${{ inputs.project }} && [[ ! $(which update-ca-certificates) ]]; then
sudo apt-get -yq install ca-certificates 2>&1 >/dev/null | sed '/Running/,/host./d' && echo -e "${text3}" || echo 'No ca-certificates installed effects can vary';
fi;
if [[ ! $(which gawk) ]]; then
sudo apt-get -yq install gawk 2>&1 >/dev/null | sed '/Running/,/host./d' && echo -e "####################\ngawk dependencies installed\n####################" || echo -e "\n::error::No gawk installed in linux exiting";
fi;
echo 'deb [trusted=yes] https://apt.gabe565.com /' | sudo tee -a /etc/apt/sources.list.d/gabe565.list >/dev/null;
if ${{ inputs.project }} && [[ "${cmake_version}" < "${required_version}" ]]; then
python3 -m pip install --upgrade pip >/dev/null && echo -e "\n####################\npip dependencies installed\n####################" || echo -e '::warning::pip not updated for project checks';
echo -e "\nCMake version $cmake_version upgrading to latest python cmake";
sudo rm -f "$(which cmake)";
sudo mkdir -p '/usr/local/bin';
echo "/usr/local/bin" >> "${GITHUB_PATH}";
python3 -m pip install --upgrade cmake >/dev/null && echo -e "\n####################\ncmake pip dependencies installed\n####################" || echo -e '::error::No cmake pip installed for project checks';
sudo cp -pf "${HOME}/.local/bin/cmake" '/usr/local/bin/';
fi;
if ${{ inputs.project }} && ${{ inputs.source == '5' }}; then
go build ${{ github.action_path }}/scripts/cmakebar.go && echo -e "\n####################\ncmakebar dependencies installed\n####################" || echo -e '::error::No cmakebar installed for project checks';
[[ -e "cmakebar" ]] && sudo cp -f 'cmakebar' '/usr/local/bin/'
fi;
if ${{ inputs.project }} && [[ ! $(apt list linux-headers-generic >/dev/null 2>&1) ]]; then
sudo apt-get -yq install linux-headers-generic 2>&1 >/dev/null | sed '/Running/,/host./d' && echo -e "####################\nDependencies $(apt list linux-headers-generic 2>/dev/null)\n####################" || echo -e "::warning::No linux-headers-generic installed for project build";
fi;
if [[ ! $(which git) ]]; then
sudo apt-get -yq install git git-core 2>&1 >/dev/null | sed '/Running/,/host./d' && echo -e "${text0}" || echo -e '::error::No git installed for repo updates';
[[ ! $(which git) ]] && exit 1
fi;
if [[ ! $(which fdfind) ]] && (${{ inputs.project }} || ${{ inputs.source > '0' }}); then
sudo apt-get -yq install fd-find 2>&1 >/dev/null | sed '/Running/,/host./d' && echo -e "####################\nfd dependencies installed\n####################" || echo -e '::error::No fdfind installed for file searches';
[[ ! $(which fdfind) ]] && echo -e '::error::[No fdfind found]\n';
fi;
if [[ ! $(which gcc) ]] || [[ ! $(which g++) ]] && ${{ inputs.repair }} && ${{ inputs.filename != '' }}; then
sudo apt-get -yq install gcc g++ 2>&1 >/dev/null | sed '/Running/,/host./d' && echo -e "####################\ngcc g++ dependencies installed\n####################" || echo -e '::error::No gcc or g++ installed for repo updates';
[[ ! $(which gcc) ]] || [[ ! $(which g++) ]] && exit 1
fi;
if ${{ inputs.project }} && [[ ! $(llvm-config --version 2>/dev/null) ]]; then
sudo bash -c "$(sudo wget -qO - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - >/dev/null 2>&1)"
sudo bash -c "$(sudo wget -qO - https://apt.llvm.org/llvm.sh | sudo bash -s -- 21 >/dev/null 2>&1)"
sudo add-apt-repository "deb http://apt.llvm.org/$(lsb_release -cs)/ llvm-toolchain-$(lsb_release -cs) main" >/dev/null;
sudo apt-get -yq install lld llvm llvm-dev liblldb-dev libclang-dev 2>&1 >/dev/null | sed '/Running/,/host./d' && echo -e "####################\nllvm tools dependencies installed\n####################" || echo -e '::error::No llvm tools installed for project build';
sudo apt-get -yq install clang-tools clang-tidy 2>&1 >/dev/null | sed '/Running/,/host./d' && echo -e "${text5}" || echo -e '::error::No clang-tools installed';
[[ ! $(llvm-config --version 2>/dev/null) ]] && exit 1
fi;
if (${{ inputs.project }} || [[ "${file_type}" == [cth]* ]]) && [[ ! $(which clang-tidy) ]]; then
python3 -m pip install clang-tools >/dev/null && clang-tools --install latest --directory /usr/bin >/dev/null && echo -e "\n####################\nclang tools pip dependencies installed\n####################\n" || echo -e '::error::No clang tools installed for project check'; # Adjust directory as needed
[[ ! -e '/usr/bin/clang-tidy' ]] && [[ -e "${HOME}/.local/bin/clang-tidy" ]] && sudo mv -vf "${HOME}/.local/bin/clang-tidy" '/usr/bin/clang-tidy'
[[ -e "${HOME}/.local/bin/run-clang-tidy" ]] && sudo mv -vf "${HOME}/.local/bin/run-clang-tidy" '/usr/bin/run-clang-tidy'
[[ ! $(which clang-tidy) ]] && exit 1
fi;
if ${{ inputs.analyzer == '1' }} && ${{ inputs.project }} && [[ $(which run-clang-tidy) ]]; then
echo -e "\n[clang-tools] $(whereis -b run-clang-tidy)";
[[ $(whereis clang-format) ]] && echo -e "\n[clang-tools]: $(whereis -b clang-format)" || echo -e '::error::No clang-format pip installed for project checks';
[[ $(whereis clang-apply-replacements) ]] && echo -e "\n[clang-tools]: $(whereis -b clang-apply-replacements)" || echo -e '::error::No clang-apply-replacements pip installed for project checks';
echo 'run_clang_tidy=run-clang-tidy' >> "${GITHUB_ENV}";
elif ${{ inputs.analyzer == '1' }} && ${{ inputs.project }}; then
echo -e "\n[clang-tools] run-clang-tidy: /scripts/tools/run-clang-tidy.py" || echo -e '::error::No run-clang-tidy.py pip installed for project checks';
[[ $(whereis clang-format) ]] && echo -e "\n[clang-tools]: $(whereis -b clang-format)" || echo -e '::error::No clang-format pip installed for project checks';
[[ $(whereis clang-apply-replacements) ]] && echo -e "\n[clang-tools]: $(whereis -b clang-apply-replacements)" || echo -e '::error::No clang-apply-replacements pip installed for project checks';
echo "run_clang_tidy=${{ github.action_path }}/scripts/tools/run-clang-tidy.py" >> "${GITHUB_ENV}";
fi;
if ${{ inputs.project }} && ${{ inputs.analyzer == '3' }} && [[ ! $(which clangd-tidy) ]]; then
python3 -m pip install --upgrade clangd-tidy >/dev/null && echo -e "\n####################\nclangd-tidy dependencies installed\n####################" || echo -e '::error::No clangd-tidy installed for project checks';
sudo apt-get -yq install clangd 2>&1 >/dev/null | sed '/Running/,/host./d' && echo -e "\n####################\nclangd pip dependencies installed\n####################" || echo -e '::error::No clangd pip installed for project checks';
if [[ $(which clangd-tidy) ]]; then
echo -e "\nclangd-tidy path: $(which clangd-tidy)\n";
else
exit 1
fi;
fi;
if (${{ inputs.analyzer == '4' }} || ${{ inputs.build == '1' }} || ${{ inputs.build == '2' }}) && [[ ! $(which CodeChecker) ]]; then
sudo apt-get -yq install python3-pip python3-venv 2>&1 >/dev/null | sed '/Running/,/host./d' && echo -e "\n####################\npython3-pip dependencies installed\n####################" || echo -e '::error::No python3-pip installed for project checks';
python3 -m pip install --upgrade codechecker >/dev/null && echo -e "\n####################\ncodechecker dependencies installed\n####################" || echo -e '::error::No codechecker installed for project checks';
sudo mkdir -p "/home/runner/codechecker/venv/include";
sudo mkdir -p "/home/runner/codechecker/venv/bin";
sudo chown -R "${USER}:${USER}" /home/runner/codechecker/
cd "/home/runner/codechecker/venv";
python3 -m venv .
cd "${github}";
if [[ $(which CodeChecker) ]]; then
echo -e "\nCodeChecker path: $(which CodeChecker)";
else
exit 1
fi;
fi;
if ${{ inputs.project }} && ${{ inputs.build > '2' }} && [[ ! $(which deheader) ]]; then
sudo apt-get -yq install deheader 2>&1 >/dev/null | sed '/Running/,/host./d' && echo -e "####################\ndeheader dependencies installed\n####################" || echo -e '::error::No deheader installed for project includes check';
[[ ! $(which deheader) ]] && exit 1
fi;
if ${{ inputs.project }} && [[ ! $(dpkg -s build-essential 2>/dev/null) ]]; then
sudo apt-get -yq install build-essential device-tree-compiler 2>&1 >/dev/null | sed '/Running/,/host./d' && echo -e "####################\nbuild-essential dependencies installed\n####################" || echo -e '::error::No build-essential installed for project build';
fi;
if ${{ inputs.project }} && ${{ inputs.analyzer == 3 }} && [[ ! $(which tqdm) ]]; then
python3 -m pip install tqdm >/dev/null && echo -e "\n####################\ntqdm dependencies installed\n####################\n" || echo -e '::warning::No tpdm installed for project progress checks';
[[ ! $(which tqdm) ]] && exit 1
fi;
if (${{ inputs.pattern != '' }} || ${{ inputs.database }} || ${{ inputs.source > '0' }}) && [[ ! $(which rg) ]]; then
sudo apt-get -yq install ripgrep 2>&1 >/dev/null | sed '/Running/,/host./d' && echo -e "${text1}" || echo -e '::error::No ripgrep installed for pattern matching';
[[ ! $(which rg) ]] && exit 1
fi;
if ${{ inputs.report }} && [[ ! $(which ansi2txt) ]]; then
sudo apt-get -yq install ansi2txt 2>&1 >/dev/null | sed '/Running/,/host./d' && echo -e "${text2}" || echo -e '::error::No ansi2txt installed for cleaning log report';
fi;
if [[ "${file_type}" == [cth]* ]] && [[ ! $(which cppcheck) ]]; then
sudo apt-get -yq install cppcheck 2>&1 >/dev/null | sed '/Running/,/host./d' && echo -e "${text4}" || echo -e '::error::No cppcheck installed Exiting';
[[ ! $(which cppcheck) ]] && exit 1
fi;
if [[ "${file_type}" == [sh] ]] && ${{ inputs.repair }} && [[ ! $(which shellharden) ]]; then
sudo wget -qO 'shellharden.tar.gz' 'https://github.com/anordal/shellharden/releases/latest/download/shellharden-x86_64-unknown-linux-gnu.tar.gz' >/dev/null;
sudo tar xf 'shellharden.tar.gz' -C '/usr/local/bin' 'shellharden' && rm -vrf 'shellharden.tar.gz' && echo -e "${text6}" || echo -e '::error::No shellharden installed Exiting';
[[ ! $(which shellharden) ]] && exit 1
fi;
if [[ "${file_type}" == [sh] ]] && [[ ! $(which shellcheck) ]]; then
sudo apt-get -yq install shellcheck 2>&1 >/dev/null | sed '/Running/,/host./d' && echo -e "${text7}" || echo -e '::error::No shellcheck installed Exiting';
[[ ! $(which shellcheck) ]] && exit 1
fi;
checkmake_src='checkmake.ini';
checkmake_des="${HOME}/checkmake.ini";
if [[ "${checkmake_src}" ]] && [[ -n $(echo "${file_type}" | LC_ALL=C grep -E "^mk$|.*Makefile$") ]] && [[ $(which checkmake) ]]; then
sudo cp -vf "${checkmake_src}" "${checkmake_des}" 2>/dev/null;
elif [[ -n $(echo "${file_type}" | LC_ALL=C grep -E "^mk$|.*Makefile$") ]] && [[ $(which checkmake) ]]; then
echo -e '\ncheckmake.ini file missing, needed for checkmake to function properly\n';
fi;
if [[ "${checkmake_src}" ]] && [[ -n $(echo "${file_type}" | LC_ALL=C egrep -i "^mk$|.*Makefile$") ]] && [[ ! $(which checkmake) ]]; then
go install "github.com/checkmake/checkmake/cmd/checkmake@latest" >/dev/null && echo -e "\n${text8}\n" || echo -e '::error::No checkmake installed Exiting';
sudo cp -vf "${checkmake_src}" "${checkmake_des}" 2>/dev/null;
[[ ! $(which checkmake) ]] && exit 1
fi;
if ${{ inputs.filename != '' }} || ${{ inputs.pattern != '' }}; then
if [[ $(which bat) ]] && [[ ! $(which batcat) ]]; then
sudo ln -sf "$(which bat)" /usr/bin/batcat >/dev/null || echo -e '::error::No batcat installed Exiting';
[[ ! $(which batcat) ]] && exit 1
echo -e "\nalias batcat='bat'" | sudo tee -a ~/.bashrc >/dev/null;
echo 'export BAT_THEME=ansi' | sudo tee -a ~/.bashrc >/dev/null;
elif [[ ! $(which batcat) ]]; then
sudo apt-get -yq install bat 2>&1 >/dev/null | sed '/Running/,/host./d' && echo -e "${text9}" || echo -e '::error::No batcat installed Exiting';
[[ ! $(which batcat) ]] && exit 1
echo 'export BAT_THEME=ansi' | sudo tee -a ~/.bashrc >/dev/null;
fi;
fi;
echo "update=${{ inputs.update }}" >> "${GITHUB_ENV}";
if [[ -d '/usr/local/bin' ]]; then
echo '/usr/local/bin' >> "${GITHUB_PATH}";
fi;
if [[ -d "${HOME}/.local/bin" ]]; then
echo "${HOME}/.local/bin" >> "${GITHUB_PATH}";
fi;
if [[ -d "${HOME}/codechecker/build/CodeChecker/bin" ]]; then
echo "${HOME}/codechecker/build/CodeChecker/bin" >> "${GITHUB_PATH}";
fi;
if ${{ inputs.build > '0' }}; then
echo 'github_build_project=true' >> "${GITHUB_ENV}";
else
echo 'github_build_project=false' >> "${GITHUB_ENV}";
fi;
sudo apt-get --fix-broken install -yq 2>&1 >/dev/null | sed '/Running/,/host./d';
echo '';
shell: bash
continue-on-error: false
- name: Set Directory Base
if: inputs.pattern != '' || inputs.filename != '' || inputs.project == 'true' || inputs.source > '0'
run: |
echo '';
repair_file='check-file-repaired.txt';
repo=$(echo ${{ github.repository }} | cut -d'/' -f 2-);
echo 'database=database' >> "${GITHUB_ENV}";
text1a="####################";
text1b="DEFAULT DIRECTORY (GITHUB ROOT)";
text1c="####################";
text2a="####################";
text2b="DEFAULT DIRECTORY (GITHUB WORKSPACE)";
text2c="####################";
text3a="####################";
text3b="Store repaired files Enabled";
text3c="####################";
text4="Creating ${repair_file} for checked files";
text5a="####################";
text5b="Database Performance Mode Enabled";
text5c="####################";
text6="::error::Database not found exiting";
text7a="####################";
text7b="Searching directories for ${{ inputs.filename }}) file(s)";
text7c="####################";
text8a="####################";
text8b="Searching ${{ inputs.filetype }} files for ${{ inputs.pattern }} match(s)";
text8c="####################";
text9a="####################";
text9b="Searching all files for ${{ inputs.pattern }} match(s)";
text9c="####################";
text10a="#####################";
text10b="#\033[1m\033[32m CHECK FILE ACTION \033[0m#";
text10c="#####################";
chmod -R 0755 "${{ github.action_path }}/scripts";
text() {
local text="$1";
echo -e "${text}";
}
if ${{ inputs.absolute }}; then
text "${text1a}";
text "${text1b}";
text "${text1c}";
echo -e '\nAbsolute Path Mode';
echo "base=${GITHUB_WORKSPACE}" >> "${GITHUB_ENV}";
echo 'github_absolute_path=true' >> "${GITHUB_ENV}";
base="${GITHUB_WORKSPACE}";
else
text "${text2a}";
text "${text2b}";
text "${text2c}";
echo -e "\nRelative Path Mode";
echo 'base=.' >> "${GITHUB_ENV}";
echo 'github_absolute_path=false' >> "${GITHUB_ENV}";
base='.'
fi;
if (${{ inputs.stored }} || ${{ env.update }}) && [[ -f "${repair_file}" ]]; then
repaired="${repair_file}";
if [[ -f ${repaired} ]]; then
text "\n${text3a}";
text "${text3b}";
text "${text3c}";
else
text "\n${text4a}";
text "${text4b}";
text "${text4c}";
date '+%Y%m%d' > "${repaired}" || echo -e "::warning::${repaired} backup file not found";
fi;
fi;
if ${{ inputs.database }}; then
sudo find "${base}" -not \( -path "*/build/*" -prune -o -path "*/.git/*" -prune \) -type f -print | sort -t/ -k1.2 > 'database';
if [[ -s 'database' ]]; then
text "\n${text5a}";
text "${text5b}";
text "${text5c}";
echo 'database=database' >> "${GITHUB_ENV}";
else
text "\n${text5a}";
text "${text6}";
text "${text5c}";
fi;
fi;
if ${{ inputs.filename != '' }}; then
text "\n${text7a}";
text "${text7b}";
text "${text7c}";
fi;
if ${{ inputs.pattern != '' }} && ${{ inputs.filetype != '' }}; then
text "\n${text8a}";
text "${text8b}";
text "${text8c}";
elif ${{ inputs.pattern != '' }}; then
text "\n${text9a}";
text "${text9b}";
text "${text9c}";
fi;
dirname=${{ inputs.dirname }};
echo "dirname=${dirname}" >> "${GITHUB_ENV}";
if ${{ inputs.project }} && ${{ inputs.filename != '' }} && ${{ inputs.analyzer > '0' }}; then
text "::warning:: project:true and filename:set both enabled auto sets analyzer:0 to disable\nTo remove this warning use ( analyzer: 0 )\n";
echo "analyzer=0" >> "${GITHUB_ENV}";
else
echo "analyzer=${{ inputs.analyzer }}" >> "${GITHUB_ENV}";
fi;
if ${{ inputs.recovery == 'false' }} && ${{ inputs.dirname != '' }}; then
cd "${{ inputs.dirname }}";
fi;
src=$(ls);
type_count=0
total_files=$(find -type f | grep -v '\.git/.' | wc -l);
file_type0=$(find -type f -name "*.${{ inputs.filetype }}" | grep -v '\.git/.' | wc -l);
file_type1=$(find -type f \( -name '*.c' -o -name '*.cc' -o -name '*.cpp' -o -name '*.c++' -o -name '*.tpp' \) | grep -v '\.git/.' | wc -l);
file_type2=$(find -type f \( -name '*.h' -o -name '*.hh' -o -name '*.hpp' -o -name '*.h++' \) | grep -v '\.git/.' | wc -l);
percentage0=$(echo "scale=2; (${file_type0:-0} / ${total_files:-0}) * 100" | bc);
percentage1=$(echo "scale=2; (${file_type1:-0} / ${total_files:-0}) * 100" | bc);
percentage2=$(echo "scale=2; (${file_type2:-0} / ${total_files:-0}) * 100" | bc);
include_dirs=$(find -type d -name 'include' -print | awk '{ print length($0), $0 }' | sort -n | cut -d' ' -f 2- 2>/dev/null | wc -l);
file_count() {
find -type f | grep -iEo '\_[[:alnum:]]+$|\-[[:alnum:]]+$|\.[[:alnum:]]+$|[[:alnum:]]+$' | tr -d '_\-\.' | sort | uniq -c | sed 's/^ *//' | while IFS= read -r file; do
echo "${file} files"
done;
}
directory() {
for dir in ${src[@]}; do
if [ -d "${dir}" ]; then
count=$(find "${dir}" -type f | wc -l);
echo "${dir}: ${count} files";
fi;
done;
}
file_types() {
type_count=0
while IFS= read -r file; do
type_count=$(expr ${type_count} + 1);
done < <(file_count);
echo "${type_count}";
}
if ${{ inputs.content }}; then
if [[ "$(directory)" ]]; then
echo -e "\n#####################\nProject Source Directories:\n#####################\n\n$(directory)";
fi;
if [[ "$(file_count)" ]]; then
echo -e "\n#####################\nProject File Types:\n#####################\n\n$(file_count)";
fi;
if [[ "$(file_types)" ]]; then
echo -e "\n#####################\nDifferent File Types: \033[1m$(file_types)\033[0m\n#####################";
fi;
if [[ "${include_dirs}" ]]; then
echo -e "\n#####################\nTotal Include Directories: \033[1m${include_dirs}\033[0m\n#####################";
fi;
if [[ "${total_files:-0}" > '0' ]] && ${{ inputs.filetype != '' }}; then
echo -e "\nThe total percentage of ${{ inputs.filetype }} files is: \033[1m${percentage0:-0}%\033[0m";
echo -e "\nThe total percentage of header files is: \033[1m${percentage2:-0}%\033[0m";
echo -e "\n#####################\nRepository: \033[1m${repo}\033[0m\n#####################\n\nProject has \033[1m${total_files}\033[0m files total";
elif [[ "${total_files:-0}" > '0' ]]; then
echo -e "\nThe total percentage of c/c++ files is: \033[1m${percentage1:-0}%\033[0m";
echo -e "\nThe total percentage of header files is: \033[1m${percentage2:-0}%\033[0m";
echo -e "\n#####################\nRepository: \033[1m${repo}\033[0m\n#####################\n\nProject has \033[1m${total_files}\033[0m files total";
else
echo -e "\n#####################\n::error::Repository: ${repo} files missing? Exiting....\n#####################\n";
fi;
fi;
text "\n${text10a}" 2>/dev/null;
text "${text10b}" 2>/dev/null;
text "${text10c}\n" 2>/dev/null;
echo "github_repository=${repo}" >> "${GITHUB_ENV}";
echo "filetype=${{ inputs.filetype }}" >> "${GITHUB_ENV}";
echo 'sources=false' >> "${GITHUB_ENV}";
echo 'file_fixed=0' >> "${GITHUB_ENV}";
echo 'file_found=0' >> "${GITHUB_ENV}";
echo 'file_error=0' >> "${GITHUB_ENV}";
echo 'file1_parted=0' >> "${GITHUB_ENV}";
echo 'file2_parted=0' >> "${GITHUB_ENV}";
echo 'build_cache=false' >> "${GITHUB_ENV}";
echo 'check_build=false' >> "${GITHUB_ENV}";
shell: bash
continue-on-error: false
- name: Source Includes Fixer A
if: inputs.source == '1' || inputs.source == '2'
run: |
echo '';
set +e
start_time="${SECONDS}";
file_name="${{ inputs.filename }}";
file_type="${file_name##*.}";
repository=$(echo ${{ github.repository }} | cut -d'/' -f 2-);
project_log="${repository}_project.log";
export LC_ALL=C
export LS_COLORS
SAVEIFS="${IFS}";
include_missing=1
include_count=1
include_total=1
include_dirs=1
file_count=1
count1=0
count2=0
count3=0
count4=0
count5=0
checked=false
source_include=false
includes_found=false
include1='include-file1.txt';
include2='include-file2.txt';
include3='include-file3.txt';
include_list='check-file-sources.txt';
name_count_file='name-count-file.txt';
include_count_file='include-count-file.txt';
github="${GITHUB_WORKSPACE}";
process_input() {
while IFS= read -r output; do
if ${{ inputs.output == '1' }}; then
echo -e "${output}" | tee -a "${project_log}";
elif ${{ inputs.output == '2' }}; then
echo -e "${output}" >> "${project_log}";
elif ${{ inputs.output == '3' }}; then
echo -e "${output}";
elif ${{ inputs.output == '4' }}; then
echo -e "${output}" >/dev/null;
fi;
done;
}
if ${{ inputs.absolute }}; then
abs='-a';
else
abs='';
fi;
echo -e "####################\n\t\033[33mPROGRESSIVE SCAN MODE\033[0m\n####################" | process_input;
include_files1=$(fdfind -p -c auto "${abs}" -e "${{ inputs.filetype }}" "${{ env.base }}" | awk -F'/' '{print $NF, $0}' | sort -k1,1 | cut -d' ' -f2-);
include_files2=$(fdfind -p -c auto "${abs}" -e "${{ inputs.filetype }}" "${{ env.base }}" | LC_ALL=C xargs -r rg --sort=path --trim -H -o '^#include[[:space:]]+["].*["]' | tr -d '<">' | awk '{ print $NF, $0 }' | sort -k1,1 -us | cut -d' ' -f2-);
[[ -f "${include_list}" ]] && mv -f "${include_list}" "${include_list}.old";
[[ -f "${include1}" ]] && rm -f "include-file*.txt";
[[ -f "${name_count_file}" ]] && rm -f "${name_count_file}";
[[ -f "${include_count_file}" ]] && rm -f "${include_count_file}";
if [[ "${{ inputs.filetype }}" == [c]* ]] && ${{ inputs.source == '1' }} && [[ "${include_files1}" ]]; then
declare -A processed
declare -A missing
echo -e "\n\033[32mCheck-File discovered include objectives running full scan now: \033[0m\033[1mContent Display\033[0m [\033[1m verbose \033[0m]" | process_input;
echo -e "\n####################\nCheck-File Auto Fix Sources Include [ Status: \033[32mAnalzying\033[0m ]\n####################" | process_input;
while IFS= read -r file; do
include_count=1
count1=$((file_count++));
echo -e "\n####################\n\t\033[33mSOURCE FILE\033[0m ( ${count1} )\n####################" | process_input;
echo -e "\nSource File Location: ${file}" | process_input;
echo -e "\nAnalyzing Includes Source File ${count1}: ${file##*/}" | process_input;
if ${{ inputs.include }}; then
includes_found=false
include_source=$( { rg --sort=path --trim -o '^#include[[:space:]]+["].*["]' "${file}" 2>/dev/null || true; } | awk '{print $2}' | tr -d '<">' | sort -u);
if [[ "${include_source}" ]]; then
echo -e "\n\tinclude file objectives:\n\n${include_source}" | process_input;
while IFS= read -r include; do
if [[ "${include}" == *.[ch]* ]] && [[ ! "${processed[$include]}" ]]; then
processed["$include"]=1
path1="${include##+(*./)}";
path2="${path1##[:]*}";
path3="${path2%'\n'}";
path4="${path3%\\}";
clean_path="${path4%/*}";
file1="${include##+(*./)}";
file2="${file1##[:]*}";
file3="${file2%'\n'}";
file4="${file3%\\}";
clean_file="${file4##*/}";
if [[ ${include} == *"/"* ]]; then
shopt -s extglob
header=$(fdfind -c auto "${abs}" -p -t f -g "**/${path4##+(*./)}" "${{ env.base }}");
shopt -u extglob
else
header=$(fdfind -c auto "${abs}" -p -t f "${clean_file##+(*./)}" "${{ env.base }}");
fi;
if [[ -n "${header}" ]]; then
while IFS= read -r includes; do
count2=$((include_count++));
count3=$((include_total++));
echo "${includes%/*}" >> "${include1}";
echo -e "\n\033[33mSource file #include \033[0m\033[1m( ${includes##*/} )\033[0m\033[33m is located!\033[0m [ ✅ ]\n\n\033[32mREAL FILE LOCATION:\033[0m ${includes}" | process_input;
done <<< "${header[@]}";
includes_found=true
elif [[ -n "${missing[$include]}" ]]; then
echo -e "\n\033[33mSource file #include \033[0m( ${include} )\033[33m already listed missing!\033[0m [\033[1m skipped \033[0m]" | process_input;
includes_found=false
else
includes_found=false
missing["${include}"]=1
count5=$((include_missing++));
echo -e "\n::notice::\033[31mSource file #include \033[0m( ${file4##+(*./)} )\033[31m is missing!?\033[0m [ ❌ ]" | process_input;
fi;
elif [[ -n "${processed[$include]}" ]]; then
echo -e "\n\033[34mSource file #include \033[0m( ${include} )\033[34m already added to includes list!\033[0m [\033[1m skipped \033[0m]" | process_input;
fi;
done <<< "${include_source[@]}";
fi;
if [[ "${includes_found}" ]]; then
echo -e "\n${count2}\033[32m include file objectives confirmed added after scanning file: \033[0m\033[1m${file##*/}\033[0m [ ✅ ]" | process_input;
elif [[ -z "${include_source}" ]]; then
echo -e "\n\033[33mNo include file objectives confirmed after scanning file: \033[0m\033[1m${file##*/}\033[0m [ 🚫 ]" | process_input;
else
echo -e "\n${count5}\033[33m include file objectives confirmed missing after scanning file: \033[0m\033[1m${file##*/}\033[0m [ ❌ ]" | process_input;
fi;
fi;
done <<< "${include_files1[@]}";
if [[ -s "${include1}" ]]; then
awk '!seen[$0]++' "${include1}" > "${include_list}";
fi;
if [[ -s "${include_list}" ]]; then
count4=$(awk 'NF > 0 { count++ } END { print count }' "${include_list}");
fi;
echo -e "\n::notice::\033[32mTotal source file checked during scan\033[0m\033[1m ${count1}\033[0m" | process_input;
if [[ "${includes_found}" ]]; then
echo 'check_build=true' >> "${GITHUB_ENV}";
echo -e "\n::notice::\033[34mTotal include source file added during scan\033[0m\033[1m ${count3}\033[0m\n[Hint] \033[1m${count4}\033[0m included directories added after duplicate cleaning!!!\033[0m\nSet option (\033[1m cache: true \033[0m) to use this list for source include checks without manually downloading an adding the file to your repo\n With cache you should set (\033[1m source: 0 \033[0m)running sources again each check!" | process_input;
else
echo -e '\n::notice::\033[31mNo include objectives discovered or check-file encountered an issue!!!\033[0m' | process_input;
fi;
if [[ "${count5}" > '0' ]]; then
echo -e "\n::notice::\033[34m⚠️ Total include source files missing during scan\033[0m\033[1m ${count5}\033[0m\n[Hint] Many source files may call these \033[31mmissing include files.\nYou may need to remove the missing include file objectives or added the file before compiling!!!" | process_input;
fi;
unset processed;
unset missing;
[[ -s "${include_list}" ]] && mkdir -p build && echo -e "\nSaving list to build: $(cp -vf ${include_list} build/)" | process_input;
seconds=$((SECONDS - start_time));
m=$((seconds / 60));
s=$((seconds % 60));
printf "Project Auto Include Runtime: %d minutes and %d seconds\n" "$m" "$s" | process_input;
elif [[ "${{ inputs.filetype }}" == [c]* ]] && ${{ inputs.source == '2' }} && [[ "${include_files2}" ]]; then
echo -e "\n\033[32mCheck-File discovered include objectives running full scan now: \033[0m\033[1mContent Display\033[0m [\033[33m medium \033[0m]" | process_input;
echo -e "\n####################\nCheck-File Auto Fix Sources Include [ Status: \033[32mAnalzying\033[0m ]\n####################" | process_input;
echo > "${name_count_file}";
declare -A processed
while IFS= read -r file; do
name="${file%%:*}";
name_count="${name##*/}";
if [[ $(LC_ALL=C grep -s "${name_count}" "${name_count_file}") ]]; then
echo -e "\nAnalyzing Source File: ${name##*/}" | process_input;
else
count1=$((file_count++));
echo "${name_count}" >> "${name_count_file}";
echo -e "\n####################\n\t\033[33mSOURCE FILE\033[0m ( ${count1} )\n####################" | process_input;
echo -e "\nSource File Location: ${file%%:*}" | process_input;
echo -e "\nChecking include objective in source file: ${name##*/} [ \033[1m${count1}\033[0m ]" | process_input;
fi;
includes_found=false
include_source=$(echo "${file}" | awk '{print $2}');
if [[ "${include_source}" ]]; then
includes_found=true
echo -e "\n\tinclude source: ${include_source}" | process_input;
if [[ "${include_source}" == *.[h]* ]]; then
path1="${include_source##+(*./)}";
path2="${path1##[:]*}";
path3="${path2%'\n'}";
path4="${path3%\\}";
clean_path="${path4%/*}";
file1="${include_source##+(*./)}";
file2="${file1##[:]*}";
file3="${file2%'\n'}";
file4="${file3%\\}";
clean_file="${file4##*/}";
if [[ ${include_source} == *"/"* ]]; then
shopt -s extglob
header=$(fdfind -c auto "${abs}" -p -t f -g "**/${path4##+(*./)}" "${{ env.base }}");
shopt -u extglob
else
header=$(fdfind -c auto "${abs}" -p -t f "${clean_file##+(*./)}" "${{ env.base }}");
fi;
includes_missing=false
if [[ -n "${header}" ]]; then
while IFS= read -r includes; do
count2=$((include_count++));
count3=$((include_total++));
echo "${includes%/*}" >> "${include1}";
echo -e "\n\033[33mSource file include \033[0m\033[1m( ${includes##*/} )\033[0m\033[33m is located!\033[0m [ ✅ ]\n\n\033[32mREAL FILE LOCATION:\033[0m ${includes}" | process_input;
done <<< "${header[@]}";
elif [[ -n "${processed[$include_source]}" ]]; then
echo -e "\n\033[33mSource file #include \033[0m( ${include_source} )\033[33m already listed missing!\033[0m [\033[1m skipped \033[0m]" | process_input;
else
includes_missing=true
processed["${include_source}"]=1
count5=$((include_missing++));
echo -e "\n::notice::\033[31mSource file include \033[0m( ${file4##+(*./)} )\033[31m is missing!?\033[0m [ ❌ ]" | process_input;
fi;
fi;
fi;
if [[ "${includes_found}" == 'true' ]]; then
echo -e "\n${count2}\033[32m includes successfully added after scanning file: \033[0m\033[1m${name##*/}\033[0m [ ✅ ]" | process_input;
source_include=true
elif [[ "${includes_missing}" == 'true' ]]; then
echo -e "\n\033[32mCheck-File discovered missing include objective after scanning file: \033[0m\033[1m${name##*/}\033[0m [ ❌ ]" | process_input;
elif [[ -z "${include_source}" ]]; then
echo -e "\n\033[32mCheck-File discovered no include objective after scanning file: \033[0m\033[1m${name##*/}\033[0m [ 🚫 ]" | process_input;
fi;
done <<< "${include_files2[@]}";
if [[ -s "${include1}" ]]; then
awk '!seen[$0]++' "${include1}" > "${include_list}";
fi;
if [[ -s "${include_list}" ]]; then
count4=$(awk 'NF > 0 { count++ } END { print count }' "${include_list}");
fi;
echo -e "\n::notice::\033[32mTotal source files checked during scan\033[0m\033[1m ${count1}\033[0m" | process_input;
if [[ "${includes_found}" ]]; then
echo 'check_build=true' >> "${GITHUB_ENV}";
echo -e "\n::notice::\033[34mTotal include source file added during scan\033[0m\033[1m ${count3}\033[0m\n[Hint] \033[1m${count4}\033[0m included directories added after duplicate cleaning!!!\033[0m\nSet option (\033[1m cache: true \033[0m) to use this list for source include checks without manually downloading an adding the file to your repository\nWith caching you should then set (\033[1m source: 0 \033[0m) before checking sources again!" | process_input;
else
echo -e '\n::notice::\033[31mNo include objectives discovered or check-file encountered an issue!!!\033[0m' | process_input;
fi;
if [[ "${count5}" > '0' ]]; then
echo -e "\n::notice::\033[34m⚠️ Total include source files missing during scan\033[0m\033[1m ${count5}\033[0m\n[Hint] Many source files may call these \033[31mmissing include files.\nYou may need to remove the missing include file objectives or added the file before compiling!!!" | process_input;
fi;
unset processed;
[[ -s "${include_list}" ]] && mkdir -p build && echo -e "\nSaving list to build: $(cp -vf ${include_list} build/)" | process_input;
seconds=$((SECONDS - start_time));
m=$((seconds / 60));
s=$((seconds % 60));
printf "Project Auto Include Runtime: %d minutes and %d seconds\n" "$m" "$s" | process_input;
fi;
if [[ "${source_include}" == 'true' ]]; then
echo "include_count=${count4}" >> "${GITHUB_ENV}";
else
echo 'include_count=0' >> "${GITHUB_ENV}";
fi;
if ${{ inputs.number > '0' }}; then
echo 'include_source=false' >> "${GITHUB_ENV}";
elif [[ "${count4}" > '2000' ]]; then
echo 'include_source=true' >> "${GITHUB_ENV}";
else
echo 'include_source=false' >> "${GITHUB_ENV}";
fi;
echo '';
shell: bash
continue-on-error: true
- name: Source Includes Fixer B
if: inputs.source == '3' || inputs.source == '4'
run: |
echo '';
set +e
start_time="${SECONDS}";
file_name="${{ inputs.filename }}";
file_type="${file_name##*.}";
repository=$(echo ${{ github.repository }} | cut -d'/' -f 2-);
project_log="${repository}_project.log";
export LC_ALL=C
export LS_COLORS
SAVEIFS="${IFS}";
include_missing=1
include_count=1
include_total=1
include_dirs=1
file_count=1
count1=0
count2=0
count3=0
count4=0
count5=0
checked=false
source_include=false
includes_found=false
include1='include-file1.txt';
include2='include-file2.txt';
include3='include-file3.txt';
include_list='check-file-sources.txt';
name_count_file='name-count-file.txt';
include_count_file='include-count-file.txt';
github="${GITHUB_WORKSPACE}";
process_input() {
while IFS= read -r output; do
if ${{ inputs.output == '1' }}; then
echo -e "${output}" | tee -a "${project_log}";
elif ${{ inputs.output == '2' }}; then
echo -e "${output}" >> "${project_log}";
elif ${{ inputs.output == '3' }}; then
echo -e "${output}";
elif ${{ inputs.output == '4' }}; then
echo -e "${output}" >/dev/null;
fi;
done;
}
if ${{ inputs.absolute }}; then
abs='-a';
else
abs='';
fi;
echo -e "####################\n\t\033[33mPROGRESSIVE SCAN MODE\033[0m\n####################" | process_input;
include_files3=$(fdfind -p -c auto "${abs}" -e "${{ inputs.filetype }}" "${{ env.base }}" | LC_ALL=C xargs -r rg --sort=path --trim -o '^#include[[:space:]]+["].*["]' | awk '{print $2}' | tr -d '<">' | sort -u);
include_files4=$(fdfind -p -c auto "${abs}" -e "${{ inputs.filetype }}" "${{ env.base }}" | awk -F'/' '{print $NF, $0}' | sort -k1,1 | cut -d' ' -f2-);
[[ -f "${include_list}" ]] && mv -f "${include_list}" "${include_list}.old";
[[ -f "${include1}" ]] && rm -f "include-file*.txt";
[[ -f "${name_count_file}" ]] && rm -f "${name_count_file}";
[[ -f "${include_count_file}" ]] && rm -f "${include_count_file}";
if [[ "${{ inputs.filetype }}" == [c]* ]] && ${{ inputs.source == '3' }} && [[ "${include_files3}" ]]; then
echo -e "\n\033[32mCheck-File discovered include objectives running full scan now: \033[0m\033[1mContent Display\033[0m [\033[35m low \033[0m]" | process_input;
echo -e "\n####################\nCheck-File Auto Fix Sources Include [ Status: \033[32mAnalzying\033[0m ]\n####################" | process_input;
declare -A processed
while IFS= read -r include; do
if [[ "${include}" == *.[h]* ]]; then
path1="${include##+(*./)}";
path2="${path1##[:]*}";
path3="${path2%'\n'}";
path4="${path3%\\}";
clean_path="${path4%/*}";
file1="${include##+(*./)}";
file2="${file1##[:]*}";
file3="${file2%'\n'}";
file4="${file3%\\}";
clean_file="${file4##*/}";
if [[ ${include} == *"/"* ]]; then
shopt -s extglob
header=$(fdfind -p -c auto "${abs}" -t f -g "**/${path4##+(*./)}" "${{ env.base }}");
shopt -u extglob
else
header=$(fdfind -p -c auto "${abs}" -t f "${clean_file##+(*./)}" "${{ env.base }}");
fi;
if [[ "${header}" ]]; then
while IFS= read -r includes; do
count2=$((include_count++));
echo "${includes%/*}" >> "${include1}";
done <<< "${header[@]}";
includes_found=true
elif [[ -n "${processed[$include]}" ]]; then
includes_found=false
echo -e "\n\033[33mSource file #include \033[0m( ${include} )\033[33m already listed missing!\033[0m [\033[1m skipped \033[0m]" | process_input;
else
includes_found=false
processed["$include"]=1
count5=$((include_missing++));
echo -e "\n::notice::\033[31mSource file #include \033[0m( ${include} )\033[31m is missing!?\033[0m [ ❌ ]" | process_input;
fi;
fi;
done <<< "${include_files3[@]}";
if [[ -s "${include1}" ]]; then
awk '!seen[$0]++' "${include1}" > "${include_list}";
fi;
if [[ -s "${include_list}" ]]; then
count4=$(awk 'NF > 0 { count++ } END { print count }' "${include_list}");
fi;
if [[ "${includes_found}" == 'true' ]]; then
source_include=true
echo 'check_build=true' >> "${GITHUB_ENV}";
echo -e "\n::notice::\033[34mTotal include source file added during scan\033[0m\033[1m ${count3}\033[0m\n[Hint] \033[1m${count4}\033[0m included directories added after duplicate cleaning!!!\033[0m\nSet option (\033[1m cache: true \033[0m) to use this list for source include checks without manually downloading an adding the file to your repo\n With cache you should set (\033[1m source: 0 \033[0m)running sources again each check!" | process_input;
else
echo -e '\n::notice::\033[31mNo include objectives discovered or check-file encountered an issue!!!\033[0m' | process_input;
fi;
if [[ "${count5}" > '0' ]]; then