Skip to content

Commit

Permalink
Fix Github action to generate labels for changed atomics (redcanaryco…
Browse files Browse the repository at this point in the history
  • Loading branch information
cyberbuff authored Jul 29, 2023
1 parent 0736dfb commit 20d3a04
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
10 changes: 7 additions & 3 deletions .github/workflows/assign-labels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: assign-labels

on:
workflow_run:
workflows: [ "validate-atomics" ]
workflows: ["validate-atomics"]
types:
- completed

Expand Down Expand Up @@ -41,6 +41,10 @@ jobs:
let fs = require('fs');
const obj = JSON.parse(fs.readFileSync('./labels.json'));
console.log(obj)
const existingAssignees = await github.rest.issues.listAssignees({
owner: context.repo.owner,
repo: context.repo.repo,
});
if(obj.labels.length > 0){
await github.rest.issues.addLabels({
issue_number: obj.pr,
Expand All @@ -49,11 +53,11 @@ jobs:
labels: obj.labels
})
}
if(obj.maintainers.length > 0){
if(obj.maintainers.length > 0 && existingAssignees.data.length === 0){
await github.rest.issues.addAssignees({
issue_number: obj.pr,
owner: context.repo.owner,
repo: context.repo.repo,
assignees: obj.maintainers
});
}
}
13 changes: 11 additions & 2 deletions bin/generate_labels.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,18 @@ def get_tests_changed(self, pr: str):
count = -1
elif line.startswith("+"): # only take count of added lines
changed_lines.append(start + count)
elif line.startswith("-"):
count -= 1
count += 1
for index, t in enumerate(data["atomic_tests"]):
if t["__line__"] in changed_lines:
atomics = data["atomic_tests"]
for index, t in enumerate(atomics):
curr_atomic_start = atomics[index]["__line__"]
if index+1<len(atomics):
curr_atomic_end = atomics[index+1]["__line__"]
else:
curr_atomic_end = start+60
changes_in_current_atomic = [i for i in changed_lines if i > curr_atomic_start and i < curr_atomic_end]
if len(changes_in_current_atomic) > 0:
tests.append(ChangedAtomic(technique=technique, test_number=index + 1,
data=t))

Expand Down

0 comments on commit 20d3a04

Please sign in to comment.