@@ -130,7 +130,8 @@ def _save_to_cache(package: str, version: Version, release: Optional[dict]) -> N
130
130
131
131
132
132
def _prefilter_releases (
133
- integration : str , releases : dict [str , dict ], older_than : Optional [datetime ] = None
133
+ integration : str ,
134
+ releases : dict [str , dict ],
134
135
) -> tuple [list [Version ], Optional [Version ]]:
135
136
"""
136
137
Filter `releases`, removing releases that are for sure unsupported.
@@ -178,9 +179,6 @@ def _prefilter_releases(
178
179
179
180
uploaded = datetime .fromisoformat (meta ["upload_time_iso_8601" ])
180
181
181
- if older_than is not None and uploaded > older_than :
182
- continue
183
-
184
182
if CUTOFF is not None and uploaded < CUTOFF :
185
183
continue
186
184
@@ -224,7 +222,7 @@ def _prefilter_releases(
224
222
225
223
226
224
def get_supported_releases (
227
- integration : str , pypi_data : dict , older_than : Optional [ datetime ] = None
225
+ integration : str , pypi_data : dict
228
226
) -> tuple [list [Version ], Optional [Version ]]:
229
227
"""
230
228
Get a list of releases that are currently supported by the SDK.
@@ -236,17 +234,15 @@ def get_supported_releases(
236
234
We return the list of supported releases and optionally also the newest
237
235
prerelease, if it should be tested (meaning it's for a version higher than
238
236
the current stable version).
239
-
240
- If an `older_than` timestamp is provided, no release newer than that will be
241
- considered.
242
237
"""
243
238
package = pypi_data ["info" ]["name" ]
244
239
245
240
# Get a consolidated list without taking into account Python support yet
246
241
# (because that might require an additional API call for some
247
242
# of the releases)
248
243
releases , latest_prerelease = _prefilter_releases (
249
- integration , pypi_data ["releases" ], older_than
244
+ integration ,
245
+ pypi_data ["releases" ],
250
246
)
251
247
252
248
def _supports_lowest (release : Version ) -> bool :
@@ -665,32 +661,10 @@ def _normalize_release(release: dict) -> dict:
665
661
return normalized
666
662
667
663
668
- def main (fail_on_changes : bool = False ) -> dict [str , list ]:
664
+ def main () -> dict [str , list ]:
669
665
"""
670
666
Generate tox.ini from the tox.jinja template.
671
-
672
- The script has two modes of operation:
673
- - fail on changes mode (if `fail_on_changes` is True)
674
- - normal mode (if `fail_on_changes` is False)
675
-
676
- Fail on changes mode is run on every PR to make sure that `tox.ini`,
677
- `tox.jinja` and this script don't go out of sync because of manual changes
678
- in one place but not the other.
679
-
680
- Normal mode is meant to be run as a cron job, regenerating tox.ini and
681
- proposing the changes via a PR.
682
667
"""
683
- print (f"Running in { 'fail_on_changes' if fail_on_changes else 'normal' } mode." )
684
- last_updated = get_last_updated ()
685
- if fail_on_changes :
686
- # We need to make the script ignore any new releases after the last updated
687
- # timestamp so that we don't fail CI on a PR just because a new package
688
- # version was released, leading to unrelated changes in tox.ini.
689
- print (
690
- f"Since we're in fail_on_changes mode, we're only considering "
691
- f"releases before the last tox.ini update at { last_updated .isoformat ()} ."
692
- )
693
-
694
668
global MIN_PYTHON_VERSION , MAX_PYTHON_VERSION
695
669
meta = _fetch_sdk_metadata ()
696
670
sdk_python_versions = _parse_python_versions_from_classifiers (
@@ -736,12 +710,7 @@ def main(fail_on_changes: bool = False) -> dict[str, list]:
736
710
737
711
# Get the list of all supported releases
738
712
739
- # If in fail-on-changes mode, ignore releases newer than `last_updated`
740
- older_than = last_updated if fail_on_changes else None
741
-
742
- releases , latest_prerelease = get_supported_releases (
743
- integration , pypi_data , older_than
744
- )
713
+ releases , latest_prerelease = get_supported_releases (integration , pypi_data )
745
714
746
715
if not releases :
747
716
print (" Found no supported releases." )
@@ -778,9 +747,6 @@ def main(fail_on_changes: bool = False) -> dict[str, list]:
778
747
}
779
748
)
780
749
781
- if fail_on_changes :
782
- old_file_hash = get_file_hash ()
783
-
784
750
write_tox_file (packages )
785
751
786
752
# Sort the release cache file
@@ -798,36 +764,13 @@ def main(fail_on_changes: bool = False) -> dict[str, list]:
798
764
):
799
765
releases_cache .write (json .dumps (release ) + "\n " )
800
766
801
- if fail_on_changes :
802
- new_file_hash = get_file_hash ()
803
- if old_file_hash != new_file_hash :
804
- raise RuntimeError (
805
- dedent (
806
- """
807
- Detected that `tox.ini` is out of sync with
808
- `scripts/populate_tox/tox.jinja` and/or
809
- `scripts/populate_tox/populate_tox.py`. This might either mean
810
- that `tox.ini` was changed manually, or the `tox.jinja`
811
- template and/or the `populate_tox.py` script were changed without
812
- regenerating `tox.ini`.
813
-
814
- Please don't make manual changes to `tox.ini`. Instead, make the
815
- changes to the `tox.jinja` template and/or the `populate_tox.py`
816
- script (as applicable) and regenerate the `tox.ini` file by
817
- running scripts/generate-test-files.sh
818
- """
819
- )
820
- )
821
- print ("Done checking tox.ini. Looking good!" )
822
- else :
823
- print (
824
- "Done generating tox.ini. Make sure to also update the CI YAML "
825
- "files to reflect the new test targets."
826
- )
767
+ print (
768
+ "Done generating tox.ini. Make sure to also update the CI YAML "
769
+ "files to reflect the new test targets."
770
+ )
827
771
828
772
return packages
829
773
830
774
831
775
if __name__ == "__main__" :
832
- fail_on_changes = len (sys .argv ) == 2 and sys .argv [1 ] == "--fail-on-changes"
833
- main (fail_on_changes )
776
+ main ()
0 commit comments