mirror of
https://github.com/netinvent/npbackup.git
synced 2025-09-06 04:54:48 +08:00
tests: Don't make archives move on github actions
This commit is contained in:
parent
7cd6ea6922
commit
bbc19f749d
2 changed files with 18 additions and 8 deletions
|
@ -23,7 +23,7 @@ sys.path.insert(0, os.path.normpath(os.path.join(os.path.dirname(__file__), ".."
|
|||
from npbackup.path_helper import BASEDIR
|
||||
|
||||
|
||||
def download_restic_binaries(arch: str = "amd64"):
|
||||
def download_restic_binaries(arch: str = "amd64", move_is_fatal: bool = True) -> bool:
|
||||
"""
|
||||
We must first download latest restic binaries to make sure we can run all tests and/or compile
|
||||
"""
|
||||
|
@ -77,16 +77,15 @@ def download_restic_binaries(arch: str = "amd64"):
|
|||
# Assume we have a zip or tar.gz
|
||||
shutil.unpack_archive(full_path, dest_dir)
|
||||
try:
|
||||
print("ARCHIVE DIR EXISTS: ", dest_dir.joinpath("ARCHIVES").is_dir())
|
||||
if not dest_dir.joinpath("ARCHIVES").is_dir():
|
||||
os.makedirs(dest_dir.joinpath("ARCHIVES"))
|
||||
print("ARCHIVE DIR EXISTS: ", dest_dir.joinpath("ARCHIVES").is_dir())
|
||||
shutil.move(full_path, dest_dir.joinpath("ARCHIVES").joinpath(filename))
|
||||
except OSError:
|
||||
print(
|
||||
f'CANNOT MOVE TO ARCHIVE: {full_path} to {dest_dir.joinpath("ARCHIVES").joinpath(filename)}'
|
||||
)
|
||||
return False
|
||||
if move_is_fatal:
|
||||
print(
|
||||
f'CANNOT MOVE TO ARCHIVE: {full_path} to {dest_dir.joinpath("ARCHIVES").joinpath(filename)}'
|
||||
)
|
||||
return False
|
||||
print(f"DOWNLOADED {dest_dir}")
|
||||
downloaded = True
|
||||
break
|
||||
|
|
|
@ -65,6 +65,15 @@ repo_config, _ = get_repo_config(full_config)
|
|||
DUMP_FILE = "__version__.py"
|
||||
|
||||
|
||||
def running_on_github_actions():
|
||||
"""
|
||||
This is set in github actions workflow with
|
||||
env:
|
||||
RUNNING_ON_GITHUB_ACTIONS: true
|
||||
"""
|
||||
return os.environ.get("RUNNING_ON_GITHUB_ACTIONS", "False").lower() == "true"
|
||||
|
||||
|
||||
class RedirectedStdout:
|
||||
"""
|
||||
Balantly copied from https://stackoverflow.com/a/45899925/2635443
|
||||
|
@ -91,7 +100,9 @@ def test_download_restic_binaries():
|
|||
We must first download latest restic binaries to make sure we can run all tests
|
||||
Currently we only run these on amd64
|
||||
"""
|
||||
assert download_restic_binaries("amd64"), "Could not download restic binaries"
|
||||
assert download_restic_binaries(
|
||||
"amd64", move_is_fatal=not running_on_github_actions()
|
||||
), "Could not download restic binaries"
|
||||
|
||||
|
||||
def test_npbackup_cli_no_config():
|
||||
|
|
Loading…
Add table
Reference in a new issue