Skip to content

Commit 22654a6

Browse files
committed
Merge remote-tracking branch 'origin/master' into ticket/SG-36435
2 parents 64aa32a + 13be391 commit 22654a6

File tree

2 files changed

+65
-63
lines changed

2 files changed

+65
-63
lines changed

azure-pipelines-templates/run-tests.yml

Lines changed: 33 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
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:
@@ -28,64 +28,47 @@
2828

2929
# This is the list of parameters for this template and their default values.
3030
parameters:
31-
name: ''
31+
os_name: ''
3232
vm_image: ''
33+
python_version: ''
3334

3435
jobs:
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

azure-pipelines.yml

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,31 @@ pr:
5858
include:
5959
- "*"
6060

61+
parameters:
62+
- name: python_versions
63+
type: object
64+
default:
65+
# - '3.9'
66+
# - '3.10'
67+
- '3.11'
68+
- '3.13'
69+
70+
# # Keep compat
71+
# Python 3.7:
72+
# python.version: pypy3.7
73+
74+
- name: os_versions
75+
type: object
76+
default:
77+
- name: Linux
78+
vm_image: ubuntu-latest
79+
80+
# - name: macOS
81+
# vm_image: macOS-latest
82+
83+
# - name: Windows
84+
# vm_image: windows-latest
85+
6186
# This here is the list of jobs we want to run for our build.
6287
# Jobs run in parallel.
6388
jobs:
@@ -71,20 +96,10 @@ jobs:
7196

7297
- template: azure-pipelines-templates/type_checking.yml
7398

74-
# These are jobs templates, they allow to reduce the redundancy between
75-
# variations of the same build. We pass in the image name
76-
# and a friendly name that then template can then use to create jobs.
77-
- template: azure-pipelines-templates/run-tests.yml
78-
parameters:
79-
name: Linux
80-
vm_image: 'ubuntu-latest'
81-
82-
# - template: azure-pipelines-templates/run-tests.yml
83-
# parameters:
84-
# name: macOS
85-
# vm_image: 'macOS-latest'
86-
87-
# - template: azure-pipelines-templates/run-tests.yml
88-
# parameters:
89-
# name: Windows
90-
# vm_image: 'windows-latest'
99+
- ${{ each os_version in parameters.os_versions }}:
100+
- ${{ each python_version in parameters.python_versions }}:
101+
- template: azure-pipelines-templates/run-tests.yml
102+
parameters:
103+
os_name: "${{ os_version.name }}"
104+
vm_image: ${{ os_version.vm_image }}
105+
python_version: ${{ python_version }}

0 commit comments

Comments
 (0)