From 7b336ac4aef344f22c5726f7ed9f55753a3e771a Mon Sep 17 00:00:00 2001 From: Julien Langlois Date: Fri, 12 Dec 2025 10:54:50 -0800 Subject: [PATCH 01/21] Tests --- azure-pipelines-templates/run-tests.yml | 57 ++++++++++++------------- azure-pipelines.yml | 44 +++++++++++-------- 2 files changed, 54 insertions(+), 47 deletions(-) diff --git a/azure-pipelines-templates/run-tests.yml b/azure-pipelines-templates/run-tests.yml index c1a1a4ef8..a4db3634d 100644 --- a/azure-pipelines-templates/run-tests.yml +++ b/azure-pipelines-templates/run-tests.yml @@ -30,28 +30,17 @@ parameters: name: '' vm_image: '' + python_version: '' jobs: # The job will be named after the OS and Azure will suffix the strategy to make it unique # so we'll have a job name "Windows Python 3.9" for example. What's a strategy? Strategies are the # name of the keys under the strategy.matrix scope. So for each OS we'll have " Python 3.9" and # " Python 3.10". -- job: ${{ parameters.name }} +- job: + displayName: ${{ parameters.name }} pool: vmImage: ${{ parameters.vm_image }} - # The strategy is another way of removing repetition. It will create one job per entry in the - # matrix. - strategy: - matrix: - # We support these versions of Python. - Python 3.9: - python.version: '3.9' - Python 3.10: - python.version: '3.10' - Python 3.11: - python.version: '3.11' - - maxParallel: 4 variables: group: sg-credentials @@ -65,20 +54,23 @@ jobs: # Otherwise we may hit the GitHub anonymous download limit. - task: UsePythonVersion@0 inputs: - versionSpec: '$(python.version)' - addToPath: True + versionSpec: ${{ parameters.python_version }} # Install all dependencies needed for running the tests. This command is good # for all OSes - - script: | - python -m pip install --upgrade pip setuptools wheel - python -m pip install -r tests/ci_requirements.txt - displayName: Install tools + - task: Bash@3 + displayName: Install dependencies + inputs: + targetType: inline + script: | + pip install --upgrade pip + pip install --upgrade setuptools wheel + pip install --upgrade --requirement tests/ci_requirements.txt # The {{}} syntax is meant for the the pre-processor of Azure pipeline. Every statement inside # a {{}} block will be evaluated and substituted before the file is parsed to create the jobs. # So here we're inserting an extra step if the template is being invoked for Windows. - - ${{ if eq(parameters.name, 'Windows') }}: + - ${{ if startsWith(parameters.vm_image, 'windows') }}: # On Windows, we need to update the certificates, the cert store is missing the newer one # from Amazon like some clients experienced a while back. Who would have thought Microsoft # would have been out of date! ;) @@ -92,10 +84,15 @@ jobs: # Runs the tests and generates test coverage. The tests results are uploaded to Azure Pipelines in the # Tests tab of the build and each test run will be named after the --test-run-title argument to pytest, # for example 'Windows - 2.7' - - bash: | - cp ./tests/example_config ./tests/config - pytest --durations=0 -v --cov shotgun_api3 --cov-report xml --test-run-title="${{parameters.name}}-$(python.version)" + - task: Bash@3 displayName: Running tests + inputs: + targetType: inline + script: | + cp ./tests/example_config ./tests/config + pytest --durations=0 -v \ + --cov shotgun_api3 --cov-report xml \ + --test-run-title="${{parameters.name}}-${{ parameters.python_version }}" env: # Pass the values needed to authenticate with the Flow Production Tracking site and create some entities. # Remember, on a pull request from a client or on forked repos, those variables @@ -130,21 +127,21 @@ jobs: SG_PLAYLIST_CODE: CI-$(python_api_human_login)-${{parameters.name}}-$(python.version) # Upload the code coverage result to codecov.io. - - ${{ if eq(parameters.name, 'Windows') }}: + - ${{ if startsWith(parameters.vm_image, 'windows') }}: - powershell: | $ProgressPreference = 'SilentlyContinue' Invoke-WebRequest -Uri https://uploader.codecov.io/latest/windows/codecov.exe -Outfile codecov.exe .\codecov.exe -f coverage.xml displayName: Uploading code coverage - - ${{ elseif eq(parameters.name, 'Linux') }}: + - ${{ elseif startsWith(parameters.vm_image, 'macos') }}: - script: | - curl -Os https://uploader.codecov.io/latest/linux/codecov + curl -Os https://uploader.codecov.io/v0.7.3/macos/codecov chmod +x codecov ./codecov -f coverage.xml displayName: Uploading code coverage - ${{ else }}: - - script: | - curl -Os https://uploader.codecov.io/v0.7.3/macos/codecov + - script: | + curl -Os https://uploader.codecov.io/latest/linux/codecov chmod +x codecov ./codecov -f coverage.xml - displayName: Uploading code coverage + displayName: Uploading code cover diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 0e465bf22..4e6222784 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -48,26 +48,36 @@ pr: include: - "*" +parameters: + - name: python_versions + type: object + default: + - '3.9' + - '3.10' + - '3.11' + + - name: os_versions + type: object + default: + - name: Linux + vm_image: ubuntu-latest + + - name: macOS + vm_image: macOS-latest + + - name: Windows + vm_image: windows-latest + # This here is the list of jobs we want to run for our build. # Jobs run in parallel. jobs: - template: azure-pipelines-templates/code_style_validation.yml - template: azure-pipelines-templates/type_checking.yml -# These are jobs templates, they allow to reduce the redundancy between -# variations of the same build. We pass in the image name -# and a friendly name that then template can then use to create jobs. -- template: azure-pipelines-templates/run-tests.yml - parameters: - name: Linux - vm_image: 'ubuntu-latest' - -- template: azure-pipelines-templates/run-tests.yml - parameters: - name: macOS - vm_image: 'macOS-latest' - -- template: azure-pipelines-templates/run-tests.yml - parameters: - name: Windows - vm_image: 'windows-latest' +- ${{ each os_version in parameters.os_versions }}: + - ${{ each python_version in parameters.python_versions }}: + - template: azure-pipelines-templates/run-tests.yml + parameters: + name: "${{ os_version.name }} Python ${{ python_version }}" + vm_image: ${{ os_version.vm_image }} + python_version: ${{ python_version }} From cd6dc10642751ec82ccd75ad6b434ab029d32f90 Mon Sep 17 00:00:00 2001 From: Julien Langlois Date: Fri, 12 Dec 2025 10:56:22 -0800 Subject: [PATCH 02/21] fixup! Tests --- azure-pipelines-templates/run-tests.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/azure-pipelines-templates/run-tests.yml b/azure-pipelines-templates/run-tests.yml index a4db3634d..c9b1d6268 100644 --- a/azure-pipelines-templates/run-tests.yml +++ b/azure-pipelines-templates/run-tests.yml @@ -140,8 +140,8 @@ jobs: ./codecov -f coverage.xml displayName: Uploading code coverage - ${{ else }}: - - script: | - curl -Os https://uploader.codecov.io/latest/linux/codecov - chmod +x codecov - ./codecov -f coverage.xml - displayName: Uploading code cover + - script: | + curl -Os https://uploader.codecov.io/latest/linux/codecov + chmod +x codecov + ./codecov -f coverage.xml + displayName: Uploading code cover From 036206870933c7664a4530fdf1997b2912ae9e8b Mon Sep 17 00:00:00 2001 From: Julien Langlois Date: Fri, 12 Dec 2025 10:58:38 -0800 Subject: [PATCH 03/21] fixup! fixup! Tests --- azure-pipelines-templates/run-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines-templates/run-tests.yml b/azure-pipelines-templates/run-tests.yml index c9b1d6268..9a40df750 100644 --- a/azure-pipelines-templates/run-tests.yml +++ b/azure-pipelines-templates/run-tests.yml @@ -144,4 +144,4 @@ jobs: curl -Os https://uploader.codecov.io/latest/linux/codecov chmod +x codecov ./codecov -f coverage.xml - displayName: Uploading code cover + displayName: Uploading code cover From 26be3a0107108bbf3421cea1a84d56d0908388d8 Mon Sep 17 00:00:00 2001 From: Julien Langlois Date: Thu, 11 Dec 2025 10:26:18 -0800 Subject: [PATCH 04/21] Tests --- .pre-commit-config.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 537da22cf..320aed3bb 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -47,3 +47,9 @@ repos: rev: 25.1.0 hooks: - id: black + +### does not work .... lots of errors +# - repo: https://github.com/pycqa/flake8 +# rev: 7.3.0# +# hooks: +# - id: flake8 From 6553ec7fe7963703bf0a15f455f25192fe44a09b Mon Sep 17 00:00:00 2001 From: Julien Langlois Date: Wed, 17 Dec 2025 13:21:37 -0800 Subject: [PATCH 05/21] Tests --- azure-pipelines.yml | 62 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 48 insertions(+), 14 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 059aa9e1b..b6d955a03 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -81,20 +81,54 @@ parameters: # This here is the list of jobs we want to run for our build. # Jobs run in parallel. jobs: -- template: build-pipeline.yml@templates - parameters: - # Python API does not follow the exact same Python version lifecycle than - # Toolkit. So we prefer to control the test execution here instead. - has_unit_tests: false +# - template: build-pipeline.yml@templates +# parameters: +# # Python API does not follow the exact same Python version lifecycle than +# # Toolkit. So we prefer to control the test execution here instead. +# has_unit_tests: false - has_ui_resources: false +# has_ui_resources: false -- template: azure-pipelines-templates/type_checking.yml +# - template: azure-pipelines-templates/type_checking.yml -- ${{ each os_version in parameters.os_versions }}: - - ${{ each python_version in parameters.python_versions }}: - - template: azure-pipelines-templates/run-tests.yml - parameters: - name: "${{ os_version.name }} Python ${{ python_version }}" - vm_image: ${{ os_version.vm_image }} - python_version: ${{ python_version }} + +# - ${{ each os_version in parameters.os_versions }}: +# - ${{ each python_version in parameters.python_versions }}: +# - template: azure-pipelines-templates/run-tests.yml +# parameters: +# name: "${{ os_version.name }} Python ${{ python_version }}" +# vm_image: ${{ os_version.vm_image }} +# python_version: ${{ python_version }} + + +- job: TODO Tests + strategy: + matrix: + linux_py310: + imageName: 'ubuntu-latest' + python.version: '3.10' + mac_py310: + imageName: 'macOS-latest' + python.version: '3.10' + windows_py310 : + imageName: 'windows-latest' + python.version: '3.10' + linux_py311: + imageName: 'ubuntu-latest' + python.version: '3.11' + mac_py311: + imageName: 'macOS-latest' + python.version: '3.11' + windows_py311 : + imageName: 'windows-latest' + python.version: '3.11' + maxParallel: 3 + pool: + vmImage: $(imageName) + steps: + - task: UsePythonVersion@0 + inputs: + versionSpec: ${{ python.version }} + + - script: | + python --version From 915326a2d1f6940684eb3aeff3efd04f5e7536ac Mon Sep 17 00:00:00 2001 From: Julien Langlois Date: Wed, 17 Dec 2025 13:23:23 -0800 Subject: [PATCH 06/21] tests --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index b6d955a03..b4481e67c 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -128,7 +128,7 @@ jobs: steps: - task: UsePythonVersion@0 inputs: - versionSpec: ${{ python.version }} + versionSpec: $(python.version) - script: | python --version From 0dca8a932e442794bf09d6194ac278d9cbb0888b Mon Sep 17 00:00:00 2001 From: Julien Langlois Date: Wed, 17 Dec 2025 13:24:34 -0800 Subject: [PATCH 07/21] fixup! tests --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index b4481e67c..0634ce09a 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -101,7 +101,7 @@ jobs: # python_version: ${{ python_version }} -- job: TODO Tests +- job: TODO_Tests strategy: matrix: linux_py310: From 9c56dfebcb986f7d1825b62228262191e9a7e27a Mon Sep 17 00:00:00 2001 From: Julien Langlois Date: Wed, 17 Dec 2025 13:29:43 -0800 Subject: [PATCH 08/21] tests --- azure-pipelines.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 0634ce09a..294776b1f 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -101,8 +101,7 @@ jobs: # python_version: ${{ python_version }} -- job: TODO_Tests - strategy: +- strategy: matrix: linux_py310: imageName: 'ubuntu-latest' @@ -123,6 +122,7 @@ jobs: imageName: 'windows-latest' python.version: '3.11' maxParallel: 3 + job: "Run tests ${{ matrix.imageName }}_${{ matrix.python.version }}" pool: vmImage: $(imageName) steps: @@ -132,3 +132,7 @@ jobs: - script: | python --version + python -c "import sys; print(sys.platform)" + + +# job: TODO_Tests_${{ matrix.imageName }}_${{ matrix.python.version }} From fe0c0cd77da345a0811a66da4c5ffca0226f2be5 Mon Sep 17 00:00:00 2001 From: Julien Langlois Date: Wed, 17 Dec 2025 13:30:39 -0800 Subject: [PATCH 09/21] tests --- azure-pipelines.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 294776b1f..cb8870607 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -101,7 +101,8 @@ jobs: # python_version: ${{ python_version }} -- strategy: +- job: "Run tests ${{ matrix.imageName }}_${{ matrix.python.version }}" + strategy: matrix: linux_py310: imageName: 'ubuntu-latest' @@ -122,7 +123,7 @@ jobs: imageName: 'windows-latest' python.version: '3.11' maxParallel: 3 - job: "Run tests ${{ matrix.imageName }}_${{ matrix.python.version }}" + pool: vmImage: $(imageName) steps: From c2d0afe50d0650a7d81bfc845434a0b19e8f98b3 Mon Sep 17 00:00:00 2001 From: Julien Langlois Date: Wed, 17 Dec 2025 13:31:37 -0800 Subject: [PATCH 10/21] tests --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index cb8870607..214898229 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -101,7 +101,7 @@ jobs: # python_version: ${{ python_version }} -- job: "Run tests ${{ matrix.imageName }}_${{ matrix.python.version }}" +- job: "Run tests $(imageName) $(python.version)" strategy: matrix: linux_py310: From b68c126f5b1a552932f110701d304fd253ac8b7f Mon Sep 17 00:00:00 2001 From: Julien Langlois Date: Wed, 17 Dec 2025 13:32:28 -0800 Subject: [PATCH 11/21] fixup! tests --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 214898229..f15a79a57 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -101,7 +101,7 @@ jobs: # python_version: ${{ python_version }} -- job: "Run tests $(imageName) $(python.version)" +- job: "Run tests" strategy: matrix: linux_py310: From 937840d0618202e1f604459a82663e4b04028fcf Mon Sep 17 00:00:00 2001 From: Julien Langlois Date: Wed, 17 Dec 2025 13:33:41 -0800 Subject: [PATCH 12/21] fixup! fixup! tests --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index f15a79a57..4626bc9a5 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -101,7 +101,7 @@ jobs: # python_version: ${{ python_version }} -- job: "Run tests" +- job: "Run_tests" strategy: matrix: linux_py310: From 3c9e5d903d061aa60dc6af996b8d2b184baadd4e Mon Sep 17 00:00:00 2001 From: Julien Langlois Date: Wed, 17 Dec 2025 13:37:48 -0800 Subject: [PATCH 13/21] Tests --- azure-pipelines.yml | 44 +++++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 4626bc9a5..1916a5244 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -101,29 +101,35 @@ jobs: # python_version: ${{ python_version }} -- job: "Run_tests" +- job: "Run_tests" ## I don't have to ... strategy: matrix: - linux_py310: - imageName: 'ubuntu-latest' - python.version: '3.10' - mac_py310: - imageName: 'macOS-latest' - python.version: '3.10' - windows_py310 : - imageName: 'windows-latest' - python.version: '3.10' - linux_py311: - imageName: 'ubuntu-latest' - python.version: '3.11' - mac_py311: - imageName: 'macOS-latest' - python.version: '3.11' - windows_py311 : - imageName: 'windows-latest' - python.version: '3.11' + ${{ each os_version in parameters.os_versions }}: + ${{ each python_version in parameters.python_versions }}: + job_${{ os_version.name }}_Python_${{ python_version }}: + imageName: '${{ os_version.vm_image }}' + python.version: '${{ python_version }}' + # linux_py310: + # imageName: 'ubuntu-latest' + # python.version: '3.10' + # mac_py310: + # imageName: 'macOS-latest' + # python.version: '3.10' + # windows_py310 : + # imageName: 'windows-latest' + # python.version: '3.10' + # linux_py311: + # imageName: 'ubuntu-latest' + # python.version: '3.11' + # mac_py311: + # imageName: 'macOS-latest' + # python.version: '3.11' + # windows_py311 : + # imageName: 'windows-latest' + # python.version: '3.11' maxParallel: 3 + displayName: "Run tests_${{ matrix.imageName }}_${{ matrix.python.version }}" pool: vmImage: $(imageName) steps: From 3b20e52cdaaafbceaac249275451cf50e81d3836 Mon Sep 17 00:00:00 2001 From: Julien Langlois Date: Wed, 17 Dec 2025 13:39:16 -0800 Subject: [PATCH 14/21] Tests --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 1916a5244..bc81c5eb7 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -129,7 +129,7 @@ jobs: # python.version: '3.11' maxParallel: 3 - displayName: "Run tests_${{ matrix.imageName }}_${{ matrix.python.version }}" + displayName: "Run tests_${{ imageName }}_${{ python.version }}" pool: vmImage: $(imageName) steps: From 73938e2e762380ca1633f54dd6711f9da82247a8 Mon Sep 17 00:00:00 2001 From: Julien Langlois Date: Wed, 17 Dec 2025 13:40:08 -0800 Subject: [PATCH 15/21] Tests --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index bc81c5eb7..4286b93dd 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -129,7 +129,7 @@ jobs: # python.version: '3.11' maxParallel: 3 - displayName: "Run tests_${{ imageName }}_${{ python.version }}" + displayName: "Run tests_$( imageName )_$( python.version )" pool: vmImage: $(imageName) steps: From 43f47a0cb241ba276fe4da910a944f5822d38cfb Mon Sep 17 00:00:00 2001 From: Julien Langlois Date: Wed, 17 Dec 2025 13:43:37 -0800 Subject: [PATCH 16/21] fixup! Tests --- azure-pipelines.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 4286b93dd..78869c26b 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -101,12 +101,12 @@ jobs: # python_version: ${{ python_version }} -- job: "Run_tests" ## I don't have to ... +- job: ## "Run_tests" ## I don't have to ... strategy: matrix: ${{ each os_version in parameters.os_versions }}: ${{ each python_version in parameters.python_versions }}: - job_${{ os_version.name }}_Python_${{ python_version }}: + Run_Tests_${{ os_version.name }}_Python_${{ python_version }}: imageName: '${{ os_version.vm_image }}' python.version: '${{ python_version }}' # linux_py310: @@ -129,7 +129,7 @@ jobs: # python.version: '3.11' maxParallel: 3 - displayName: "Run tests_$( imageName )_$( python.version )" + # displayName: "Run tests_$( imageName )_$( python.version )" pool: vmImage: $(imageName) steps: From 3e0635d72f91b28c1744e8d85731f51556689b1c Mon Sep 17 00:00:00 2001 From: Julien Langlois Date: Wed, 17 Dec 2025 13:46:14 -0800 Subject: [PATCH 17/21] fixup! fixup! Tests --- azure-pipelines.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 78869c26b..e9133335d 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -104,9 +104,9 @@ jobs: - job: ## "Run_tests" ## I don't have to ... strategy: matrix: - ${{ each os_version in parameters.os_versions }}: - ${{ each python_version in parameters.python_versions }}: - Run_Tests_${{ os_version.name }}_Python_${{ python_version }}: + ${{ each python_version in parameters.python_versions }}: + ${{ each os_version in parameters.os_versions }}: + "Run Tests ${{ os_version.name }} Python ${{ python_version }}": imageName: '${{ os_version.vm_image }}' python.version: '${{ python_version }}' # linux_py310: @@ -128,6 +128,7 @@ jobs: # imageName: 'windows-latest' # python.version: '3.11' maxParallel: 3 + # limiting the parallel jobs to 3 to avoid race condition issues between tests..... :( # displayName: "Run tests_$( imageName )_$( python.version )" pool: From cfa2380f948b5a4653c3e3644b11cdc16590f528 Mon Sep 17 00:00:00 2001 From: Julien Langlois Date: Wed, 17 Dec 2025 13:52:23 -0800 Subject: [PATCH 18/21] tests --- azure-pipelines-templates/run-tests.yml | 163 ++++++++++++------------ azure-pipelines.yml | 104 ++++++--------- 2 files changed, 125 insertions(+), 142 deletions(-) diff --git a/azure-pipelines-templates/run-tests.yml b/azure-pipelines-templates/run-tests.yml index 9a40df750..4f5e518f0 100644 --- a/azure-pipelines-templates/run-tests.yml +++ b/azure-pipelines-templates/run-tests.yml @@ -38,6 +38,8 @@ jobs: # name of the keys under the strategy.matrix scope. So for each OS we'll have " Python 3.9" and # " Python 3.10". - job: + strategy: + parallel: 3 displayName: ${{ parameters.name }} pool: vmImage: ${{ parameters.vm_image }} @@ -63,85 +65,88 @@ jobs: inputs: targetType: inline script: | - pip install --upgrade pip - pip install --upgrade setuptools wheel - pip install --upgrade --requirement tests/ci_requirements.txt + python --version + python -c "import sys; print(sys.platform)" - # The {{}} syntax is meant for the the pre-processor of Azure pipeline. Every statement inside - # a {{}} block will be evaluated and substituted before the file is parsed to create the jobs. - # So here we're inserting an extra step if the template is being invoked for Windows. - - ${{ if startsWith(parameters.vm_image, 'windows') }}: - # On Windows, we need to update the certificates, the cert store is missing the newer one - # from Amazon like some clients experienced a while back. Who would have thought Microsoft - # would have been out of date! ;) - - powershell: | - $cert_url = "https://www.amazontrust.com/repository/SFSRootCAG2.cer" - $cert_file = New-TemporaryFile - Invoke-WebRequest -Uri $cert_url -UseBasicParsing -OutFile $cert_file.FullName - Import-Certificate -FilePath $cert_file.FullName -CertStoreLocation Cert:\LocalMachine\Root - displayName: Updating OS Certificates + # pip install --upgrade pip + # pip install --upgrade setuptools wheel + # pip install --upgrade --requirement tests/ci_requirements.txt - # Runs the tests and generates test coverage. The tests results are uploaded to Azure Pipelines in the - # Tests tab of the build and each test run will be named after the --test-run-title argument to pytest, - # for example 'Windows - 2.7' - - task: Bash@3 - displayName: Running tests - inputs: - targetType: inline - script: | - cp ./tests/example_config ./tests/config - pytest --durations=0 -v \ - --cov shotgun_api3 --cov-report xml \ - --test-run-title="${{parameters.name}}-${{ parameters.python_version }}" - env: - # Pass the values needed to authenticate with the Flow Production Tracking site and create some entities. - # Remember, on a pull request from a client or on forked repos, those variables - # will be empty! - SG_SERVER_URL: $(ci_site) - SG_SCRIPT_NAME: $(ci_site_script_name) - SG_API_KEY: $(ci_site_script_key) - # The unit tests manipulate the user and project during the tests, which can cause collisions, - # so sandbox each build variant. - # Ideally, we would use the agent name here. The problem is that the agent name is in a build - # variable, so we can't edit it's value through a ${{replace(a,b,c)}} expression, which are evaluated before - # build variables are available. Because of this, we need to find another way to generate a - # unique login. So instead, we'll use the the name of the platform and the python version, - # which should make it unique. - SG_HUMAN_LOGIN: $(python_api_human_login)-${{parameters.name}}-$(python.version) - # This will give a user name like 'something macOS 2.7' - SG_HUMAN_NAME: $(python_api_human_name) ${{parameters.name}} $(python.version) - SG_HUMAN_PASSWORD: $(python_api_human_password) - # So, first, we need to make sure that two builds running at the same time do not manipulate - # the same entities, so we're sandboxing build nodes based on their name. - SG_PROJECT_NAME: Python API CI - $(Agent.Name) - # The entities created and then reused between tests assume that the same user is always - # manipulating them. Because different builds will be assigned different agents and therefore - # different projects, it means each project needs to have an entity specific to a given user. - # Again, this would have been a lot simpler if we could simply have had a login based on the - # agent name, but alas, the agent name has a space in it which needs to be replaced to something - # else and string substitution can't be made on build variables, only template parameters. - SG_ASSET_CODE: CI-$(python_api_human_login)-${{parameters.name}}-$(python.version) - SG_VERSION_CODE: CI-$(python_api_human_login)-${{parameters.name}}-$(python.version) - SG_SHOT_CODE: CI-$(python_api_human_login)-${{parameters.name}}-$(python.version) - SG_TASK_CONTENT: CI-$(python_api_human_login)-${{parameters.name}}-$(python.version) - SG_PLAYLIST_CODE: CI-$(python_api_human_login)-${{parameters.name}}-$(python.version) + # # The {{}} syntax is meant for the the pre-processor of Azure pipeline. Every statement inside + # # a {{}} block will be evaluated and substituted before the file is parsed to create the jobs. + # # So here we're inserting an extra step if the template is being invoked for Windows. + # - ${{ if startsWith(parameters.vm_image, 'windows') }}: + # # On Windows, we need to update the certificates, the cert store is missing the newer one + # # from Amazon like some clients experienced a while back. Who would have thought Microsoft + # # would have been out of date! ;) + # - powershell: | + # $cert_url = "https://www.amazontrust.com/repository/SFSRootCAG2.cer" + # $cert_file = New-TemporaryFile + # Invoke-WebRequest -Uri $cert_url -UseBasicParsing -OutFile $cert_file.FullName + # Import-Certificate -FilePath $cert_file.FullName -CertStoreLocation Cert:\LocalMachine\Root + # displayName: Updating OS Certificates + + # # Runs the tests and generates test coverage. The tests results are uploaded to Azure Pipelines in the + # # Tests tab of the build and each test run will be named after the --test-run-title argument to pytest, + # # for example 'Windows - 2.7' + # - task: Bash@3 + # displayName: Running tests + # inputs: + # targetType: inline + # script: | + # cp ./tests/example_config ./tests/config + # pytest --durations=0 -v \ + # --cov shotgun_api3 --cov-report xml \ + # --test-run-title="${{parameters.name}}-${{ parameters.python_version }}" + # env: + # # Pass the values needed to authenticate with the Flow Production Tracking site and create some entities. + # # Remember, on a pull request from a client or on forked repos, those variables + # # will be empty! + # SG_SERVER_URL: $(ci_site) + # SG_SCRIPT_NAME: $(ci_site_script_name) + # SG_API_KEY: $(ci_site_script_key) + # # The unit tests manipulate the user and project during the tests, which can cause collisions, + # # so sandbox each build variant. + # # Ideally, we would use the agent name here. The problem is that the agent name is in a build + # # variable, so we can't edit it's value through a ${{replace(a,b,c)}} expression, which are evaluated before + # # build variables are available. Because of this, we need to find another way to generate a + # # unique login. So instead, we'll use the the name of the platform and the python version, + # # which should make it unique. + # SG_HUMAN_LOGIN: $(python_api_human_login)-${{parameters.name}}-$(python.version) + # # This will give a user name like 'something macOS 2.7' + # SG_HUMAN_NAME: $(python_api_human_name) ${{parameters.name}} $(python.version) + # SG_HUMAN_PASSWORD: $(python_api_human_password) + # # So, first, we need to make sure that two builds running at the same time do not manipulate + # # the same entities, so we're sandboxing build nodes based on their name. + # SG_PROJECT_NAME: Python API CI - $(Agent.Name) + # # The entities created and then reused between tests assume that the same user is always + # # manipulating them. Because different builds will be assigned different agents and therefore + # # different projects, it means each project needs to have an entity specific to a given user. + # # Again, this would have been a lot simpler if we could simply have had a login based on the + # # agent name, but alas, the agent name has a space in it which needs to be replaced to something + # # else and string substitution can't be made on build variables, only template parameters. + # SG_ASSET_CODE: CI-$(python_api_human_login)-${{parameters.name}}-$(python.version) + # SG_VERSION_CODE: CI-$(python_api_human_login)-${{parameters.name}}-$(python.version) + # SG_SHOT_CODE: CI-$(python_api_human_login)-${{parameters.name}}-$(python.version) + # SG_TASK_CONTENT: CI-$(python_api_human_login)-${{parameters.name}}-$(python.version) + # SG_PLAYLIST_CODE: CI-$(python_api_human_login)-${{parameters.name}}-$(python.version) - # Upload the code coverage result to codecov.io. - - ${{ if startsWith(parameters.vm_image, 'windows') }}: - - powershell: | - $ProgressPreference = 'SilentlyContinue' - Invoke-WebRequest -Uri https://uploader.codecov.io/latest/windows/codecov.exe -Outfile codecov.exe - .\codecov.exe -f coverage.xml - displayName: Uploading code coverage - - ${{ elseif startsWith(parameters.vm_image, 'macos') }}: - - script: | - curl -Os https://uploader.codecov.io/v0.7.3/macos/codecov - chmod +x codecov - ./codecov -f coverage.xml - displayName: Uploading code coverage - - ${{ else }}: - - script: | - curl -Os https://uploader.codecov.io/latest/linux/codecov - chmod +x codecov - ./codecov -f coverage.xml - displayName: Uploading code cover + # # Upload the code coverage result to codecov.io. + # - ${{ if startsWith(parameters.vm_image, 'windows') }}: + # - powershell: | + # $ProgressPreference = 'SilentlyContinue' + # Invoke-WebRequest -Uri https://uploader.codecov.io/latest/windows/codecov.exe -Outfile codecov.exe + # .\codecov.exe -f coverage.xml + # displayName: Uploading code coverage + # - ${{ elseif startsWith(parameters.vm_image, 'macos') }}: + # - script: | + # curl -Os https://uploader.codecov.io/v0.7.3/macos/codecov + # chmod +x codecov + # ./codecov -f coverage.xml + # displayName: Uploading code coverage + # - ${{ else }}: + # - script: | + # curl -Os https://uploader.codecov.io/latest/linux/codecov + # chmod +x codecov + # ./codecov -f coverage.xml + # displayName: Uploading code cover diff --git a/azure-pipelines.yml b/azure-pipelines.yml index e9133335d..902f8d92d 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -81,66 +81,44 @@ parameters: # This here is the list of jobs we want to run for our build. # Jobs run in parallel. jobs: -# - template: build-pipeline.yml@templates -# parameters: -# # Python API does not follow the exact same Python version lifecycle than -# # Toolkit. So we prefer to control the test execution here instead. -# has_unit_tests: false - -# has_ui_resources: false - -# - template: azure-pipelines-templates/type_checking.yml - - -# - ${{ each os_version in parameters.os_versions }}: -# - ${{ each python_version in parameters.python_versions }}: -# - template: azure-pipelines-templates/run-tests.yml -# parameters: -# name: "${{ os_version.name }} Python ${{ python_version }}" -# vm_image: ${{ os_version.vm_image }} -# python_version: ${{ python_version }} - - -- job: ## "Run_tests" ## I don't have to ... - strategy: - matrix: - ${{ each python_version in parameters.python_versions }}: - ${{ each os_version in parameters.os_versions }}: - "Run Tests ${{ os_version.name }} Python ${{ python_version }}": - imageName: '${{ os_version.vm_image }}' - python.version: '${{ python_version }}' - # linux_py310: - # imageName: 'ubuntu-latest' - # python.version: '3.10' - # mac_py310: - # imageName: 'macOS-latest' - # python.version: '3.10' - # windows_py310 : - # imageName: 'windows-latest' - # python.version: '3.10' - # linux_py311: - # imageName: 'ubuntu-latest' - # python.version: '3.11' - # mac_py311: - # imageName: 'macOS-latest' - # python.version: '3.11' - # windows_py311 : - # imageName: 'windows-latest' - # python.version: '3.11' - maxParallel: 3 - # limiting the parallel jobs to 3 to avoid race condition issues between tests..... :( - - # displayName: "Run tests_$( imageName )_$( python.version )" - pool: - vmImage: $(imageName) - steps: - - task: UsePythonVersion@0 - inputs: - versionSpec: $(python.version) - - - script: | - python --version - python -c "import sys; print(sys.platform)" - - -# job: TODO_Tests_${{ matrix.imageName }}_${{ matrix.python.version }} +- template: build-pipeline.yml@templates + parameters: + # Python API does not follow the exact same Python version lifecycle than + # Toolkit. So we prefer to control the test execution here instead. + has_unit_tests: false + + has_ui_resources: false + +- template: azure-pipelines-templates/type_checking.yml + +- ${{ each os_version in parameters.os_versions }}: + - ${{ each python_version in parameters.python_versions }}: + - template: azure-pipelines-templates/run-tests.yml + parameters: + name: "${{ os_version.name }} Python ${{ python_version }}" + vm_image: ${{ os_version.vm_image }} + python_version: ${{ python_version }} + +# - job: ## "Run_tests" ## I don't have to ... +# strategy: +# matrix: +# ${{ each python_version in parameters.python_versions }}: +# ${{ each os_version in parameters.os_versions }}: +# "Run Tests ${{ os_version.name }} Python ${{ python_version }}": +# imageName: '${{ os_version.vm_image }}' +# python.version: '${{ python_version }}' + +# maxParallel: 3 +# # limiting the parallel jobs to 3 to avoid race condition issues between tests..... :( + +# # displayName: "Run tests_$( imageName )_$( python.version )" +# pool: +# vmImage: $(imageName) +# steps: +# - task: UsePythonVersion@0 +# inputs: +# versionSpec: $(python.version) + +# - script: | +# python --version +# python -c "import sys; print(sys.platform)" From f8b73968a8574673893fe2ecac2e2b2fcca7cef1 Mon Sep 17 00:00:00 2001 From: Julien Langlois Date: Wed, 17 Dec 2025 13:59:25 -0800 Subject: [PATCH 19/21] Tests --- azure-pipelines-templates/run-tests.yml | 68 ++++++++++++------------- azure-pipelines.yml | 52 +++++++++++-------- 2 files changed, 64 insertions(+), 56 deletions(-) diff --git a/azure-pipelines-templates/run-tests.yml b/azure-pipelines-templates/run-tests.yml index 4f5e518f0..4edbb6622 100644 --- a/azure-pipelines-templates/run-tests.yml +++ b/azure-pipelines-templates/run-tests.yml @@ -28,45 +28,45 @@ # This is the list of parameters for this template and their default values. parameters: - name: '' - vm_image: '' + # name: '' + # vm_image: '' python_version: '' -jobs: - # The job will be named after the OS and Azure will suffix the strategy to make it unique - # so we'll have a job name "Windows Python 3.9" for example. What's a strategy? Strategies are the - # name of the keys under the strategy.matrix scope. So for each OS we'll have " Python 3.9" and - # " Python 3.10". -- job: - strategy: - parallel: 3 - displayName: ${{ parameters.name }} - pool: - vmImage: ${{ parameters.vm_image }} +# jobs: +# # The job will be named after the OS and Azure will suffix the strategy to make it unique +# # so we'll have a job name "Windows Python 3.9" for example. What's a strategy? Strategies are the +# # name of the keys under the strategy.matrix scope. So for each OS we'll have " Python 3.9" and +# # " Python 3.10". +# - job: +# strategy: +# parallel: 3 +# displayName: ${{ parameters.name }} +# pool: +# vmImage: ${{ parameters.vm_image }} - variables: - group: sg-credentials +# variables: +# group: sg-credentials - # These are the steps that will be executed inside each job. - steps: - # Specifies which version of Python we want to use. That's where the strategy comes in. - # Each job will share this set of steps, but each of them will receive a different - # $(python.version) - # TODO: We should provide `githubToken` if we want to download a python release. - # Otherwise we may hit the GitHub anonymous download limit. - - task: UsePythonVersion@0 - inputs: - versionSpec: ${{ parameters.python_version }} - # Install all dependencies needed for running the tests. This command is good - # for all OSes - - task: Bash@3 - displayName: Install dependencies - inputs: - targetType: inline - script: | - python --version - python -c "import sys; print(sys.platform)" +steps: +# Specifies which version of Python we want to use. That's where the strategy comes in. +# Each job will share this set of steps, but each of them will receive a different +# $(python.version) +# TODO: We should provide `githubToken` if we want to download a python release. +# Otherwise we may hit the GitHub anonymous download limit. +- task: UsePythonVersion@0 + inputs: + versionSpec: ${{ parameters.python_version }} + +# Install all dependencies needed for running the tests. This command is good +# for all OSes +- task: Bash@3 + displayName: Install dependencies + inputs: + targetType: inline + script: | + python --version + python -c "import sys; print(sys.platform)" # pip install --upgrade pip # pip install --upgrade setuptools wheel diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 902f8d92d..b1ed2fc96 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -91,30 +91,38 @@ jobs: - template: azure-pipelines-templates/type_checking.yml -- ${{ each os_version in parameters.os_versions }}: - - ${{ each python_version in parameters.python_versions }}: +# - ${{ each os_version in parameters.os_versions }}: +# - ${{ each python_version in parameters.python_versions }}: +# - template: azure-pipelines-templates/run-tests.yml +# parameters: +# name: "${{ os_version.name }} Python ${{ python_version }}" +# vm_image: ${{ os_version.vm_image }} +# python_version: ${{ python_version }} + +- job: + strategy: + matrix: + ${{ each python_version in parameters.python_versions }}: + ${{ each os_version in parameters.os_versions }}: + "Run Tests ${{ os_version.name }} Python ${{ python_version }}": + imageName: '${{ os_version.vm_image }}' + python.version: '${{ python_version }}' + + maxParallel: 3 + # limiting the parallel jobs to 3 to avoid race condition issues between tests..... :( + + pool: + vmImage: $(imageName) + + variables: + group: sg-credentials + + steps: - template: azure-pipelines-templates/run-tests.yml parameters: - name: "${{ os_version.name }} Python ${{ python_version }}" - vm_image: ${{ os_version.vm_image }} - python_version: ${{ python_version }} - -# - job: ## "Run_tests" ## I don't have to ... -# strategy: -# matrix: -# ${{ each python_version in parameters.python_versions }}: -# ${{ each os_version in parameters.os_versions }}: -# "Run Tests ${{ os_version.name }} Python ${{ python_version }}": -# imageName: '${{ os_version.vm_image }}' -# python.version: '${{ python_version }}' - -# maxParallel: 3 -# # limiting the parallel jobs to 3 to avoid race condition issues between tests..... :( - -# # displayName: "Run tests_$( imageName )_$( python.version )" -# pool: -# vmImage: $(imageName) -# steps: + python_version: $(python.version) + + # - task: UsePythonVersion@0 # inputs: # versionSpec: $(python.version) From afecd1300738e6a2c75250473835d637bac5ea7e Mon Sep 17 00:00:00 2001 From: Julien Langlois Date: Wed, 17 Dec 2025 14:14:48 -0800 Subject: [PATCH 20/21] Tests --- azure-pipelines-templates/run-tests.yml | 191 ++++++++++++------------ azure-pipelines.yml | 40 ++--- 2 files changed, 109 insertions(+), 122 deletions(-) diff --git a/azure-pipelines-templates/run-tests.yml b/azure-pipelines-templates/run-tests.yml index 4edbb6622..1bea4baa5 100644 --- a/azure-pipelines-templates/run-tests.yml +++ b/azure-pipelines-templates/run-tests.yml @@ -49,104 +49,103 @@ parameters: steps: -# Specifies which version of Python we want to use. That's where the strategy comes in. -# Each job will share this set of steps, but each of them will receive a different -# $(python.version) -# TODO: We should provide `githubToken` if we want to download a python release. -# Otherwise we may hit the GitHub anonymous download limit. -- task: UsePythonVersion@0 - inputs: - versionSpec: ${{ parameters.python_version }} + # Specifies which version of Python we want to use. That's where the strategy comes in. + # Each job will share this set of steps, but each of them will receive a different + # $(python.version) + # TODO: We should provide `githubToken` if we want to download a python release. + # Otherwise we may hit the GitHub anonymous download limit. + - task: UsePythonVersion@0 + inputs: + versionSpec: ${{ parameters.python_version }} -# Install all dependencies needed for running the tests. This command is good -# for all OSes -- task: Bash@3 - displayName: Install dependencies - inputs: - targetType: inline - script: | - python --version + # Install all dependencies needed for running the tests. This command is good + # for all OSes + - task: Bash@3 + displayName: Install dependencies + inputs: + targetType: inline + script: | + python --version python -c "import sys; print(sys.platform)" + pip install --upgrade pip + pip install --upgrade setuptools wheel + pip install --upgrade --requirement tests/ci_requirements.txt - # pip install --upgrade pip - # pip install --upgrade setuptools wheel - # pip install --upgrade --requirement tests/ci_requirements.txt + # The {{}} syntax is meant for the the pre-processor of Azure pipeline. Every statement inside + # a {{}} block will be evaluated and substituted before the file is parsed to create the jobs. + # So here we're inserting an extra step if the template is being invoked for Windows. + - ${{ if startsWith(parameters.vm_image, 'windows') }}: + # On Windows, we need to update the certificates, the cert store is missing the newer one + # from Amazon like some clients experienced a while back. Who would have thought Microsoft + # would have been out of date! ;) + - powershell: | + $cert_url = "https://www.amazontrust.com/repository/SFSRootCAG2.cer" + $cert_file = New-TemporaryFile + Invoke-WebRequest -Uri $cert_url -UseBasicParsing -OutFile $cert_file.FullName + Import-Certificate -FilePath $cert_file.FullName -CertStoreLocation Cert:\LocalMachine\Root + displayName: Updating OS Certificates - # # The {{}} syntax is meant for the the pre-processor of Azure pipeline. Every statement inside - # # a {{}} block will be evaluated and substituted before the file is parsed to create the jobs. - # # So here we're inserting an extra step if the template is being invoked for Windows. - # - ${{ if startsWith(parameters.vm_image, 'windows') }}: - # # On Windows, we need to update the certificates, the cert store is missing the newer one - # # from Amazon like some clients experienced a while back. Who would have thought Microsoft - # # would have been out of date! ;) - # - powershell: | - # $cert_url = "https://www.amazontrust.com/repository/SFSRootCAG2.cer" - # $cert_file = New-TemporaryFile - # Invoke-WebRequest -Uri $cert_url -UseBasicParsing -OutFile $cert_file.FullName - # Import-Certificate -FilePath $cert_file.FullName -CertStoreLocation Cert:\LocalMachine\Root - # displayName: Updating OS Certificates + # Runs the tests and generates test coverage. The tests results are uploaded to Azure Pipelines in the + # Tests tab of the build and each test run will be named after the --test-run-title argument to pytest, + # for example 'Windows - 2.7' + - task: Bash@3 + displayName: Running tests + inputs: + targetType: inline + script: | + cp ./tests/example_config ./tests/config + pytest --durations=0 -v \ + --cov shotgun_api3 --cov-report xml \ + --test-run-title="${{parameters.name}}-${{ parameters.python_version }}" + env: + # Pass the values needed to authenticate with the Flow Production Tracking site and create some entities. + # Remember, on a pull request from a client or on forked repos, those variables + # will be empty! + SG_SERVER_URL: $(ci_site) + SG_SCRIPT_NAME: $(ci_site_script_name) + SG_API_KEY: $(ci_site_script_key) + # The unit tests manipulate the user and project during the tests, which can cause collisions, + # so sandbox each build variant. + # Ideally, we would use the agent name here. The problem is that the agent name is in a build + # variable, so we can't edit it's value through a ${{replace(a,b,c)}} expression, which are evaluated before + # build variables are available. Because of this, we need to find another way to generate a + # unique login. So instead, we'll use the the name of the platform and the python version, + # which should make it unique. + SG_HUMAN_LOGIN: $(python_api_human_login)-${{parameters.name}}-$(python.version) + # This will give a user name like 'something macOS 2.7' + SG_HUMAN_NAME: $(python_api_human_name) ${{parameters.name}} $(python.version) + SG_HUMAN_PASSWORD: $(python_api_human_password) + # So, first, we need to make sure that two builds running at the same time do not manipulate + # the same entities, so we're sandboxing build nodes based on their name. + SG_PROJECT_NAME: Python API CI - $(Agent.Name) + # The entities created and then reused between tests assume that the same user is always + # manipulating them. Because different builds will be assigned different agents and therefore + # different projects, it means each project needs to have an entity specific to a given user. + # Again, this would have been a lot simpler if we could simply have had a login based on the + # agent name, but alas, the agent name has a space in it which needs to be replaced to something + # else and string substitution can't be made on build variables, only template parameters. + SG_ASSET_CODE: CI-$(python_api_human_login)-${{parameters.name}}-$(python.version) + SG_VERSION_CODE: CI-$(python_api_human_login)-${{parameters.name}}-$(python.version) + SG_SHOT_CODE: CI-$(python_api_human_login)-${{parameters.name}}-$(python.version) + SG_TASK_CONTENT: CI-$(python_api_human_login)-${{parameters.name}}-$(python.version) + SG_PLAYLIST_CODE: CI-$(python_api_human_login)-${{parameters.name}}-$(python.version) - # # Runs the tests and generates test coverage. The tests results are uploaded to Azure Pipelines in the - # # Tests tab of the build and each test run will be named after the --test-run-title argument to pytest, - # # for example 'Windows - 2.7' - # - task: Bash@3 - # displayName: Running tests - # inputs: - # targetType: inline - # script: | - # cp ./tests/example_config ./tests/config - # pytest --durations=0 -v \ - # --cov shotgun_api3 --cov-report xml \ - # --test-run-title="${{parameters.name}}-${{ parameters.python_version }}" - # env: - # # Pass the values needed to authenticate with the Flow Production Tracking site and create some entities. - # # Remember, on a pull request from a client or on forked repos, those variables - # # will be empty! - # SG_SERVER_URL: $(ci_site) - # SG_SCRIPT_NAME: $(ci_site_script_name) - # SG_API_KEY: $(ci_site_script_key) - # # The unit tests manipulate the user and project during the tests, which can cause collisions, - # # so sandbox each build variant. - # # Ideally, we would use the agent name here. The problem is that the agent name is in a build - # # variable, so we can't edit it's value through a ${{replace(a,b,c)}} expression, which are evaluated before - # # build variables are available. Because of this, we need to find another way to generate a - # # unique login. So instead, we'll use the the name of the platform and the python version, - # # which should make it unique. - # SG_HUMAN_LOGIN: $(python_api_human_login)-${{parameters.name}}-$(python.version) - # # This will give a user name like 'something macOS 2.7' - # SG_HUMAN_NAME: $(python_api_human_name) ${{parameters.name}} $(python.version) - # SG_HUMAN_PASSWORD: $(python_api_human_password) - # # So, first, we need to make sure that two builds running at the same time do not manipulate - # # the same entities, so we're sandboxing build nodes based on their name. - # SG_PROJECT_NAME: Python API CI - $(Agent.Name) - # # The entities created and then reused between tests assume that the same user is always - # # manipulating them. Because different builds will be assigned different agents and therefore - # # different projects, it means each project needs to have an entity specific to a given user. - # # Again, this would have been a lot simpler if we could simply have had a login based on the - # # agent name, but alas, the agent name has a space in it which needs to be replaced to something - # # else and string substitution can't be made on build variables, only template parameters. - # SG_ASSET_CODE: CI-$(python_api_human_login)-${{parameters.name}}-$(python.version) - # SG_VERSION_CODE: CI-$(python_api_human_login)-${{parameters.name}}-$(python.version) - # SG_SHOT_CODE: CI-$(python_api_human_login)-${{parameters.name}}-$(python.version) - # SG_TASK_CONTENT: CI-$(python_api_human_login)-${{parameters.name}}-$(python.version) - # SG_PLAYLIST_CODE: CI-$(python_api_human_login)-${{parameters.name}}-$(python.version) - - # # Upload the code coverage result to codecov.io. - # - ${{ if startsWith(parameters.vm_image, 'windows') }}: - # - powershell: | - # $ProgressPreference = 'SilentlyContinue' - # Invoke-WebRequest -Uri https://uploader.codecov.io/latest/windows/codecov.exe -Outfile codecov.exe - # .\codecov.exe -f coverage.xml - # displayName: Uploading code coverage - # - ${{ elseif startsWith(parameters.vm_image, 'macos') }}: - # - script: | - # curl -Os https://uploader.codecov.io/v0.7.3/macos/codecov - # chmod +x codecov - # ./codecov -f coverage.xml - # displayName: Uploading code coverage - # - ${{ else }}: - # - script: | - # curl -Os https://uploader.codecov.io/latest/linux/codecov - # chmod +x codecov - # ./codecov -f coverage.xml - # displayName: Uploading code cover + # Upload the code coverage result to codecov.io. + - ${{ if startsWith(parameters.vm_image, 'windows') }}: + - powershell: | + $ProgressPreference = 'SilentlyContinue' + Invoke-WebRequest -Uri https://uploader.codecov.io/latest/windows/codecov.exe -Outfile codecov.exe + .\codecov.exe -f coverage.xml + displayName: Uploading code coverage + - ${{ elseif startsWith(parameters.vm_image, 'macos') }}: + - script: | + curl -Os https://uploader.codecov.io/v0.7.3/macos/codecov + chmod +x codecov + ./codecov -f coverage.xml + displayName: Uploading code coverage + - ${{ else }}: + - script: | + curl -Os https://uploader.codecov.io/latest/linux/codecov + chmod +x codecov + ./codecov -f coverage.xml + displayName: Uploading code cover diff --git a/azure-pipelines.yml b/azure-pipelines.yml index b1ed2fc96..e932eeab1 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -59,24 +59,28 @@ pr: - "*" parameters: - - name: python_versions + - name: test_python_versions type: object default: - '3.9' - '3.10' - '3.11' - - name: os_versions + - name: test_os_versions type: object default: - - name: Linux - vm_image: ubuntu-latest + - name: Windows + vm_image: windows-latest + # Select Windows first because it's slower - name: macOS vm_image: macOS-latest + # then mac because 2nd slower + + - name: Linux + vm_image: ubuntu-latest + # finally Linux is the fastest - - name: Windows - vm_image: windows-latest # This here is the list of jobs we want to run for our build. # Jobs run in parallel. @@ -91,20 +95,13 @@ jobs: - template: azure-pipelines-templates/type_checking.yml -# - ${{ each os_version in parameters.os_versions }}: -# - ${{ each python_version in parameters.python_versions }}: -# - template: azure-pipelines-templates/run-tests.yml -# parameters: -# name: "${{ os_version.name }} Python ${{ python_version }}" -# vm_image: ${{ os_version.vm_image }} -# python_version: ${{ python_version }} - +# Run tests for all combinations of Python and OS - job: strategy: matrix: - ${{ each python_version in parameters.python_versions }}: - ${{ each os_version in parameters.os_versions }}: - "Run Tests ${{ os_version.name }} Python ${{ python_version }}": + ${{ each python_version in parameters.test_python_versions }}: + ${{ each os_version in parameters.test_os_versions }}: + "Tests ${{ os_version.name }} Python ${{ python_version }}": imageName: '${{ os_version.vm_image }}' python.version: '${{ python_version }}' @@ -121,12 +118,3 @@ jobs: - template: azure-pipelines-templates/run-tests.yml parameters: python_version: $(python.version) - - -# - task: UsePythonVersion@0 -# inputs: -# versionSpec: $(python.version) - -# - script: | -# python --version -# python -c "import sys; print(sys.platform)" From 254e964dd2adcd6bdc0ba70ef7add10afcbe9b42 Mon Sep 17 00:00:00 2001 From: Julien Langlois Date: Wed, 17 Dec 2025 14:21:57 -0800 Subject: [PATCH 21/21] More tests --- azure-pipelines-templates/run-tests.yml | 9 +++------ azure-pipelines.yml | 3 --- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/azure-pipelines-templates/run-tests.yml b/azure-pipelines-templates/run-tests.yml index 1bea4baa5..60c8b9b01 100644 --- a/azure-pipelines-templates/run-tests.yml +++ b/azure-pipelines-templates/run-tests.yml @@ -1,5 +1,5 @@ # ----------------------------------------------------------------------------- -# Copyright (c) 2009-2021, Shotgun Software Inc. +# Copyright (c) 2009-2025, Shotgun Software Inc. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: @@ -44,14 +44,11 @@ parameters: # pool: # vmImage: ${{ parameters.vm_image }} -# variables: -# group: sg-credentials + variables: + group: sg-credentials steps: - # Specifies which version of Python we want to use. That's where the strategy comes in. - # Each job will share this set of steps, but each of them will receive a different - # $(python.version) # TODO: We should provide `githubToken` if we want to download a python release. # Otherwise we may hit the GitHub anonymous download limit. - task: UsePythonVersion@0 diff --git a/azure-pipelines.yml b/azure-pipelines.yml index e932eeab1..a2c919407 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -111,9 +111,6 @@ jobs: pool: vmImage: $(imageName) - variables: - group: sg-credentials - steps: - template: azure-pipelines-templates/run-tests.yml parameters: