Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
134 changes: 134 additions & 0 deletions .github/workflows/e2e-development-e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
name: E2E Development-E2E

# Runs the nextgen-devkit end-to-end suite against development-e2e, with
# citrine installed from this checkout instead of from PyPI or a git ref.
# Mirrors nextgen-devkit's pr-development.yml and test-e2e-aws.yml.

on:
pull_request:
branches:
- main
workflow_dispatch:
inputs:
devkit_ref:
description: "nextgen-devkit ref to take the e2e suite from"
required: false
default: "main"
type: string

permissions:
contents: read
checks: write

# Shares the group name with nextgen-devkit's pr-development.yml. GitHub scopes
# concurrency groups to one repository, so this serializes runs here only.
concurrency:
group: e2e-development-e2e
cancel-in-progress: false

jobs:
e2e:
name: "E2E Tests (development-e2e)"
# Fork PRs receive no secrets, so run only for same-repo PRs and manual runs.
if: github.event_name == 'workflow_dispatch' || github.event.pull_request.head.repo.full_name == github.repository
timeout-minutes: 60
# nextgen-devkit runs this suite on the self-hosted ccl-builder runner.
# citrine-python is public, so this job uses a GitHub-hosted runner.
# If GitHub-hosted runners cannot reach development-e2e, change the runner.
runs-on: ubuntu-latest

steps:
- name: Checkout citrine-python
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}
path: citrine-python
persist-credentials: false

# citrine-python cannot see the e2e secrets yet. Without them, skip the
# remaining steps so the job ends green instead of failing the PR.
- name: Check e2e secrets
id: secrets
env:
DEV_E2E_API_KEY_FE_ADMIN: ${{ secrets.DEV_E2E_API_KEY_FE_ADMIN }}
DEV_E2E_API_KEY_OTHER_USER: ${{ secrets.DEV_E2E_API_KEY_OTHER_USER }}
DEVKIT_APP_ID: ${{ secrets.DEVKIT_APP_ID }}
DEVKIT_APP_PRIVATE_KEY: ${{ secrets.DEVKIT_APP_PRIVATE_KEY }}
run: ./citrine-python/scripts/check_e2e_secrets.sh

- name: Generate GitHub App token
if: steps.secrets.outputs.available == 'true'
uses: actions/create-github-app-token@fee1f7d63c2ff003460e3d139729b119787bc349 # v2
id: generate_token
with:
app-id: ${{ secrets.DEVKIT_APP_ID }}
private-key: ${{ secrets.DEVKIT_APP_PRIVATE_KEY }}
owner: CitrineInformatics
repositories: |
nextgen-devkit

- name: Checkout nextgen-devkit
if: steps.secrets.outputs.available == 'true'
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
with:
repository: CitrineInformatics/nextgen-devkit
ref: ${{ inputs.devkit_ref || 'main' }}
token: ${{ steps.generate_token.outputs.token }}
path: nextgen-devkit
persist-credentials: false

- name: Install Python
if: steps.secrets.outputs.available == 'true'
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
with:
python-version: "3.12"

- name: Install uv
if: steps.secrets.outputs.available == 'true'
uses: astral-sh/setup-uv@61cb8a9741eeb8a550a1b8544337180c0fc8476b # 61cb8a9741eeb8a550a1b8544337180c0fc8476b
with:
version: "latest"

# The suite's uv.lock pins citrine from PyPI. The --with layer takes
# precedence over the project environment; this step logs which citrine loads.
- name: Show citrine under test
if: steps.secrets.outputs.available == 'true'
working-directory: nextgen-devkit/end-to-end-tests
env:
CITRINE_PKG: "citrine @ file://${{ github.workspace }}/citrine-python"
run: uv run --with "$CITRINE_PKG" python -c "import citrine; print('citrine', citrine.__version__, citrine.__file__)"

# Same pytest command as nextgen-devkit's test-e2e-aws.yml, with citrine
# from this checkout. pytest creates the results/ directory for --junitxml.
- name: Run E2E tests
if: steps.secrets.outputs.available == 'true'
working-directory: nextgen-devkit/end-to-end-tests
env:
CITRINE_DEPLOYMENT_TYPE: "aws"
CITRINE_API_HOST: "development-e2e.citrine-platform.com"
CITRINE_API_PORT: "443"
CITRINE_API_SCHEME: "https"
CITRINE_API_KEY: "${{ secrets.DEV_E2E_API_KEY_FE_ADMIN }}"
CITRINE_API_KEY_2: "${{ secrets.DEV_E2E_API_KEY_OTHER_USER }}"
CITRINE_NO_PRELOAD: "1"
CITRINE_PRELOAD_PREFIX: "PR"
CITRINE_PRELOAD_SHARE: "none"
CITRINE_PKG: "citrine @ file://${{ github.workspace }}/citrine-python"
run: >-
uv run --with "$CITRINE_PKG"
pytest -v -rfexs -s -p no:warnings --tb=short --capture=sys --durations=15
-n "$(( $(getconf _NPROCESSORS_ONLN) / 2 ))"
--junitxml=results/TEST-e2e-aws.xml
tests/

