potiuk commented on a change in pull request #18335:
URL: https://github.com/apache/airflow/pull/18335#discussion_r711341553



##########
File path: scripts/ci/pre_commit/pre_commit_update_versions.py
##########
@@ -0,0 +1,61 @@
+#!/usr/bin/env python3
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+import glob
+import json
+import os
+import re
+from os.path import abspath, dirname, join
+from re import Pattern
+
+import httpx
+
+AIRFLOW_SOURCES_DIR = abspath(join(dirname(__file__), os.pardir, os.pardir, 
os.pardir))
+
+
+def update_version(pattern: Pattern, version: str, file_path: str):
+    print(f"Replacing {pattern} to {version} in {file_path}")
+    with open(file_path, "r+") as f:
+        file_contents = f.read()
+        lines = file_contents.splitlines(keepends=True)
+        for i in range(0, len(lines)):
+            lines[i] = re.sub(pattern, fr'\g<1>{version}\g<2>', lines[i])
+        file_contents = "".join(lines)
+        f.seek(0)
+        f.truncate()
+        f.write(file_contents)
+
+
+REPLACEMENTS = {
+    r'(FROM apache/airflow:).*($)': 
"docs/docker-stack/docker-examples/extending/*/Dockerfile",
+    r'(apache/airflow:)[^-]*(\-)': "docs/docker-stack/entrypoint.rst",
+    r'(/constraints-)[^-]*(/constraints)': "docs/docker-stack/docker-examples/"
+    "restricted/restricted_environments.sh",
+    r'(AIRFLOW_VERSION=")[^"]*(" \\)': "docs/docker-stack/docker-examples/"
+    "restricted/restricted_environments.sh",
+}
+
+if __name__ == '__main__':
+    airflow_pypi_info = 
json.loads(httpx.get("https://pypi.org/pypi/apache-airflow/json";).text)

Review comment:
       Well. I deliberately used "latest-released" version.  Those dockerfiles 
actually **SHOULD** use 2.1.3 before we release 2.1.4 - because those 
docker-files are actually used  during tests and the dockerfiles are run 
through `docker build -f ..../Dockerfile`. 
   
   And when we release 2.1.4 - they should start using 2.1.4.
   
   If we start  using setup.py - that's the moment the tests will start to fail 
actually.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to