-
Notifications
You must be signed in to change notification settings - Fork 204
SG-43825 Improve pipeline stability #449
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
d3146da
824a1a8
5b0cfc3
53c39be
e72e6cd
fa96a4b
bc58c71
bd27f37
3f89923
e9f22c6
dd6c045
ec99632
1bd6372
28d55c0
975d46d
31ecccd
30103a3
8ff127d
a3d8146
4d16f8d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -102,6 +102,8 @@ jobs: | |||||
| --durations=0 \ | ||||||
| --nunit-xml=test-results.xml \ | ||||||
| --verbose \ | ||||||
| --reruns 1 \ | ||||||
| --reruns-delay 2 \ | ||||||
| env: | ||||||
| # Tell Pytest that we're running in a CI environment | ||||||
| CI: 1 | ||||||
|
|
@@ -123,20 +125,39 @@ jobs: | |||||
| # This will give a user name like 'something macOS 2.7' | ||||||
| SG_HUMAN_NAME: $(python_api_human_name) ${{ parameters.os_name }} ${{ parameters.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.os_name }}-${{ parameters.python_version }} | ||||||
| SG_VERSION_CODE: CI-$(python_api_human_login)-${{ parameters.os_name }}-${{ parameters.python_version }} | ||||||
| SG_SHOT_CODE: CI-$(python_api_human_login)-${{ parameters.os_name }}-${{ parameters.python_version }} | ||||||
| SG_TASK_CONTENT: CI-$(python_api_human_login)-${{ parameters.os_name }}-${{ parameters.python_version }} | ||||||
| SG_PLAYLIST_CODE: CI-$(python_api_human_login)-${{ parameters.os_name }}-${{ parameters.python_version }} | ||||||
| # Each job gets its own ephemeral project, scoped to this build + OS + Python version. | ||||||
| # This eliminates state bleed between concurrent runs and across successive builds on the | ||||||
| # same agent. The project is retired in the "Cleanup test project" step below. | ||||||
| SG_PROJECT_NAME: Python API CI - $(Build.BuildId) - ${{ parameters.os_name }} - ${{ parameters.python_version }} | ||||||
|
|
||||||
| - task: PythonScript@0 | ||||||
| displayName: Cleanup test project | ||||||
| condition: always() | ||||||
| inputs: | ||||||
| scriptSource: inline | ||||||
| workingDirectory: $(Build.SourcesDirectory) | ||||||
| script: | | ||||||
| import os, shotgun_api3 | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| sg = shotgun_api3.Shotgun( | ||||||
| base_url=os.environ['SG_SERVER_URL'], | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, no, not this one. base_url is a positional parameter, not a named parameter.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Based on this line it looks like a named (but not optional) parameter. python-api/shotgun_api3/shotgun.py Line 500 in aca9d94
|
||||||
| script_name=os.environ['SG_SCRIPT_NAME'], | ||||||
| api_key=os.environ['SG_API_KEY'], | ||||||
| ) | ||||||
| project = sg.find_one( | ||||||
| entity_type='Project', | ||||||
| filters=[['name', 'is', os.environ['SG_PROJECT_NAME']]], | ||||||
| ) | ||||||
| if not project: | ||||||
| print('Project not found, nothing to clean up.') | ||||||
| sys.exit(0) | ||||||
| sg.delete(entity_type='Project', entity_id=project['id']) | ||||||
| print('Retired project:', os.environ['SG_PROJECT_NAME']) | ||||||
| env: | ||||||
| PYTHONPATH: $(Build.SourcesDirectory) | ||||||
| SG_SERVER_URL: $(ci_site) | ||||||
| SG_SCRIPT_NAME: $(ci_site_script_name) | ||||||
| SG_API_KEY: $(ci_site_script_key) | ||||||
| SG_PROJECT_NAME: Python API CI - $(Build.BuildId) - ${{ parameters.os_name }} - ${{ parameters.python_version }} | ||||||
|
|
||||||
| # Explicit call to PublishTestResults@2 and PublishCodeCoverageResults@2 here | ||||||
| # instead of relying on pytest-azurepipelines because pytest-azurepipelines | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -289,7 +289,7 @@ def _setup_db(cls, config, sg): | |
| cls.human_user = _find_or_create_entity(sg, "HumanUser", data) | ||
|
|
||
| data = {"code": cls.config.asset_code, "project": cls.project} | ||
| keys = ["code"] | ||
| keys = ["code", "project"] | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since we are now creating many projects with entities of the same name, we must scope the search to the ephemeral project. |
||
| cls.asset = _find_or_create_entity(sg, "Asset", data, keys) | ||
|
|
||
| data = { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.