- name: Publish Test Report
uses: mikepenz/action-junit-report@5b7ee5a21e8674b695313d769f3cbdfd5d4d53a4 # v6.0.0
if: ${{ always() && steps.secrets.outputs.available == 'true' }}
with:
report_paths: "**/results/TEST-*.xml"
github_token: ${{ secrets.GITHUB_TOKEN }}
fail_on_failure: true
require_tests: true
fail_on_parse_error: true
annotate_only: true
include_passed: true
19 changes: 19 additions & 0 deletions scripts/check_e2e_secrets.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash
# Report whether the development-e2e secrets are available.
#
# Required env vars (empty when the repo cannot see the secret):
# DEV_E2E_API_KEY_FE_ADMIN, DEV_E2E_API_KEY_OTHER_USER,
# DEVKIT_APP_ID, DEVKIT_APP_PRIVATE_KEY
# Optional: GITHUB_OUTPUT. When set, the script writes available=true|false to it.
# Always exits 0, so a missing secret skips the run instead of failing it.
set -uo pipefail

available=true
for name in DEV_E2E_API_KEY_FE_ADMIN DEV_E2E_API_KEY_OTHER_USER DEVKIT_APP_ID DEVKIT_APP_PRIVATE_KEY; do
if [ -z "${!name:-}" ]; then
echo "::notice::${name} is not available to this repo; skipping the development-e2e run."
available=false
fi
done

echo "available=${available}" >> "${GITHUB_OUTPUT:-/dev/stdout}"
2 changes: 1 addition & 1 deletion src/citrine/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "5.3.1"
__version__ = "6.0.0"
3 changes: 0 additions & 3 deletions src/citrine/resources/process_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ class ProcessTemplate(
parameters = Optional(List(_attr_tuple(GEMDParameterTemplate)), "parameters", override=True)

allowed_labels = Optional(List(String()), "allowed_labels", override=True)
allowed_names = Optional(List(String()), "allowed_names", override=True)

def __init__(
self,
Expand All @@ -85,7 +84,6 @@ def __init__(
]
| None = None,
allowed_labels: list[str] | None = None,
allowed_names: list[str] | None = None,
description: str | None = None,
tags: list[str] | None = None,
):
Expand All @@ -101,7 +99,6 @@ def __init__(
tags=tags,
description=description,
allowed_labels=allowed_labels,
allowed_names=allowed_names,
)

def __str__(self):
Expand Down
2 changes: 1 addition & 1 deletion tests/resources/test_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ def test_gemd_posts(dataset):
def test_register_all_nested(dataset):
cake = make_cake()
after = dataset.register_all([cake], include_nested=True)
assert cake in after
assert MaterialRun.build(cake.dump()) in after
assert len(after) == len(recursive_flatmap(cake, lambda o: [o], unidirectional=False))


Expand Down
5 changes: 3 additions & 2 deletions tests/resources/test_material_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def test_get_history(collection, session):
},
)
assert expected_call == session.last_call
assert run == cake
assert run == CitrineRun.build(cake.dump())


def test_get_history_no_histories(collection, session):
Expand Down Expand Up @@ -558,7 +558,8 @@ def test_deep_equals(collection):
registered.remove(x)
assert len(registered) == 0, "All registered objects are in the flat list"

assert cake == CitrineRun.build(cake.dump()), "Equality works in hydrated form"
citrine_cake = CitrineRun.build(cake.dump())
assert citrine_cake == CitrineRun.build(citrine_cake.dump()), "Equality works in hydrated form"


def test_nonmutating_dry_run(collection):
Expand Down
5 changes: 3 additions & 2 deletions tests/resources/test_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,10 @@ def test_process_template_equals():

gemd_obj = GEMDProcessTemplate(name="My Name", tags=["tag!"])
citrine_obj = CitrineProcessTemplate(name="My Name", tags=["tag!"])
assert gemd_obj == citrine_obj, "GEMD/Citrine equivalence"
built = CitrineProcessTemplate.build(gemd_obj.dump())
assert built == citrine_obj, "GEMD/Citrine equivalence"
citrine_obj.name = "Something else"
assert gemd_obj != citrine_obj, "GEMD/Citrine detects difference"
assert built != citrine_obj, "GEMD/Citrine detects difference"


def test_material_template_equals():
Expand Down
2 changes: 1 addition & 1 deletion tests/serialization/test_material_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def test_cake():
assert [ingred.labels for ingred in cake.process.ingredients] == [
ingred.labels for ingred in gemd_cake.process.ingredients
]
assert gemd_cake == cake
assert MaterialRun.build(gemd_cake.dump()) == cake

def _by_name(start: MaterialRun, names: Iterable[str]) -> MaterialRun | None:
if isinstance(names, str):
Expand Down
1 change: 0 additions & 1 deletion tests/serialization/test_object_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ def test_object_template_serde():
parameters=[index_template],
conditions=[pressure_template],
allowed_labels=["Label"],
allowed_names=["first sample", "second sample"],
)
assert ProcessTemplate.build(proc_template.dump()) == proc_template

Expand Down
2 changes: 0 additions & 2 deletions tests/serialization/test_process_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ def valid_data():
]
],
"allowed_labels": ["a", "b"],
"allowed_names": ["a name"],
"description": "a long description",
},
file_links=[{"type": "file_link", "filename": "cake_recipe.txt", "url": "www.baking.com"}],
Expand Down Expand Up @@ -103,7 +102,6 @@ def test_simple_deserialization(valid_data):
],
description="a long description",
allowed_labels=["a", "b"],
allowed_names=["a name"],
)
assert process_spec.name == "Process 1"
assert process_spec.notes == "make sure to use oven mitts"
Expand Down
Loading