Skip to content

Commit 1650c1d

Browse files
authored
DEVOPS-656 feat: add clariti org pooling support via cci config (#3)
* DEVOPS-656 feat: add org_pool_id support for scratch org configuration and implement org checkout from pool * DEVOPS-656 fix: improve error handling for JSON decoding in ScratchOrgConfig * DEVOPS-656 fix: handle clariti pool fallback logging * DEVOPS-656 docs: add environment variable to disable scratch org fallback Add documentation for CCI_DISABLE_SCRATCH_FALLBACK environment variable that prevents creation of new scratch orgs when org pool checkout fails. This helps users debug checkout issues without accidentally creating new scratch orgs. * DEVOPS-656 fix: improve error handling for JSON decoding in ScratchOrgConfig * DEVOPS-656 fix: persist original scratch config metadata after importing org details * DEVOPS-656 fix: add mock for setting Salesforce alias in ScratchOrgConfig tests * DEVOPS-656 fix: enhance org persistence in ScratchOrgConfig after importing org details * DEVOPS-656 chore: update datetime handling to use timezone-aware UTC in ScratchOrgConfig tests * DEVOPS-656 chore: improve logging for SFDX errors and exceptions in ScratchOrgConfig * DEVOPS-656 fix: update type hint for args parameter in sfdx function to allow any sequence type * DEVOPS-656 fix: update ScratchOrgConfig instantiation in tests to reflect accurate state and properties * DEVOPS-656 chore: update datetime handling to use timezone-aware UTC in ScratchOrgConfig and related tests * DEVOPS-656 chore: update workflow runners to use ubuntu-latest instead of SFDO-Tooling-Ubuntu * DEVOPS-656 chore: update OS matrix in feature_test.yml to use ubuntu-latest and windows-latest
1 parent 80cc5b7 commit 1650c1d

20 files changed

Lines changed: 676 additions & 236 deletions

.github/workflows/chores.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77

88
jobs:
99
check_api_versions:
10-
runs-on: SFDO-Tooling-Ubuntu
10+
runs-on: ubuntu-latest
1111
outputs:
1212
hub_version: ${{ steps.devhub-api-version.outputs.hub_version }}
1313
cci_version: ${{ steps.cci-api-version.outputs.cci_version }}
@@ -28,7 +28,7 @@ jobs:
2828
version=$(yq '.project.package.api_version' cumulusci/cumulusci.yml)
2929
echo "cci_version=$version" >> $GITHUB_OUTPUT
3030
update_api_versions:
31-
runs-on: SFDO-Tooling-Ubuntu
31+
runs-on: ubuntu-latest
3232
needs: check_api_versions
3333
if: ${{ needs.check_api_versions.outputs.hub_version != needs.check_api_versions.outputs.cci_version }}
3434
env:

.github/workflows/feature_test.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
docs:
1717
name: Build Docs
1818
if: ${{ github.event_name == 'pull_request' }}
19-
runs-on: SFDO-Tooling-Ubuntu
19+
runs-on: ubuntu-latest
2020
steps:
2121
- name: "Checkout"
2222
uses: actions/checkout@v4
@@ -45,7 +45,7 @@ jobs:
4545
strategy:
4646
fail-fast: false
4747
matrix:
48-
os: [macos-latest, SFDO-Tooling-Ubuntu, SFDO-Tooling-Windows]
48+
os: [macos-latest, ubuntu-latest, windows-latest]
4949
python-version: ["3.11", "3.12", "3.13"]
5050
steps:
5151
- uses: actions/checkout@v4
@@ -69,7 +69,7 @@ jobs:
6969
strategy:
7070
fail-fast: false
7171
matrix:
72-
os: [macos-latest, SFDO-Tooling-Ubuntu, SFDO-Tooling-Windows]
72+
os: [macos-latest, ubuntu-latest, windows-latest]
7373
python-version: ["3.11", "3.12", "3.13"]
7474
steps:
7575
- uses: actions/checkout@v4
@@ -89,7 +89,7 @@ jobs:
8989

9090
robot_api:
9191
name: "Robot: No browser"
92-
runs-on: SFDO-Tooling-Ubuntu
92+
runs-on: ubuntu-latest
9393
steps:
9494
- uses: actions/checkout@v4
9595
- name: Set up Python 3.11

.github/workflows/pre-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ on:
1919
jobs:
2020
generate-changelog:
2121
name: Create a PR to update version and release notes
22-
runs-on: SFDO-Tooling-Ubuntu
22+
runs-on: ubuntu-latest
2323
steps:
2424
- uses: actions/checkout@main
2525
- name: Set up Python 3.11

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ concurrency: publishing
1212
jobs:
1313
publish-to-pypi:
1414
name: Publish new release to PyPI
15-
runs-on: SFDO-Tooling-Ubuntu
15+
runs-on: ubuntu-latest
1616
steps:
1717
- uses: actions/checkout@main
1818
- name: Set up Python 3.11

.github/workflows/release_test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
jobs:
99
test_artifacts:
1010
name: "Test Package Artifacts"
11-
runs-on: SFDO-Tooling-Ubuntu
11+
runs-on: ubuntu-latest
1212
steps:
1313
- uses: actions/checkout@v3
1414
- name: Set up Python 3.11

.github/workflows/release_test_sfdx.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ env:
3737
jobs:
3838
test_release:
3939
name: "Test SFDX CLI"
40-
runs-on: SFDO-Tooling-Ubuntu
40+
runs-on: ubuntu-latest
4141
concurrency: release
4242
steps:
4343
- uses: actions/checkout@v4

.github/workflows/slow_integration_tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ env:
2222
jobs:
2323
org_backed_tests:
2424
name: "Org-connected Tests"
25-
runs-on: SFDO-Tooling-Ubuntu
25+
runs-on: ubuntu-latest
2626
steps:
2727
- uses: actions/checkout@v2
2828
- name: Set up Python 3.11
@@ -60,7 +60,7 @@ jobs:
6060
uv run cci org scratch_delete pytest
6161
robot_ui:
6262
name: "Robot: ${{ matrix.job-name }}"
63-
runs-on: SFDO-Tooling-Ubuntu
63+
runs-on: ubuntu-latest
6464
strategy:
6565
fail-fast: false
6666
matrix:

cumulusci/cli/org.py

Lines changed: 20 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,27 @@
22
import json
33
import runpy
44
import webbrowser
5-
from datetime import datetime
65
from urllib.parse import urlencode, urlparse
76

87
import click
98
from rich.console import Console
109

1110
from cumulusci.cli.ui import CliTable, SimpleSalesforceUIHelpers
1211
from cumulusci.core.config import OrgConfig, ScratchOrgConfig
13-
from cumulusci.core.config.sfdx_org_config import SfdxOrgConfig
14-
from cumulusci.core.exceptions import OrgNotFound
12+
from cumulusci.core.exceptions import CumulusCIException, OrgNotFound
13+
from cumulusci.core.org_import import (
14+
import_sfdx_org_to_keychain,
15+
calculate_org_days as _core_calculate_org_days,
16+
)
1517
from cumulusci.oauth.client import (
1618
PROD_LOGIN_URL,
1719
SANDBOX_LOGIN_URL,
1820
OAuth2Client,
1921
OAuth2ClientConfig,
2022
)
2123
from cumulusci.salesforce_api.utils import get_simple_salesforce_connection
22-
from cumulusci.utils import parse_api_datetime
2324
from typing import Optional
2425

25-
import click
26-
2726
from cumulusci.utils.clariti import (
2827
ClaritiError,
2928
build_default_org_name,
@@ -341,61 +340,28 @@ def org_import(
341340
)
342341
if not org_name:
343342
raise click.UsageError("Please specify ORGNAME or --org ORGNAME.")
344-
# Import the org from the SFDX keychain as an SfdxOrgConfig
345-
# The `sfdx` key ensures we can reload using the right class.
346-
org_config = SfdxOrgConfig(
347-
{"username": username_or_alias, "sfdx": True},
348-
org_name,
349-
runtime.keychain,
350-
global_org=False,
351-
)
352-
353-
# Determine if we received a locally-created scratch org
354-
# or some other org (which we'll treat as persistent)
355-
356-
info = org_config.sfdx_info
357-
if info.get("created_date"):
358-
# This is a locally-created scratch org.
359-
# Re-import accordingly.
360-
org_config = ScratchOrgConfig(
361-
{"username": username_or_alias},
362-
org_name,
343+
try:
344+
org_config = import_sfdx_org_to_keychain(
363345
runtime.keychain,
346+
username_or_alias,
347+
org_name,
364348
global_org=False,
365349
)
366-
org_config._sfdx_info = info
367-
# Set `created` so we don't try to rebuild it.
368-
org_config.config["created"] = True
369-
370-
org_config.config["days"] = calculate_org_days(info)
371-
org_config.config["date_created"] = parse_api_datetime(info["created_date"])
350+
except CumulusCIException as err:
351+
raise click.ClickException(str(err)) from err
372352

373-
org_config.save()
374-
click.echo(
375-
"Imported scratch org: {org_id}, username: {username}".format(
376-
**org_config.sfdx_info
377-
)
378-
)
379-
else:
380-
# This is either a persistent org or a scratch org imported into the
381-
# sfdx keychain via OAuth login.
382-
org_config.populate_expiration_date()
383-
org_config.save()
384-
click.echo(
385-
"Imported org: {org_id}, username: {username}".format(
386-
**org_config.sfdx_info
387-
)
388-
)
353+
message = (
354+
"Imported scratch org: {org_id}, username: {username}"
355+
if getattr(org_config, "scratch", False)
356+
else "Imported org: {org_id}, username: {username}"
357+
)
358+
click.echo(message.format(**org_config.sfdx_info))
389359

390360

391361
def calculate_org_days(info):
392-
"""Returns the difference in days between created_date (ISO 8601),
393-
and expiration_date (%Y-%m-%d)"""
394-
if not info.get("created_date") or not info.get("expiration_date"):
395-
return 1
396-
created_date = parse_api_datetime(info["created_date"]).date()
397-
expires_date = datetime.strptime(info["expiration_date"], "%Y-%m-%d").date()
398-
return abs((expires_date - created_date).days)
362+
"""Backwards-compatible shim for legacy imports."""
363+
364+
return _core_calculate_org_days(info)
399365

400366

401367
@org.command(name="info", help="Display information for a connected org")

0 commit comments

Comments
 (0)