from pathlib import Path


def test_gcp_artifact_workflow_retains_immutable_image_digest() -> None:
    workflow = Path(".github/workflows/gcp-artifact.yml").read_text()

    assert "gcloud artifacts docker images describe" in workflow
    assert "Image tag already exists; reusing immutable Artifact Registry image." in workflow
    assert 'docker pull "${image_uri}@${image_digest}"' in workflow
    assert 'docker run --rm "${image_uri}@${image_digest}"' in workflow
    assert "docker push" in workflow
    assert "tee docker-push.log" in workflow
    assert "image_digest=" in workflow
    assert "image_ref=" in workflow
    assert "test -n \"${image_digest}\"" in workflow
