From f953726d185b3dde1cc2ef2d4420ade31fc77779 Mon Sep 17 00:00:00 2001 From: Oleg Kulachenko Date: Mon, 13 Nov 2023 16:33:48 +0400 Subject: [PATCH 1/2] workflows: Add test without attributes Signed-off-by: Oleg Kulachenko --- .github/workflows/tests.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 916bcff..53b1544 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -84,6 +84,26 @@ jobs: source venv/bin/activate && pytest test_downloads.py --base_url="$OUTPUT_CONTAINER_URL" working-directory: ./tests + - name: Run gh-push-to-neofs without attributes + id: gh_push_to_neofs_without_attributes + uses: ./ + with: + NEOFS_WALLET: ${{ secrets.NEOFS_WALLET }} + NEOFS_WALLET_PASSWORD: ${{ secrets.NEOFS_WALLET_PASSWORD }} + NEOFS_NETWORK_DOMAIN: ${{ vars.NEOFS_NETWORK_DOMAIN }} + NEOFS_HTTP_GATE: ${{ vars.NEOFS_HTTP_GATE }} + STORE_OBJECTS_CID: ${{ vars.STORE_OBJECTS_CID }} + LIFETIME: ${{ vars.LIFETIME }} + PATH_TO_FILES_DIR: ${{ env.TESTS_DATA_DIR }} + URL_PREFIX: ${{ env.URL_PREFIX }} + + - name: Run tests + env: + OUTPUT_CONTAINER_URL: ${{ steps.gh_push_to_neofs_with_url_prefix.outputs.OUTPUT_CONTAINER_URL }} + run: | + source venv/bin/activate && pytest test_downloads.py --base_url="$OUTPUT_CONTAINER_URL" + working-directory: ./tests + - name: Prepare directory name for tests without url prefix shell: bash env: From 2817593fbe6097123db757ef3843cd0c6bb633c4 Mon Sep 17 00:00:00 2001 From: Oleg Kulachenko Date: Mon, 13 Nov 2023 17:01:56 +0400 Subject: [PATCH 2/2] Fix arguments For parameters that can be specified with an empty value, the value `None` has been added to neofs-cli arguments for correct processing. It is also possible that the value of the argument "" comes from the shell. This has been fixed in all possible cases. Closes https://github.com/nspcc-dev/gh-push-to-neofs/issues/12 Signed-off-by: Oleg Kulachenko --- push-to-neofs.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/push-to-neofs.py b/push-to-neofs.py index 350f34c..c32cb60 100644 --- a/push-to-neofs.py +++ b/push-to-neofs.py @@ -27,6 +27,8 @@ def parse_args(): "For example, it's convenient to create url links to access an object via http:" "FilePath=96-1697035975/dir/3.txt" "Type=test_result,Master=true,RUN_ID=96-1697035975", + nargs="?", + const=None, default=None, ) parser.add_argument( @@ -39,6 +41,8 @@ def parse_args(): " https://http.fs.neo.org/HXSaMJXk2g8C14ht8HSi7BBaiYZ1HeWh2xnWPGQCg4H6/832-1695916423/file.txt" "Without --url_path_prefix the url will be:" " https://http.fs.neo.org/HXSaMJXk2g8C14ht8HSi7BBaiYZ1HeWh2xnWPGQCg4H6/file.txt", + nargs="?", + const=None, default=None, ) parser.add_argument( @@ -54,6 +58,8 @@ def parse_args(): help="Lifetime in epochs - number of epochs for object to stay valid. If provided, will be added to the " "current epoch to calculate expiration epoch. If not provided, or if it is 0, the report will be stored " "indefinitely", + nargs="?", + const=None, default=None, ) parser.add_argument( @@ -95,14 +101,14 @@ def push_file( mime_type = magic.from_file(filepath, mime=True) relative_path = os.path.relpath(filepath, os.path.dirname(directory)) - if url_path_prefix is not None: + if url_path_prefix is not None and url_path_prefix != "": neofs_path_attr = os.path.join(url_path_prefix, relative_path) else: neofs_path_attr = relative_path base_cmd_with_file = f"{base_cmd} --file {filepath} --attributes {FILE_PATH}={neofs_path_attr},{CONTENT_TYPE}={mime_type}" - if attributes is not None: + if attributes is not None and attributes != "": base_cmd_with_file += f",{attributes}" print(f"Neofs cli cmd is: {base_cmd_with_file}")