Blob Blame History Raw
%bcond_without tests

# telemetry and testsdk don't follow azure-cli's versioning scheme.
# They have their own versions in the main repository.
%global         telemetry_version   1.0.6
%global         testsdk_version     0.2.4

%global         srcname     azure-cli
%global         forgeurl    https://github.com/Azure/azure-cli
Version:        2.29.1
%global         tag         %{srcname}-%{version}
%global         distprefix  %{nil}
%forgemeta

Name:           %{srcname}
Release:        %autorelease
Summary:        Microsoft Azure Command-Line Tools
License:        MIT
URL:            %forgeurl
Source0:        %forgesource
# All requirements are met, sometimes by newer versions, except for two:
# humanfriendly: https://src.fedoraproject.org/rpms/python-humanfriendly/pull-request/1
# portalocker:   https://src.fedoraproject.org/rpms/python-portalocker/pull-request/2
Patch0:         azure-cli-requirements-fix.patch

BuildArch:      noarch

BuildRequires:  python3-devel
BuildRequires:  python3-pip
BuildRequires:  python3-setuptools
BuildRequires:  python3-wheel
BuildRequires:  pyproject-rpm-macros

%if %{with tests}
BuildRequires:  python3dist(azure-devtools)
BuildRequires:  python3dist(azure-mgmt-managedservices)
BuildRequires:  python3dist(javaproperties)
BuildRequires:  python3dist(jsondiff)
BuildRequires:  python3dist(pkginfo)
BuildRequires:  python3dist(pytest)
BuildRequires:  python3dist(vcrpy)
%endif

%description
Microsoft Azure Command-Line Tools

# python-azure-cli-core
%package -n python3-%{srcname}-core
Summary:        Microsoft Azure Command-Line Tools Core Module
Requires:       %{name} = %{version}-%{release}

%description -n python3-%{srcname}-core
Microsoft Azure Command-Line Tools Core Module

# python-azure-cli-telemetry
%package -n python3-%{srcname}-telemetry
Summary:        Microsoft Azure CLI Telemetry Package
Requires:       %{name} = %{version}-%{release}

%description -n python3-%{srcname}-telemetry
Microsoft Azure CLI Telemetry Package

# python-azure-cli-testsdk
%package -n python3-%{srcname}-testsdk
Summary:        Microsoft Azure CLI SDK testing tools
Requires:       %{name} = %{version}-%{release}

%description -n python3-%{srcname}-testsdk
Microsoft Azure CLI SDK testing tools


%prep
%forgeautosetup -p1


%generate_buildrequires
%pyproject_buildrequires -N src/azure-cli/requirements.py3.Linux.txt


%build
PROJECTS=("azure-cli azure-cli-core azure-cli-telemetry azure-cli-testsdk")
for PROJECT in ${PROJECTS[@]}; do
    pushd src/${PROJECT}
        %pyproject_wheel
    popd
done


%install
%pyproject_install

# Batch scripts are only for Windows.
rm -f %{buildroot}%{_bindir}/az.bat

# Install the az bash completion script properly.
install -D -p -m 0644 %{buildroot}%{_bindir}/az.completion.sh \
    %{buildroot}%{_sysconfdir}/bash-completion.d/azure-cli
rm -f %{buildroot}%{_bindir}/az.completion.sh


%if %{with tests}
%check

export TEST_BASE=src/azure-cli/azure/cli/command_modules

# Test azure-cli components.
# NOTE(mhayden): Skipped tests shown below are skipped because they call out to
# Azure's APIs (unless otherwise specified).
%pytest --disable-warnings ${TEST_BASE}/acr \
    -k "not test_acr_create_webhook \
        and not test_acr_network_rule \
        and not test_acr_create_with_managed_registry \
        and not test_check_name_availability"

%pytest --disable-warnings ${TEST_BASE}/acs \
    -k "not test_aks_create_default_setting \
        and not test_aks_nodepool_create_scale_delete \
        and not test_aks_upgrade_node_image_only_cluster \
        and not test_aks_upgrade_node_image_only_nodepool"

