-
Notifications
You must be signed in to change notification settings - Fork 2
149 lines (122 loc) · 5.11 KB
/
pull-requests.yaml
File metadata and controls
149 lines (122 loc) · 5.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
name: Lint and Tests PRs
on:
pull_request:
branches:
- 'main'
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
matrix:
container: [ "python:3.10", "python:3.11" ]
container:
image: ${{ matrix.container }}
steps:
- name: Check out src from Git
uses: actions/checkout@v4
with:
fetch-depth: 0 # this (and below) is needed to have setuptools_scm report the correct version
fetch-tags: true
- name: Mark workspace as safe directory
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
- name: Upgrade pip
run: pip install --upgrade pip
- name: Create and activate Virtualenv
run: |
pip install virtualenv
[ ! -d ".venv" ] && virtualenv .venv
. .venv/bin/activate
- name: Install dependencies
run: |
pip install ".[dev]"
- name: Install pypa/build
run: >-
python -m
pip install
build
--user
- name: Make sure dist folder is empty
run: >-
rm -rf dist/*
- name: Build a binary wheel and a source tarball
run: >-
python -m
build
--sdist
--wheel
--outdir dist/
.
- name: Run black formatter check
run: black --check confidence --exclude="telemetry_pb2.py|_version.py"
- name: Run flake8 formatter check
run: flake8 confidence --exclude=telemetry_pb2.py,_version.py,telemetry.py
- name: Run type linter check
run: mypy confidence --follow-imports=skip --exclude telemetry_pb2.py --exclude telemetry.py
- name: Run tests with pytest
run: pytest
test-installation-scenarios:
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
matrix:
python-version: ["3.11"]
installation-type: ["full", "minimal"]
steps:
- name: Check out src from Git
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Upgrade pip
run: pip install --upgrade pip
- name: Install full dependencies (with protobuf)
if: matrix.installation-type == 'full'
run: |
pip install -e ".[dev]"
- name: Install minimal dependencies (without protobuf)
if: matrix.installation-type == 'minimal'
run: |
pip install --no-deps -e .
pip install "requests>=2.33.1,<3.0.0" openfeature-sdk==0.4.2 typing_extensions==4.9.0 httpx==0.27.2
pip install pytest==7.4.2 pytest-mock==3.11.1
- name: Test telemetry functionality
run: |
python -c "
from confidence.telemetry import Telemetry, PROTOBUF_AVAILABLE, ProtoTraceId, ProtoStatus
print(f'Installation: ${{ matrix.installation-type }}')
print(f'Protobuf available: {PROTOBUF_AVAILABLE}')
telemetry = Telemetry('test-version')
telemetry.add_trace(ProtoTraceId.PROTO_TRACE_ID_RESOLVE_LATENCY, 100, ProtoStatus.PROTO_STATUS_SUCCESS)
header = telemetry.get_monitoring_header()
if '${{ matrix.installation-type }}' == 'full':
assert PROTOBUF_AVAILABLE == True, 'Protobuf should be available in full installation'
assert len(header) > 0, 'Header should not be empty in full installation'
print('✅ Full installation: Telemetry enabled')
else:
assert PROTOBUF_AVAILABLE == False, 'Protobuf should not be available in minimal installation'
assert header == '', 'Header should be empty in minimal installation'
print('✅ Minimal installation: Telemetry disabled')
"
- name: Run core functionality tests
run: |
# Run a subset of tests to verify core functionality works in both scenarios
python -c "
from confidence.confidence import Confidence
from openfeature import api
from confidence.openfeature_provider import ConfidenceOpenFeatureProvider
# Test basic SDK initialization (should work in both scenarios)
confidence = Confidence('fake-token', disable_telemetry=True)
provider = ConfidenceOpenFeatureProvider(confidence)
print('✅ Core SDK functionality works')
"