File tree Expand file tree Collapse file tree 2 files changed +23
-27
lines changed
Expand file tree Collapse file tree 2 files changed +23
-27
lines changed Original file line number Diff line number Diff line change 6666 - name : Check if all keys are generated
6767 id : check-complete
6868 run : |
69- # Use the Python function to check if all expensive keys are generated
70- python -c "
71- from pathlib import Path
72- from scripts.pipeline_gen_stfl_keys import check_generated_all_keys
73- import sys
74-
75- out_dir = Path('${KEY_DIR}')
76- if check_generated_all_keys(out_dir):
77- print('All keys generated!')
78- print('complete=true')
79- sys.exit(0)
80- else:
81- print('Still missing some keys')
82- print('complete=false')
83- sys.exit(0)
84- " | tee /tmp/check_output.txt
85-
86- # Extract the complete status from output
87- if grep -q "complete=true" /tmp/check_output.txt; then
69+ # Use the --check_keys_dir flag to verify all keys are present
70+ if python scripts/pipeline_gen_stfl_keys.py "${KEY_DIR}" --check_keys_dir; then
8871 echo "complete=true" >> $GITHUB_OUTPUT
8972 else
9073 echo "complete=false" >> $GITHUB_OUTPUT
Original file line number Diff line number Diff line change @@ -184,19 +184,32 @@ def main(argv: Iterable[str] | None = None) -> int:
184184 "Defaults to $KEY_DIR if set, otherwise data/xmss_xmssmt_keys."
185185 ),
186186 )
187+ parser .add_argument (
188+ "--check_keys_dir" ,
189+ action = "store_true" ,
190+ help = (
191+ "If set, do not generate keys; only check whether all required "
192+ "XMSS/XMSSMT keys exist in the output directory. Returns 0 if all "
193+ "keys are present, 1 if any are missing."
194+ ),
195+ )
187196 args = parser .parse_args (list (argv ) if argv is not None else None )
188197
189198 out_dir = _resolve_out_dir (args .key_dir )
190- stats = generate_keys (out_dir )
191-
192- # For now we always return 0 to keep behavior similar to the inline script,
193- # which only printed errors but did not cause the job to fail.
194- if stats ["missing" ]:
195- # If you later want to fail the pipeline, change this to return 1.
196- pass
197199
200+ if args .check_keys_dir :
201+ # Only check whether all required keys are present; do not generate.
202+ all_present = check_generated_all_keys (out_dir )
203+ if all_present :
204+ logger .debug ("All required XMSS/XMSSMT keys are present in %s" , out_dir )
205+ return 0
206+ else :
207+ logger .debug ("Some required XMSS/XMSSMT keys are missing in %s" , out_dir )
208+ return 1
209+
210+ _ = generate_keys (out_dir )
198211 return 0
199212
200213
201- if __name__ == "__main__" : # pragma: no cover - thin CLI wrapper
214+ if __name__ == "__main__" :
202215 main ()
You can’t perform that action at this time.
0 commit comments