%pytest --disable-warnings ${TEST_BASE}/advisor
%pytest --disable-warnings ${TEST_BASE}/ams
%pytest --disable-warnings ${TEST_BASE}/apim
%pytest --disable-warnings ${TEST_BASE}/appconfig
%pytest --disable-warnings ${TEST_BASE}/appservice
%pytest --disable-warnings ${TEST_BASE}/aro
%pytest --disable-warnings ${TEST_BASE}/backup
%pytest --disable-warnings ${TEST_BASE}/batch
%pytest --disable-warnings ${TEST_BASE}/batchai
%pytest --disable-warnings ${TEST_BASE}/billing
%pytest --disable-warnings ${TEST_BASE}/botservice

%pytest --disable-warnings ${TEST_BASE}/cdn \
    -k "not test_cdn_custom_domain_https_msft"

%pytest --disable-warnings ${TEST_BASE}/cloud
%pytest --disable-warnings ${TEST_BASE}/cognitiveservices
%pytest --disable-warnings ${TEST_BASE}/config
%pytest --disable-warnings ${TEST_BASE}/configure
%pytest --disable-warnings ${TEST_BASE}/consumption
%pytest --disable-warnings ${TEST_BASE}/container
%pytest --disable-warnings ${TEST_BASE}/cosmosdb

%pytest --disable-warnings ${TEST_BASE}/databoxedge \
    -k "not test_device_general \
        and not test_general_Scenario \
        and not test_order_Scenario \
        and not test_device_general \
        and not test_general_Scenario \
        and not test_order_Scenario"

%pytest --disable-warnings ${TEST_BASE}/deploymentmanager
%pytest --disable-warnings ${TEST_BASE}/dla
%pytest --disable-warnings ${TEST_BASE}/dls
%pytest --disable-warnings ${TEST_BASE}/dms
%pytest --disable-warnings ${TEST_BASE}/eventgrid
%pytest --disable-warnings ${TEST_BASE}/eventhubs
%pytest --disable-warnings ${TEST_BASE}/find
%pytest --disable-warnings ${TEST_BASE}/hdinsight

%pytest --disable-warnings ${TEST_BASE}/iot \
    -k "not test_certificate_lifecycle and not test_iot_hub"

%pytest --disable-warnings ${TEST_BASE}/keyvault \
    -k "not test_keyvault_mgmt \
        and not test_keyvault_key \
        and not test_keyvault_secret \
        and not test_keyvault_certificate_contacts \
        and not test_keyvault_certificate_issuers \
        and not test_keyvault_pending_certificate \
        and not test_keyvault_certificate_download \
        and not test_keyvault_certificate_crud \
        and not test_keyvault_certificate_import \
        and not test_keyvault_softdelete"

%pytest --disable-warnings ${TEST_BASE}/kusto
%pytest --disable-warnings ${TEST_BASE}/lab
%pytest --disable-warnings ${TEST_BASE}/managedservices
%pytest --disable-warnings ${TEST_BASE}/maps
%pytest --disable-warnings ${TEST_BASE}/marketplaceordering

%pytest --disable-warnings ${TEST_BASE}/monitor \
    -k "not test_monitor_private_link_scope_scenario"

%pytest --disable-warnings ${TEST_BASE}/natgateway
%pytest --disable-warnings ${TEST_BASE}/netappfiles

%pytest --disable-warnings ${TEST_BASE}/network \
    --ignore=${TEST_BASE}/network/tests/hybrid_2018_03_01/test_network_commands.py \
    -k "not test_dns \
        and not test_dns_zone2_import \
        and not test_dns_zone3_import \
        and not test_dns_zone4_import \
        and not test_dns_zone5_import \
        and not test_dns_zone6_import \
        and not test_network_app_gateway_with_identity \
        and not test_network_virtual_appliance \
        and not test_network_security_partner_provider"

%pytest --disable-warnings ${TEST_BASE}/policyinsights
%pytest --disable-warnings ${TEST_BASE}/privatedns

%pytest --disable-warnings ${TEST_BASE}/profile \
    -k "not test_login_validate_tenant"

%pytest --disable-warnings ${TEST_BASE}/rdbms
%pytest --disable-warnings ${TEST_BASE}/redis
%pytest --disable-warnings ${TEST_BASE}/relay
%pytest --disable-warnings ${TEST_BASE}/reservations

