46
46
run : sudo chown -R klocwork:klocwork .
47
47
48
48
- name : create local Klocwork project
49
- run : kwcheck create --project-dir /home/klocwork/.kwlp --settings-dir /home/klocwork/.kwps
49
+ run : |
50
+ mkdir -p /home/klocwork/parent
51
+ kwcheck create --project-dir /home/klocwork/parent/.kwlp --settings-dir /home/klocwork/parent/.kwps
50
52
51
53
- name : checkout base ref
52
54
uses : actions/checkout@v2
@@ -62,12 +64,16 @@ jobs:
62
64
run : kwinject --output kwinject.out ninja -C build -v -k0
63
65
64
66
- name : fully analyze build of base ref
65
- run : kwcheck run --build-spec kwinject.out -F scriptable --report issues .txt --project-dir /home/klocwork/.kwlp --settings-dir /home/klocwork/.kwps
67
+ run : kwcheck run --build-spec kwinject.out -F scriptable --report /home/klocwork/parent_issues .txt --project-dir /home/klocwork/parent/ .kwlp --settings-dir /home/klocwork/parent /.kwps
66
68
67
- - name : ignore issues of base ref
69
+ # Use non numeric sort because `comm` expects default sorting order
70
+ - name : get parent issue ids
71
+ run : awk -F ';' '{print $1}' /home/klocwork/parent_issues.txt | sort > /home/klocwork/parent_issues_ids.txt
72
+
73
+ - name : copy parent klocwork project
68
74
run : |
69
- count=$(wc -l < issues.txt)
70
- test "$count" = "0" || kwcheck set-status 1-"$count" --status ignore --project-dir /home/klocwork/.kwlp
75
+ mkdir -p /home/klocwork/child
76
+ cp -r /home/klocwork/parent/ .kwlp /home/klocwork/parent/.kwps /home/klocwork/child
71
77
72
78
- name : checkout head ref
73
79
uses : actions/checkout@v2
@@ -81,13 +87,31 @@ jobs:
81
87
run : kwinject --output kwinject.out ninja -C build -v -k0
82
88
83
89
- name : incrementally analyze build of head ref
84
- run : kwcheck run --build-spec kwinject.out -F scriptable --report issues.txt --project-dir /home/klocwork/.kwlp --settings-dir /home/klocwork/.kwps
90
+ run : kwcheck run --build-spec kwinject.out -F scriptable --report /home/klocwork/child_issues.txt --project-dir /home/klocwork/child/.kwlp --settings-dir /home/klocwork/child/.kwps
91
+
92
+ # Klocwork incremental scans will suppress the issues that were fixed in head ref (while preserving their issue id)
93
+ # Any new issue will have id will be larger than the max id in scan of base ref.
94
+ # For example, if base ref scan produced issue ids 1-5, and in head ref issue 4 was resolved but also introduced a new issue
95
+ # then the resulting issue ids for head ref scan will be 1,2,3,5,6.
96
+ - name : get child issue ids
97
+ run : awk -F ';' '{print $1}' /home/klocwork/child_issues.txt | sort > /home/klocwork/child_issues_ids.txt
98
+
99
+ - name : list issues fixed in head ref
100
+ run : |
101
+ FIXED_ISSUE_ID=$(comm -13 /home/klocwork/child_issues_ids.txt /home/klocwork/parent_issues_ids.txt | paste -sd,)
102
+ if [ -n "$FIXED_ISSUE_ID" ]
103
+ then
104
+ kwcheck list --id "$FIXED_ISSUE_ID" -F detailed --project-dir /home/klocwork/parent/.kwlp --settings-dir /home/klocwork/parent/.kwps
105
+ fi
85
106
86
107
- name : ensure no new issues have been found in head ref
87
108
run : |
88
- kwcheck list -F detailed --project-dir /home/klocwork/.kwlp --settings-dir /home/klocwork/.kwps
89
- size=$(stat --printf=%s issues.txt)
90
- test "$size" = "0"
109
+ NEW_ISSUE_ID=$(comm -13 /home/klocwork/parent_issues_ids.txt /home/klocwork/child_issues_ids.txt | paste -sd,)
110
+ if [ -n "$NEW_ISSUE_ID" ]
111
+ then
112
+ kwcheck list --id "$NEW_ISSUE_ID" -F detailed --project-dir /home/klocwork/child/.kwlp --settings-dir /home/klocwork/child/.kwps
113
+ fi
114
+ test -z "$NEW_ISSUE_ID"
91
115
92
116
- name : revert ownership of workspace to root
93
117
run : sudo chown -R root:root .
0 commit comments