11# -----------------------------------------------------------------------------
2- # Copyright (c) 2009-2021 , Shotgun Software Inc.
2+ # Copyright (c) 2009-2025 , Shotgun Software Inc.
33#
44# Redistribution and use in source and binary forms, with or without
55# modification, are permitted provided that the following conditions are met:
2828
2929# This is the list of parameters for this template and their default values.
3030parameters :
31- name : ' '
31+ os_name : ' '
3232 vm_image : ' '
33+ python_version : ' '
3334
3435jobs :
3536 # The job will be named after the OS and Azure will suffix the strategy to make it unique
3637 # so we'll have a job name "Windows Python 3.9" for example. What's a strategy? Strategies are the
3738 # name of the keys under the strategy.matrix scope. So for each OS we'll have "<OS> Python 3.9" and
3839 # "<OS> Python 3.10".
39- - job : ${{ parameters.name }}
40+ - job :
41+ displayName : " ${{ parameters.os_name }} Python ${{ parameters.python_version }}"
4042 pool :
4143 vmImage : ${{ parameters.vm_image }}
42- # The strategy is another way of removing repetition. It will create one job per entry in the
43- # matrix.
44- strategy :
45- matrix :
46- # We support these versions of Python.
47- # Python 3.9:
48- # python.version: '3.9'
49- # Python 3.10:
50- # python.version: '3.10'
51- Python 3.11 :
52- python.version : ' 3.11'
53- Python 3.13 :
54- python.version : ' 3.13'
55-
56- # # Keep compat
57- # Python 3.7:
58- # python.version: pypy3.7
59-
60- maxParallel : 2
61- # Looks like too much parallelle creates race condition issues between tests..... :(
6244
6345 variables :
6446 group : sg-credentials
6547
6648 # These are the steps that will be executed inside each job.
6749 steps :
68- # Specifies which version of Python we want to use. That's where the strategy comes in.
69- # Each job will share this set of steps, but each of them will receive a different
70- # $(python.version)
50+ # Specifies which version of Python we want to use.
7151 # TODO: We should provide `githubToken` if we want to download a python release.
7252 # Otherwise we may hit the GitHub anonymous download limit.
7353 - task : UsePythonVersion@0
7454 inputs :
75- versionSpec : ' $(python.version) '
55+ versionSpec : ${{ parameters.python_version }}
7656
7757 # Install all dependencies needed for running the tests. This command is good
7858 # for all OSes
79- - script : |
80- python -m pip install --upgrade pip
81- python -m pip install --upgrade pip setuptools wheel
82- python -m pip install --upgrade -r tests/ci_requirements.txt
83- displayName: Install tools
59+ - task : Bash@3
60+ displayName : Install dependencies
61+ inputs :
62+ targetType : inline
63+ script : |
64+ pip install --upgrade pip
65+ pip install --upgrade setuptools wheel
66+ pip install --upgrade --requirement tests/ci_requirements.txt
8467
8568 # The {{}} syntax is meant for the the pre-processor of Azure pipeline. Every statement inside
8669 # a {{}} block will be evaluated and substituted before the file is parsed to create the jobs.
8770 # So here we're inserting an extra step if the template is being invoked for Windows.
88- - ${{ if eq(parameters.name , 'Windows') }} :
71+ - ${{ if eq(parameters.os_name , 'Windows') }} :
8972 # On Windows, we need to update the certificates, the cert store is missing the newer one
9073 # from Amazon like some clients experienced a while back. Who would have thought Microsoft
9174 # would have been out of date! ;)
@@ -99,11 +82,15 @@ jobs:
9982 # Runs the tests and generates test coverage. The tests results are uploaded to Azure Pipelines in the
10083 # Tests tab of the build and each test run will be named after the --test-run-title argument to pytest,
10184 # for example 'Windows - 2.7'
102- # # pytest --durations=0 -v --cov shotgun_api3 --cov-report xml --test-run-title="${{parameters.name}}-$(python.version)"
103- - bash : |
104- cp ./tests/example_config ./tests/config
105- pytest --durations=0 -v --cov shotgun_api3 --cov-report xml --test-run-title="${{parameters.name}}-$(python.version)"
85+ - task : Bash@3
10686 displayName : Running tests
87+ inputs :
88+ targetType : inline
89+ script : |
90+ cp ./tests/example_config ./tests/config
91+ pytest --durations=0 -v \
92+ --cov shotgun_api3 --cov-report xml \
93+ --test-run-title="${{ parameters.os_name }}-${{ parameters.python_version }}"
10794 env :
10895 # Pass the values needed to authenticate with the Flow Production Tracking site and create some entities.
10996 # Remember, on a pull request from a client or on forked repos, those variables
@@ -118,9 +105,9 @@ jobs:
118105 # build variables are available. Because of this, we need to find another way to generate a
119106 # unique login. So instead, we'll use the the name of the platform and the python version,
120107 # which should make it unique.
121- SG_HUMAN_LOGIN: $(python_api_human_login)-${{parameters.name }}-$(python.version)
108+ SG_HUMAN_LOGIN : $(python_api_human_login)-${{ parameters.os_name }}-${{ parameters.python_version }}
122109 # This will give a user name like 'something macOS 2.7'
123- SG_HUMAN_NAME: $(python_api_human_name) ${{parameters.name }} $(python.version)
110+ SG_HUMAN_NAME : $(python_api_human_name) ${{ parameters.os_name }} ${{ parameters.python_version }}
124111 SG_HUMAN_PASSWORD : $(python_api_human_password)
125112 # So, first, we need to make sure that two builds running at the same time do not manipulate
126113 # the same entities, so we're sandboxing build nodes based on their name.
@@ -131,20 +118,20 @@ jobs:
131118 # Again, this would have been a lot simpler if we could simply have had a login based on the
132119 # agent name, but alas, the agent name has a space in it which needs to be replaced to something
133120 # else and string substitution can't be made on build variables, only template parameters.
134- SG_ASSET_CODE: CI-$(python_api_human_login)-${{parameters.name }}-$(python.version)
135- SG_VERSION_CODE: CI-$(python_api_human_login)-${{parameters.name }}-$(python.version)
136- SG_SHOT_CODE: CI-$(python_api_human_login)-${{parameters.name }}-$(python.version)
137- SG_TASK_CONTENT: CI-$(python_api_human_login)-${{parameters.name }}-$(python.version)
138- SG_PLAYLIST_CODE: CI-$(python_api_human_login)-${{parameters.name }}-$(python.version)
121+ SG_ASSET_CODE : CI-$(python_api_human_login)-${{ parameters.os_name }}-${{ parameters.python_version }}
122+ SG_VERSION_CODE : CI-$(python_api_human_login)-${{ parameters.os_name }}-${{ parameters.python_version }}
123+ SG_SHOT_CODE : CI-$(python_api_human_login)-${{ parameters.os_name }}-${{ parameters.python_version }}
124+ SG_TASK_CONTENT : CI-$(python_api_human_login)-${{ parameters.os_name }}-${{ parameters.python_version }}
125+ SG_PLAYLIST_CODE : CI-$(python_api_human_login)-${{ parameters.os_name }}-${{ parameters.python_version }}
139126
140127 # Upload the code coverage result to codecov.io.
141- - ${{ if eq(parameters.name , 'Windows') }} :
128+ - ${{ if eq(parameters.os_name , 'Windows') }} :
142129 - powershell : |
143130 $ProgressPreference = 'SilentlyContinue'
144131 Invoke-WebRequest -Uri https://uploader.codecov.io/latest/windows/codecov.exe -Outfile codecov.exe
145132 .\codecov.exe -f coverage.xml
146133 displayName: Uploading code coverage
147- - ${{ elseif eq(parameters.name , 'Linux') }} :
134+ - ${{ elseif eq(parameters.os_name , 'Linux') }} :
148135 - script : |
149136 curl -Os https://uploader.codecov.io/latest/linux/codecov
150137 chmod +x codecov
0 commit comments