%pytest --disable-warnings ${TEST_BASE}/resource \
    --ignore=${TEST_BASE}/resource/tests/hybrid_2018_03_01/test_locks.py \
    --ignore=${TEST_BASE}/resource/tests/hybrid_2018_03_01/test_resource.py \
    --ignore=${TEST_BASE}/resource/tests/hybrid_2019_03_01/test_locks.py \
    --ignore=${TEST_BASE}/resource/tests/hybrid_2019_03_01/test_managmentgroups.py \
    --ignore=${TEST_BASE}/resource/tests/hybrid_2019_03_01/test_resource.py

%pytest --disable-warnings ${TEST_BASE}/role \
    --ignore=${TEST_BASE}/role/tests/hybrid_2018_03_01/test_role.py

%pytest --disable-warnings ${TEST_BASE}/search
%pytest --disable-warnings ${TEST_BASE}/security
%pytest --disable-warnings ${TEST_BASE}/servicebus

%pytest --disable-warnings ${TEST_BASE}/servicefabric \
    -k "not test_create_cluster_with_separate_kv \
        and not test_cert_and_ext"

%pytest --disable-warnings ${TEST_BASE}/signalr
%pytest --disable-warnings ${TEST_BASE}/sql
%pytest --disable-warnings ${TEST_BASE}/sqlvm

%pytest --disable-warnings ${TEST_BASE}/storage \
    --ignore-glob=${TEST_BASE}/storage/tests/hybrid_*/test_storage_acl_scenarios.py \
    --ignore-glob=${TEST_BASE}/storage/tests/hybrid_*/test_storage_account_scenarios.py \
    --ignore-glob=${TEST_BASE}/storage/tests/hybrid_*/test_storage_blob_scenarios.py \
    --ignore-glob=${TEST_BASE}/storage/tests/hybrid_*/test_storage_cors_scenarios.py \
    --ignore-glob=${TEST_BASE}/storage/tests/hybrid_*/test_storage_file_scenarios.py \
    --ignore-glob=${TEST_BASE}/storage/tests/hybrid_*/test_storage_queue_scenarios.py \
    --ignore-glob=${TEST_BASE}/storage/tests/hybrid_*/test_storage_table_scenarios.py

%pytest --disable-warnings ${TEST_BASE}/synapse
%pytest --disable-warnings ${TEST_BASE}/util

%pytest --disable-warnings ${TEST_BASE}/vm \
    --ignore-glob=${TEST_BASE}/vm/tests/hybrid_*/test_vm_commands.py \
    -k "not test_vm_create_with_monitor \
        and not test_vm_metric_tail"

# Test azure-cli-core.
%pytest --disable-warnings \
    -k "not test_format_styled_text_legacy_powershell and not test_metadata_url_endpoints and not test_help_loads and not test_get_msal_token" \
    src/azure-cli-core

# Test azure-cli-telemetry.
%pytest --disable-warnings src/azure-cli-telemetry

# azure-cli-testsdk has no tests.
%endif


%files
%doc README.md
%license LICENSE
# Executable-related files/directories.
%{_bindir}/az
%dir %{_sysconfdir}/bash-completion.d/
%{_sysconfdir}/bash-completion.d/%{srcname}
# Python sitelib files and directories.
%dir %{python3_sitelib}/azure
%{python3_sitelib}/azure/cli
%{python3_sitelib}/azure_cli-%{version}.dist-info/
# Prevent azure-cli from grabbing all of the files underneath azure/cli.
%exclude %{python3_sitelib}/azure/cli/core
%exclude %{python3_sitelib}/azure/cli/telemetry
%exclude %{python3_sitelib}/azure/cli/testsdk


%files -n python3-%{srcname}-core
%doc README.md
%license LICENSE
%{python3_sitelib}/azure/cli/core
%{python3_sitelib}/azure_cli_core-%{version}.dist-info/


%files -n python3-%{srcname}-telemetry
%doc README.md
%license LICENSE
%{python3_sitelib}/azure/cli/telemetry
%{python3_sitelib}/azure_cli_telemetry-%{telemetry_version}.dist-info/


%files -n python3-%{srcname}-testsdk
%doc README.md
%license LICENSE
%{python3_sitelib}/azure/cli/testsdk
%{python3_sitelib}/azure_cli_testsdk-%{testsdk_version}.dist-info/


%changelog
%autochangelog