Skip to content

Commit b16b673

Browse files
Set up GitHub actions, implemented dynamic suggestions and added commit ids to the repos in ground truth
2 parents 69c18fb + 1682587 commit b16b673

6 files changed

Lines changed: 503 additions & 205 deletions

File tree

.github/workflows/test-action.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Test Action
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
jobs:
10+
test-action:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@v4
15+
16+
- name: Run RsMetaCheck Action on self
17+
uses: ./
18+
with:
19+
# Automatically uses ${{ github.repository }} and checks it
20+
verbose: "false"
21+
env:
22+
# Provide token for SoMEF API rate limits (optional but recommended)
23+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
24+
25+
- name: Verify outputs are generated
26+
run: |
27+
if [ ! -d "somef_outputs" ]; then
28+
echo "somef_outputs directory not found!"
29+
exit 1
30+
fi
31+
if [ ! -d "pitfalls" ]; then
32+
echo "pitfalls directory not found!"
33+
exit 1
34+
fi
35+
if [ ! -f "all_pitfalls_results.json" ]; then
36+
echo "all_pitfalls_results.json not found!"
37+
exit 1
38+
fi
39+
echo "Output files verified successfully."

README.md

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,39 @@ pip install git+https://github.com/SoftwareUnderstanding/RsMetaCheck.git
6969

7070
## Usage
7171

72-
### Run the Detection Tool
72+
### GitHub Action
73+
74+
RsMetaCheck can be easily integrated into your CI/CD pipelines as a GitHub Action.
75+
76+
```yaml
77+
name: RsMetaCheck
78+
79+
on:
80+
push:
81+
branches: [main]
82+
pull_request:
83+
branches: [main]
84+
85+
jobs:
86+
check-metadata:
87+
runs-on: ubuntu-latest
88+
steps:
89+
- name: Checkout repository
90+
uses: actions/checkout@v4
91+
92+
- name: Run RsMetaCheck
93+
uses: SoftwareUnderstanding/RsMetaCheck@v0.2.1 # Update to the latest version tag
94+
with:
95+
# Optional: Include passed checks in output (defaults to false)
96+
verbose: "false"
97+
env:
98+
# Optional: Provide token for SoMEF API rate limits
99+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
100+
```
101+
102+
The action will generate `all_pitfalls_results.json`, along with the `pitfalls/` and `somef_outputs/` directories directly in your workflow workspace.
103+
104+
### Run the Detection Tool locally
73105

74106
#### Analyze a Single Repository
75107

action.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: "RsMetaCheck"
2+
description: "Detect metadata pitfalls and warnings in software repositories using SoMEF."
3+
author: "SoftwareUnderstanding"
4+
branding:
5+
icon: "check-circle"
6+
color: "blue"
7+
8+
inputs:
9+
repository_url:
10+
description: "URL of the repository to analyze. Defaults to the current GitHub workspace repository."
11+
required: false
12+
default: "https://github.com/${{ github.repository }}"
13+
branch:
14+
description: "Specific branch to analyze."
15+
required: false
16+
input_file:
17+
description: "Path to a JSON file containing a list of repositories to analyze."
18+
required: false
19+
verbose:
20+
description: "Whether to include all tests (even passed ones) in the final JSON-LD output."
21+
required: false
22+
default: "false"
23+
24+
runs:
25+
using: "composite"
26+
steps:
27+
- name: Set up Python
28+
uses: actions/setup-python@v5
29+
with:
30+
python-version: "3.11"
31+
cache: "pip"
32+
33+
- name: Install RsMetaCheck
34+
shell: bash
35+
run: pip install ${{ github.action_path }}
36+
37+
- name: Run RsMetaCheck
38+
shell: bash
39+
run: |
40+
CMD="rsmetacheck"
41+
42+
if [ -n "${{ inputs.input_file }}" ]; then
43+
CMD="$CMD --input ${{ inputs.input_file }}"
44+
elif [ -n "${{ inputs.repository_url }}" ]; then
45+
CMD="$CMD --input ${{ inputs.repository_url }}"
46+
if [ -n "${{ inputs.branch }}" ]; then
47+
CMD="$CMD --branch ${{ inputs.branch }}"
48+
fi
49+
fi
50+
51+
if [ "${{ inputs.verbose }}" == "true" ]; then
52+
CMD="$CMD --verbose"
53+
fi
54+
55+
echo "Running: $CMD"
56+
eval "$CMD"

docs/ground_truth/index.html

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
margin-bottom: 30px;
1919
}
2020
.table-container {
21-
max-width: 1200px;
21+
max-width: 95%;
2222
margin: 0 auto;
2323
overflow-x: auto;
2424
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
@@ -95,7 +95,7 @@ <h1>Ground TruthReport</h1>
9595
<th>Pitfall / Warning Code</th>
9696
<th>Description</th>
9797
<th>Source File</th>
98-
<th>Automated</th>
98+
<th>Commit ID</th>
9999
</tr>
100100
</thead>
101101
</table>
@@ -126,11 +126,11 @@ <h1>Ground TruthReport</h1>
126126
let isFirstContext = true;
127127

128128
for (const [code, info] of pEntries) {
129-
addRow(tbody, url, code, info, 'p', isFirstContext, totalRows);
129+
addRow(tbody, url, code, info, 'p', isFirstContext, totalRows, repoData);
130130
isFirstContext = false;
131131
}
132132
for (const [code, info] of wEntries) {
133-
addRow(tbody, url, code, info, 'w', isFirstContext, totalRows);
133+
addRow(tbody, url, code, info, 'w', isFirstContext, totalRows, repoData);
134134
isFirstContext = false;
135135
}
136136

@@ -144,7 +144,7 @@ <h1>Ground TruthReport</h1>
144144
});
145145
});
146146

147-
function addRow(tbody, url, code, info, type, isFirstContext, totalRows) {
147+
function addRow(tbody, url, code, info, type, isFirstContext, totalRows, repoData) {
148148
const tr = document.createElement('tr');
149149

150150
if (isFirstContext) {
@@ -179,14 +179,30 @@ <h1>Ground TruthReport</h1>
179179
const tdSource = document.createElement('td');
180180
tdSource.textContent = info.source_file || 'Unknown';
181181

182-
// Automated Column
183-
const tdAutomated = document.createElement('td');
184-
tdAutomated.textContent = 'Yes';
185-
186182
tr.appendChild(tdCode);
187183
tr.appendChild(tdDesc);
188184
tr.appendChild(tdSource);
189-
tr.appendChild(tdAutomated);
185+
186+
if (isFirstContext) {
187+
const tdCommit = document.createElement('td');
188+
tdCommit.style.whiteSpace = 'nowrap';
189+
const commitId = repoData['commit ID'];
190+
if (commitId) {
191+
const aCommit = document.createElement('a');
192+
let cleanUrl = url.endsWith('/') ? url.slice(0, -1) : url;
193+
let treePath = cleanUrl.includes('gitlab') ? '/-/tree/' : '/tree/';
194+
aCommit.href = `${cleanUrl}${treePath}${commitId}`;
195+
aCommit.textContent = commitId.substring(0, 7);
196+
aCommit.className = 'repo-link';
197+
aCommit.style.wordBreak = 'normal';
198+
aCommit.target = '_blank';
199+
tdCommit.appendChild(aCommit);
200+
} else {
201+
tdCommit.textContent = 'Unknown';
202+
}
203+
tdCommit.rowSpan = totalRows;
204+
tr.appendChild(tdCommit);
205+
}
190206

191207
tbody.appendChild(tr);
192208
}

0 commit comments

Comments
 (0)