actions: Cleanup using context managers for lock

Signed-off-by: Joe MacMahon <joe.macmahon@cern.ch>
tests: Added tests for fallback to log files

Signed-off-by: Joe MacMahon <joe.macmahon@cern.ch>