Skip to content

Commit c18e1ee

Browse files
committed
chore: improve issues management
Signed-off-by: Jefferson <jefferson.rios.caro@gmail.com>
1 parent 5f70537 commit c18e1ee

7 files changed

Lines changed: 422 additions & 344 deletions

File tree

.github/workflows/check-vulns.yml

Lines changed: 21 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,15 @@ permissions:
2020
contents: read
2121
issues: write
2222

23+
# Serialize reconciliation per stream so two runs for the same stream can never
24+
# race and double-create issues.
25+
concurrency:
26+
group: reconcile-${{ inputs.nsolidStream }}
27+
cancel-in-progress: false
28+
2329
jobs:
2430
check-vulns:
2531
runs-on: ubuntu-latest
26-
outputs:
27-
matrix: ${{ steps.set_matrix.outputs.matrix }}
2832
steps:
2933
- name: Setup Python 3.11
3034
uses: actions/setup-python@v5
@@ -44,14 +48,6 @@ jobs:
4448
python3 --version
4549
- name: Checkout current repository
4650
uses: actions/checkout@v4
47-
- name: Debug directory structure
48-
run: |
49-
echo "Current directory:"
50-
pwd
51-
echo "Directory contents:"
52-
ls -la
53-
echo "dep_checker directory exists:"
54-
ls -la dep_checker/ || echo "dep_checker directory not found"
5551
- name: Installing pre-reqs
5652
working-directory: ./dep_checker
5753
run: pip install -r requirements.txt
@@ -63,58 +59,22 @@ jobs:
6359
ref: ${{ inputs.nsolidStream }}
6460
- name: Run the check
6561
working-directory: ./dep_checker
62+
# Write clean JSON to result.json (diagnostics go to stderr). A non-zero exit
63+
# just means "vulnerabilities were found" — it must not skip reconciliation.
6664
run: |
67-
(
68-
set -o pipefail
69-
python3 main.py --json-output --include-npm --npm-timeout 600 --gh-token ${{ secrets.GITHUB_TOKEN }} --nvd-key=${{ secrets.NVD_API_KEY }} ../nsolid ${{ inputs.nsolidStream }} 2>&1 | tee result.log
70-
)
71-
cat result.log
72-
- name: build matrix
73-
id: set_matrix
74-
if: ${{ failure() }}
65+
python3 main.py --scan-file result.json --include-npm --npm-timeout 600 \
66+
--gh-token ${{ secrets.GITHUB_TOKEN }} --nvd-key=${{ secrets.NVD_API_KEY }} \
67+
../nsolid ${{ inputs.nsolidStream }} || true
68+
echo "Scan result:"
69+
cat result.json
70+
- name: Reconcile issues
71+
if: ${{ always() }}
7572
working-directory: ./dep_checker
76-
run: |
77-
# Extract vulnerabilities JSON from the log
78-
vulnerabilities_json=$(grep -o '{.*}' result.log | tail -1)
79-
echo "Raw vulnerabilities JSON: $vulnerabilities_json"
80-
81-
# Use the matrix formatter to build the complete matrix with labels
82-
matrix=$(python3 ../.github/workflows/format_matrix.py "$vulnerabilities_json" "${{ inputs.nsolidStream }}")
83-
echo "Formatted matrix: $matrix"
84-
echo "matrix=$matrix" >> $GITHUB_OUTPUT
85-
86-
create-issues:
87-
needs: check-vulns
88-
if: ${{ always() }}
89-
runs-on: ubuntu-latest
90-
strategy:
91-
matrix: ${{ fromJson(needs.check-vulns.outputs.matrix) }}
92-
max-parallel: 1
93-
steps:
94-
- uses: actions/checkout@v4
95-
- name: Debug matrix data
96-
run: |
97-
echo "Matrix vulnerability data:"
98-
echo "ID: ${{ matrix.vulnerabilities.id }}"
99-
echo "Dependency: ${{ matrix.vulnerabilities.dependency }}"
100-
echo "Source: ${{ matrix.vulnerabilities.source }}"
101-
echo "Labels: ${{ join(matrix.vulnerabilities.labels, ', ') }}"
102-
echo "ISSUE_LABELS: ${{ join(matrix.vulnerabilities.labels, ',') }}"
103-
104-
- name: Create or update GitHub issue
10573
env:
106-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
107-
GITHUB_REPOSITORY: ${{ github.repository }}
108-
VULN_ID: ${{ matrix.vulnerabilities.id }}
109-
VULN_URL: ${{ matrix.vulnerabilities.url }}
110-
VULN_DEP_NAME: ${{ matrix.vulnerabilities.dependency }}
111-
VULN_DEP_VERSION: ${{ matrix.vulnerabilities.version }}
112-
VULN_SOURCE: ${{ matrix.vulnerabilities.source }}
113-
VULN_TITLE: ${{ matrix.vulnerabilities.title }}
114-
VULN_MAIN_DEP_NAME: ${{ matrix.vulnerabilities.main_dep_name }}
115-
VULN_MAIN_DEP_PATH: ${{ matrix.vulnerabilities.main_dep_path }}
116-
NODEJS_STREAM: ${{ inputs.nsolidStream }}
117-
ACTION_URL: "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
118-
LABELS: ${{ join(matrix.vulnerabilities.labels, ',') }}
74+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
75+
GH_REPO: ${{ github.repository }}
11976
run: |
120-
.github/workflows/create_issue.sh
77+
python3 reconcile_issues.py \
78+
--stream "${{ inputs.nsolidStream }}" \
79+
--scan-file result.json \
80+
--action-url "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"

.github/workflows/create_issue.sh

Lines changed: 0 additions & 141 deletions
This file was deleted.

.github/workflows/daily.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
fail-fast: false
1818
max-parallel: 1
1919
matrix:
20-
nsolidStream: ["node-v20.x-nsolid-v5.x", "node-v22.x-nsolid-v5.x"]
20+
nsolidStream: ["node-v22.x-nsolid-v5.x", "node-v24.x-nsolid-v6.x"]
2121
uses: ./.github/workflows/check-vulns.yml
2222
with:
2323
nsolidStream: ${{ matrix.nsolidStream }}

.github/workflows/format_matrix.py

Lines changed: 0 additions & 121 deletions
This file was deleted.

dep_checker/dependencies.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ def get_cpe(self, repo_path: Path) -> Optional[str]:
4343
"acorn",
4444
"brotli",
4545
"c-ares",
46-
"CJS Module Lexer",
4746
"corepack",
4847
"HdrHistogram",
4948
"ICU",
@@ -65,8 +64,8 @@ def get_cpe(self, repo_path: Path) -> Optional[str]:
6564
]
6665

6766
# Define branch-specific dependencies
68-
main_specific = ["simdutf"]
69-
v22_specific = ["simdutf"]
67+
main_specific = ["simdutf", "CJS Module Lexer",]
68+
v22_specific = ["simdutf", "CJS Module Lexer"]
7069

7170
# Combine common dependencies with branch-specific ones
7271
dependencies_per_branch: dict[str, list[str]] = {

0 commit comments

Comments
 (0)