File tree Expand file tree Collapse file tree 2 files changed +24
-19
lines changed Expand file tree Collapse file tree 2 files changed +24
-19
lines changed Original file line number Diff line number Diff line change 3535 - name : Pre-commit checks
3636 run : pre-commit run --all-files
3737 - name : Test with pytest
38+ # Create the ssh key file once for all testing
3839 run : |
40+ ssh-keygen -t ecdsa -m PEM -N '' -f /tmp/buildrunner-test-id_rsa
3941 pytest -v -m "not serial" --numprocesses=auto --junitxml=test-reports/non-serial-test-results.xml
4042 pytest -v -m "serial" --junitxml=test-reports/serial-test-results.xml
4143 python scripts/combine_xml.py test-reports/serial-test-results.xml test-reports/non-serial-test-results.xml > test-reports/test-result.xml
Original file line number Diff line number Diff line change 2626@pytest .fixture (autouse = True , scope = "session" )
2727def setup_buildrunner_test_ssh_key ():
2828 key_file_path = Path (TEST_SSH_KEY_FILE )
29- key_file_path .unlink (missing_ok = True )
30- subprocess .run (
31- [
32- "ssh-keygen" ,
33- "-t" ,
34- "ecdsa" ,
35- "-m" ,
36- "PEM" ,
37- "-N" ,
38- "" ,
39- "-f" ,
40- TEST_SSH_KEY_FILE ,
41- ],
42- check = True ,
43- )
29+ cleanup_key_file = False
30+ pub_key_file_path = Path (f"{ TEST_SSH_KEY_FILE } .pub" )
31+ if not key_file_path .exists ():
32+ subprocess .run (
33+ [
34+ "ssh-keygen" ,
35+ "-t" ,
36+ "ecdsa" ,
37+ "-m" ,
38+ "PEM" ,
39+ "-N" ,
40+ "" ,
41+ "-f" ,
42+ TEST_SSH_KEY_FILE ,
43+ ],
44+ check = True ,
45+ )
46+ cleanup_key_file = True
4447 # Set the public key in an environment variable to use in the test buildrunner files
45- os .environ ["BUILDRUNNER_TEST_SSH_PUB_KEY" ] = (
46- Path (f"{ TEST_SSH_KEY_FILE } .pub" ).read_text ().strip ()
47- )
48+ os .environ ["BUILDRUNNER_TEST_SSH_PUB_KEY" ] = pub_key_file_path .read_text ().strip ()
4849 yield
4950 # Cleanup
5051 del os .environ ["BUILDRUNNER_TEST_SSH_PUB_KEY" ]
51- key_file_path .unlink ()
52+ if cleanup_key_file :
53+ key_file_path .unlink ()
54+ pub_key_file_path .unlink ()
5255
5356
5457def _get_test_args (file_name : str ) -> Optional [List [str ]]:
You can’t perform that action at this time.
0 commit comments