Skip to content

Read every key under its _51DEGREES_ name, and skip a live cloud test without one - #254

Merged
jwrosewell merged 9 commits into
rcfrom
ci/51degrees-secret-names
Nov 21, 2026
Merged

jwrosewell merged 9 commits into
rcfrom
ci/51degrees-secret-names

Conversation

@51DTechResponse

Copy link
Copy Markdown

The workflows now pass their secrets to common-ci with secrets: inherit, and the CI scripts and tests read every key from the environment under its 51DEGREES name. A live cloud test with no key now skips and names the variable, while CI still fails a run that has no key. This goes with the common-ci draft secrets-by-51degrees-names, in which common-ci exports each key from the organization secret of the same name, downloads every data file from the Distributor with _51DEGREES_LICENSE_KEY, and passes PYPI_TOKEN on under the name the publish asks for.

What changed

Workflows

  • Every job that calls a common-ci reusable workflow uses secrets: inherit in place of its mapping. Gone are DEVICE_DETECTION_KEY, IP_INTELLIGENCE_KEY, IPI_DATA_FILE_URL, the TestResourceKey mapping and the explicit PYPI_TOKEN mapping.
  • cloud-51did.yml no longer reads repository variables. It passes _51DEGREES_RESOURCE_KEY_51DID (from the secret _51DEGREES_RESOURCE_KEY_BESPOKE) and _51DEGREES_LICENSE_KEY_51DID and runs the 51Did client test once, in place of once per resource key with licenses matched by suffix. The tier test takes _51DEGREES_RESOURCE_KEY_BASIC from _51DEGREES_RESOURCE_KEY_FREE. Neither step writes _51DEGREES_RESOURCE_KEY or _51DEGREES_LICENSE_KEY any more, and each fails, naming the variable, when its key is missing. Those three secrets, all in cloud-51did.yml, are the only ones a workflow names.

CI scripts

  • run-integration-tests.ps1 in device-detection, ip-intelligence, location and pipeline read the resource key from _51DEGREES_RESOURCE_KEY_BESPOKE in place of TestResourceKey, and fail naming it when it's missing. They fill _51DEGREES_RESOURCE_KEY from it only when common-ci hasn't. $Keys is optional, and no key is read from it.
  • device-detection/ci/run-integration-tests.ps1 no longer writes _51DEGREES_LICENSE_KEY from the DeviceDetection option. Under secrets: inherit that option is empty, so it would clear the data license common-ci exported.
  • ci/fetch-assets.ps1 and the fetch-assets.ps1 of device-detection and ip-intelligence take and pass no key or address. Device detection always asks for TAC-HashV41.hash and 51Degrees.csv. IP Intelligence always asks for 51Degrees-EnterpriseIpiV41.ipi and points _51DEGREES_IPI_PATH at it. common-ci downloads them with _51DEGREES_LICENSE_KEY.
  • The ci/README.md files of device-detection, ip-intelligence, location and pipeline name the 51DEGREES secrets in place of SUPER_RESOURCE_KEY, DEVICE_DETECTION_KEY, IP_INTELLIGENCE_KEY and IPI_DATA_FILE_URL.

Tests

  • Every tox.ini with pass_env (15 files) passes _51DEGREES_* in place of its own list. Before, several packages didn't pass names their tests read, such as _51DEGREES_RESOURCE_KEY_BESPOKE, _51DEGREES_CLOUD_ENDPOINT and _51DEGREES_DD_PATH, and none passed _51DEGREES_LICENSE_KEY_BESPOKE, _51DEGREES_RESOURCE_KEY_51DID or _51DEGREES_LICENSE_KEY_51DID.
  • The cloud request engine's test_licensekey_live.py and examples/tests/helpers.py read the cloud license from _51DEGREES_LICENSE_KEY_BESPOKE in place of _51DEGREES_LICENSE_KEY, which is the data license, and skip naming it when it's missing.
  • test_did_client_live.py reads _51DEGREES_RESOURCE_KEY_51DID and _51DEGREES_LICENSE_KEY_51DID in place of _51DEGREES_RESOURCE_KEY and _51DEGREES_LICENSE_KEY. In the main CI it used to get the data license as its 51Did license.
  • Live cloud tests skip with a reason naming each variable, where before they failed, raised at import, or built an example with an empty key. That covers live_cloud.py in eight test folders and the device detection cloud, device detection examples, IP Intelligence examples, location, cloud request engine and 51Did tests. location's test_examples.py used to pass without calling anything when no key was set.
  • A new Pester test, ci/key-names.Tests.ps1, runs each product's run-integration-tests.ps1 and fetch-assets.ps1 against a stand-in common-ci, and checks the tox pass_env, the license and 51Did names, and that no live test fails for want of a key. ci-script-tests.yml now runs it when a product's ci folder, a tox.ini, those tests or cloud-51did.yml change.

