Исходный код СУБД RuDB — свободной СУБД с открытым исходным кодом на базе PostgreSQL
rudb
3 days ago bd039d1e92813358c5c5a1e346b49074baf513f2
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
# -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation.  All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
 
# This script is used to add trigger rules to the workflow files.
from __future__ import annotations
 
import multiprocessing
import os
from os.path import abspath, dirname
 
skip_doc_changes = ["web-ci-pipeline.yml"]
skip_js_changes = [
    "android-x86_64-crosscompile-ci-pipeline.yml",
    "bigmodels-ci-pipeline.yml",
    "linux-ci-pipeline.yml",
    "linux-dnnl-ci-pipeline.yml",
    "linux-gpu-ci-pipeline.yml",
    "linux-gpu-tensorrt-ci-pipeline.yml",
    "linux-migraphx-ci-pipeline.yml",
    "linux-openvino-ci-pipeline.yml",
    "mac-ci-pipeline.yml",
    "mac-coreml-ci-pipeline.yml",
    "mac-ios-ci-pipeline.yml",
    "mac-ios-packaging-pipeline.yml",
    "mac-react-native-ci-pipeline.yml",
    "win-ci-pipeline.yml",
    "win-gpu-dml-ci-pipeline.yml",
    "win-gpu-cuda-ci-pipeline.yml",
    "win-gpu-tensorrt-ci-pipeline.yml",
    "win-gpu-webgpu-ci-pipeline.yml",
    "win-openvino-ci-pipeline.yml",
]
 
 
def add_trigger_filter(file_name, trigger_lines):
    # Open the file and read its lines
    with open(file_name) as f:
        lines = f.readlines()
 
    start_marker = f"##### start trigger Don't edit it manually, Please do edit {os.path.basename(__file__)} ####"
    end_marker = "#### end trigger ####\n"
    reminder = f"### please do rerun {os.path.basename(__file__)} ###"
    trigger_lines.insert(0, f"{reminder}\n")
 
    if lines[0].startswith(start_marker):
        for i in range(1, len(lines)):
            if lines[i].startswith(end_marker):
                lines[1:i] = trigger_lines
                break
    else:
        trigger_lines.insert(0, start_marker + "\n")
        trigger_lines.extend(end_marker + "\n")
        lines[0:0] = trigger_lines
 
    with open(file_name, "w") as f:
        f.writelines(lines)
        print("Added trigger rules to file: " + file_name)
 
 
def main():
    working_dir = os.path.join(dirname(abspath(__file__)), "github/azure-pipelines")
    os.chdir(working_dir)
 
    trigger_rules = {"skip-docs.yml": skip_doc_changes, "skip-js.yml": skip_js_changes}
    for key, skip_changes in trigger_rules.items():
        trigger_file = os.path.join(working_dir, "triggers", key)
        with open(trigger_file) as f1:
            trigger_lines = f1.readlines()
 
        pool = multiprocessing.Pool()
        pool.starmap(add_trigger_filter, [(file, trigger_lines) for file in skip_changes])
        pool.close()
        pool.join()
 
 
if __name__ == "__main__":
    main()