Skip to content

Commit 87edc50

Browse files
committed
fix(ci): Fix CodeQL warnings
1 parent 9fc8643 commit 87edc50

File tree

3 files changed

+29
-17
lines changed

3 files changed

+29
-17
lines changed

.github/workflows/tests_hw_wokwi.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ jobs:
302302
303303
- name: Trigger GitLab Pipeline and Download Artifacts
304304
if: ${{ steps.check-tests.outputs.enabled == 'true' }}
305-
uses: digital-blueprint/[email protected]
305+
uses: digital-blueprint/gitlab-pipeline-trigger-action@20e77989b24af658ba138a0aa5291bdc657f1505 # v1.3.0
306306
id: gitlab-trigger
307307
with:
308308
host: ${{ secrets.GITLAB_URL }}

.github/workflows/tests_results.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,12 +141,16 @@ jobs:
141141
- name: Clean up caches
142142
if: always()
143143
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
144+
env:
145+
ORIGINAL_REF: ${{ needs.get-artifacts.outputs.original_ref }}
146+
ORIGINAL_EVENT: ${{ needs.get-artifacts.outputs.original_event }}
147+
ORIGINAL_ACTION: ${{ needs.get-artifacts.outputs.original_action }}
144148
with:
145149
script: |
146-
const ref = '${{ needs.get-artifacts.outputs.original_ref }}';
150+
const ref = process.env.ORIGINAL_REF;
147151
const key_prefix = 'test-' + ref + '-';
148152
149-
if ('${{ needs.get-artifacts.outputs.original_event }}' == 'pull_request' && '${{ needs.get-artifacts.outputs.original_action }}' != 'closed') {
153+
if (process.env.ORIGINAL_EVENT == 'pull_request' && process.env.ORIGINAL_ACTION != 'closed') {
150154
console.log('Skipping cache cleanup for open PR');
151155
return;
152156
}
@@ -172,16 +176,19 @@ jobs:
172176
- name: Report conclusion
173177
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
174178
if: always()
179+
env:
180+
ORIGINAL_EVENT: ${{ needs.get-artifacts.outputs.original_event }}
181+
ORIGINAL_SHA: ${{ needs.get-artifacts.outputs.original_sha }}
175182
with:
176183
script: |
177184
const owner = '${{ github.repository_owner }}';
178185
const repo = '${{ github.repository }}'.split('/')[1];
179-
const sha = '${{ needs.get-artifacts.outputs.original_sha }}';
186+
const sha = process.env.ORIGINAL_SHA;
180187
core.debug(`owner: ${owner}`);
181188
core.debug(`repo: ${repo}`);
182189
core.debug(`sha: ${sha}`);
183190
const { context: name, state } = (await github.rest.repos.createCommitStatus({
184-
context: `Runtime Tests / Report results (${{ needs.get-artifacts.outputs.original_event }} -> workflow_run -> workflow_run)`,
191+
context: `Runtime Tests / Report results (${process.env.ORIGINAL_EVENT} -> workflow_run -> workflow_run)`,
185192
owner: owner,
186193
repo: repo,
187194
sha: sha,

.gitlab/scripts/gen_hw_jobs.py

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,21 @@
55
import yaml
66
import os
77
import sys
8-
from pathlib import Path
98
import copy
9+
import traceback
10+
from pathlib import Path
1011

11-
# Resolve repository root from this script location: .gitlab/scripts -> esp32 root
12+
# Resolve repository root from this script location
1213
SCRIPT_DIR = Path(__file__).resolve().parent
1314
REPO_ROOT = SCRIPT_DIR.parent.parent
15+
TESTS_ROOT = REPO_ROOT / "tests"
1416

1517
# Ensure we run from repo root so relative paths work consistently
1618
try:
1719
os.chdir(REPO_ROOT)
18-
except Exception:
19-
pass
20-
21-
TESTS_ROOT = REPO_ROOT / "tests"
20+
except Exception as e:
21+
sys.stderr.write(f"[WARN] Failed to chdir to repo root '{REPO_ROOT}': {e}\n")
22+
sys.stderr.write(traceback.format_exc() + "\n")
2223

2324

2425
class PrettyDumper(yaml.SafeDumper):
@@ -35,7 +36,9 @@ def read_json(p: Path):
3536
try:
3637
with p.open("r", encoding="utf-8") as f:
3738
return json.load(f)
38-
except Exception:
39+
except Exception as e:
40+
sys.stderr.write(f"[WARN] Failed to parse JSON file '{p}': {e}\n")
41+
sys.stderr.write(traceback.format_exc() + "\n")
3942
return {}
4043

4144

@@ -155,7 +158,9 @@ def sdk_meets_requirements(sdkconfig: Path, ci_json: dict) -> bool:
155158
if not ok:
156159
return False
157160
return True
158-
except Exception:
161+
except Exception as e:
162+
sys.stderr.write(f"[WARN] Failed to evaluate requirements against '{sdkconfig}': {e}\n")
163+
sys.stderr.write(traceback.format_exc() + "\n")
159164
return False
160165

161166

@@ -166,13 +171,13 @@ def parse_list_arg(s: str) -> list[str]:
166171
if txt.startswith("[") and txt.endswith("]"):
167172
try:
168173
return [str(x).strip() for x in json.loads(txt)]
169-
except Exception:
170-
# Attempt single-quote JSON -> replace with double quotes
174+
except Exception as e:
175+
sys.stderr.write(f"[WARN] Failed to parse JSON list '{txt}': {e}. Retrying with quote normalization.\n")
171176
try:
172177
fixed = txt.replace("'", '"')
173178
return [str(x).strip() for x in json.loads(fixed)]
174-
except Exception:
175-
pass
179+
except Exception as e2:
180+
sys.stderr.write(f"[WARN] Failed to parse JSON list after normalization: {e2}. Falling back to CSV parsing.\n")
176181
# Fallback: comma-separated
177182
return [part.strip() for part in txt.split(",") if part.strip()]
178183

0 commit comments

Comments
 (0)