Tests

Run locally with Pester 6.2.0 on Windows. On the first commit of this branch, 33 of 104 failed. On the commit before the skip change, 23 of the 28 skip tests failed. On this head, 132 of 132 pass, and the repository's own ci/check-environment-variable-names.ps1 passes. Python's own tests weren't run, as pytest and tox weren't available there. The changed .py files compile.

No GitHub run has been made on this head yet. Before merging, run the CI against common-ci's secrets-by-51degrees-names. Only a run can show that every test gets its key through tox with _51DEGREES_* (tox 4 takes glob patterns in pass_env), that _51DEGREES_LICENSE_KEY downloads the Enterprise IP Intelligence file under the name the tests expect along with the TAC hash file and the CSV, that the cloud takes _51DEGREES_LICENSE_KEY_BESPOKE on its own, and how the 51Did keys pair up.

Before you upgrade

  • Nothing changes for users of the packages. The published examples and packages keep their deprecated fallbacks to resource_key and license_key.
  • Maintainers: the organization secrets _51DEGREES_LICENSE_KEY, _51DEGREES_LICENSE_KEY_BESPOKE and _51DEGREES_LICENSE_KEY_51DID must exist. Without _51DEGREES_LICENSE_KEY, fetching data files fails. The repository variables _51DEGREES_RESOURCE_KEY_51DID and _51DEGREES_RESOURCE_KEY_BASIC are no longer read and can be removed after the merge.

Open questions

  • The live tests now skip without a key, naming the variable. The repository had chosen to fail (Fail the cloud tests when no resource key is set, and run the Cloud 51Did workflow #58, "Fail the cloud tests when no resource key is set"), so that a run that called nothing can't look like a pass. CI still fails without a key: each run-integration-tests.ps1 fails naming _51DEGREES_RESOURCE_KEY_BESPOKE, and cloud-51did.yml fails naming the 51DID or BASIC variable.
  • device-detection's Selenium contract still sets PAID_RESOURCE_KEY, now from _51DEGREES_RESOURCE_KEY_BESPOKE, because 51Degrees/selenium-api-tests reads that name. That suite needs a 51DEGREES name first.
  • The published examples and packages still fall back to resource_key and license_key with a deprecation warning. Dropping them changes what users' code reads, so it needs a decision.
  • The examples read _51DEGREES_LICENSE_KEY as the user's license, both for data files and, in the mixed examples, for the cloud. Only the tests were moved to _51DEGREES_LICENSE_KEY_BESPOKE for the cloud license.
  • Whether _51DEGREES_RESOURCE_KEY_BESPOKE carries CloudV5FODiD, the TAC and native model lookups, and countrynamestranslated, and whether _51DEGREES_LICENSE_KEY_51DID belongs to the same account, needs a run.

How to merge

Merge after common-ci's secrets-by-51degrees-names has merged into main. These workflows call common-ci at main, and before that change its workflows still require a token secret and nothing passes PYPI_TOKEN on under the name the publish asks for. Then merge this into rc.

Tracy51D and others added 9 commits November 20, 2026 16:57
Adds ci/key-names.Tests.ps1. It runs each product's
run-integration-tests.ps1 and fetch-assets.ps1 against a stand-in
common-ci, and checks that:

- the resource key comes from _51DEGREES_RESOURCE_KEY_BESPOKE, with no
  TestResourceKey option
- the data license common-ci exports as _51DEGREES_LICENSE_KEY is left
  as it is
- the TAC data file, the CSV and the Enterprise IP Intelligence file
  are asked for with no key or address option
- no CI script reads TestResourceKey, DeviceDetection or IpIntelligence
- every tox.ini passes each _51DEGREES_ variable its package reads
- the cloud license-key tests read _51DEGREES_LICENSE_KEY_BESPOKE, and
  the 51Did live test reads _51DEGREES_RESOURCE_KEY_51DID and
  _51DEGREES_LICENSE_KEY_51DID

The CI script tests workflow now also runs when those files change.
common-ci now exports each _51DEGREES_ secret under its own name, fills
_51DEGREES_RESOURCE_KEY and _51DEGREES_RESOURCE_KEY_51DID from
_51DEGREES_RESOURCE_KEY_BESPOKE, and downloads every data file with
_51DEGREES_LICENSE_KEY. No key reaches a script as an option.

- run-integration-tests.ps1 in each product reads the resource key from
  _51DEGREES_RESOURCE_KEY_BESPOKE, not TestResourceKey, and fails naming
  it when it is not set. Device Detection no longer writes
  _51DEGREES_LICENSE_KEY from the DeviceDetection option, which cleared
  the data license common-ci exported.
- fetch-assets.ps1 passes no key or address. Device Detection always
  asks for the TAC data file and the CSV, and IP Intelligence for the
  Enterprise data file, which common-ci downloads with the data license.
- Every tox.ini passes _51DEGREES_*, so the tests get each key they
  read.
- The cloud license-key tests read _51DEGREES_LICENSE_KEY_BESPOKE, a
  cloud license, and skip naming it when it is not set.
  _51DEGREES_LICENSE_KEY is the data license, which the cloud does not
  take on its own.
- The 51Did live test reads _51DEGREES_RESOURCE_KEY_51DID and
  _51DEGREES_LICENSE_KEY_51DID. The Cloud 51Did workflow passes those
  two and no longer writes _51DEGREES_RESOURCE_KEY or
  _51DEGREES_LICENSE_KEY.
- The CI readmes name the _51DEGREES_ secrets.
Every live cloud test with no key now skips, and its reason names each
variable it reads. None fails for want of a key. Before, most failed,
one raised at import, one built its example with an empty key, and the
location getting started test passed without calling anything.

- live_cloud.py (the same in each test folder) says what a test skips
  with, and no longer says there is no skip.
- The Device Detection, IP Intelligence, location, cloud request engine
  and 51Did live tests call skipTest or pytest.skip where they called
  fail.
- CI still fails a run with no key. Each product's
  run-integration-tests.ps1 fails naming
  _51DEGREES_RESOURCE_KEY_BESPOKE, and the Cloud 51Did workflow fails
  naming _51DEGREES_RESOURCE_KEY_51DID or _51DEGREES_RESOURCE_KEY_BASIC
  before it runs the tests.
- ci/key-names.Tests.ps1 checks that no live test fails for want of a
  key.
cloud-51did.yml filled _51DEGREES_RESOURCE_KEY_51DID from the Bespoke
resource key secret. The 51Did license key unseals only results made with
a resource key of its own account, so the licensed redeem came back
unreadable. On rc the same key came from the organization variable, and
the redeem passed.

The workflow now reads the organization secret
_51DEGREES_RESOURCE_KEY_51DID, which has to hold the same value as that
variable. ci/key-names.Tests.ps1 fails if any workflow fills the 51Did
resource key from another secret, and the pipeline CI readme says where
the key comes from.
If the _51DEGREES_RESOURCE_KEY_51DID secret is missing while
_51DEGREES_LICENSE_KEY_51DID is set, the licensed redeem never runs. The
step already fails then, naming the secret, before tox runs. A Pester
case now runs the step's script with only the license key set, and
fails if the step passes, runs tox, or doesn't name the secret.
The Basic tier step filled _51DEGREES_RESOURCE_KEY_BASIC from the FREE
secret, and test_non_marketing_usage_gets_a_51did failed with it. The
organization secret _51DEGREES_RESOURCE_KEY_BASIC now exists, so the step
reads it by its own name. A Pester test checks every workflow fills it
that way, as it already did for the 51DID key.
rc's integration test step now skips the tests marked live, with a
warning, when there is no resource key, where this branch failed the
step. The merge keeps rc's skip and reads the key from
_51DEGREES_RESOURCE_KEY_BESPOKE in place of the TestResourceKey option,
in all four product scripts:

- The warning names _51DEGREES_RESOURCE_KEY_BESPOKE.
- Device Detection runs the Selenium contract against the cloud example
  only when _51DEGREES_RESOURCE_KEY_BESPOKE is set.
- IP Intelligence reports the key's products only when there is a key.
- Pipeline runs the 51Did live tests on their own, after the others,
  only when _51DEGREES_RESOURCE_KEY_BESPOKE is set.

The three tox.ini files that conflicted pass _51DEGREES_* and rc's
PYTEST_ADDOPTS.

ci/run-integration-tests.Tests.ps1 now sets and clears
_51DEGREES_RESOURCE_KEY_BESPOKE rather than passing TestResourceKey. The
key-names test that expected a throw without the key now expects the
step to run and name the variable.
rc now runs the CI script tests when free-threaded-python.yml changes,
and says so in the workflow's header comment, where this branch says
the tests check each key name. The header now says both, and the paths
keep both sides' entries.
@jwrosewell
jwrosewell marked this pull request as ready for review November 21, 2026 21:01
@jwrosewell
jwrosewell merged commit 60e1b5e into rc Nov 21, 2026
10 checks passed
@jwrosewell
jwrosewell deleted the ci/51degrees-secret-names branch November 21, 2026 21:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants