File: llvmdev_evaluate.py

package info (click to toggle)
llvmlite 0.46.0-0.1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 2,140 kB
  • sloc: python: 13,605; cpp: 3,192; makefile: 185; sh: 168
file content (104 lines) | stat: -rwxr-xr-x 2,658 bytes parent folder | download
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
#!/usr/bin/env python

import json
import os
from pathlib import Path


event = os.environ.get("GITHUB_EVENT_NAME")
label = os.environ.get("GITHUB_LABEL_NAME")
inputs = os.environ.get("GITHUB_WORKFLOW_INPUT", "{}")

runner_mapping = {
    "linux-64": "ubuntu-24.04",
    "linux-aarch64": "ubuntu-24.04-arm",
    "osx-arm64": "macos-14",
    "win-64": "windows-2025",
}

default_include = [
    # linux-64
    {
        "runner": runner_mapping["linux-64"],
        "platform": "linux-64",
        "recipe": "llvmdev",
    },
    {
        "runner": runner_mapping["linux-64"],
        "platform": "linux-64",
        "recipe": "llvmdev_for_wheel",
    },
    # linux-aarch64
    {
        "runner": runner_mapping["linux-aarch64"],
        "platform": "linux-aarch64",
        "recipe": "llvmdev",
    },
    {
        "runner": runner_mapping["linux-aarch64"],
        "platform": "linux-aarch64",
        "recipe": "llvmdev_for_wheel",
    },
    # osx-arm64
    {
        "runner": runner_mapping["osx-arm64"],
        "platform": "osx-arm64",
        "recipe": "llvmdev",
    },
    {
        "runner": runner_mapping["osx-arm64"],
        "platform": "osx-arm64",
        "recipe": "llvmdev_for_wheel",
    },
    # win-64
    {
        "runner": runner_mapping["win-64"],
        "platform": "win-64",
        "recipe": "llvmdev",
    },
    {
        "runner": runner_mapping["win-64"],
        "platform": "win-64",
        "recipe": "llvmdev_for_wheel",
    },
]

print(
    "Deciding what to do based on event: "
    f"'{event}', label: '{label}', inputs: '{inputs}'"
)
if event == "pull_request":
    print("pull_request detected")
    include = default_include
elif event == "label" and label == "build_on_gha":
    print("build label detected")
    include = default_include
elif event == "workflow_dispatch":
    print("workflow_dispatch detected")
    params = json.loads(inputs)
    platform = params.get("platform", "all")
    recipe = params.get("recipe", "all")

    # Start with the full matrix
    filtered_matrix = default_include

    # Filter by platform if a specific one is chosen
    if platform != "all":
        filtered_matrix = [
            item for item in filtered_matrix if item["platform"] == platform
        ]

    # Filter by recipe if a specific one is chosen
    if recipe != "all":
        filtered_matrix = [
            item for item in filtered_matrix if item["recipe"] == recipe
        ]

    include = filtered_matrix
else:
    include = {}

matrix = {"include": include}
print(f"Emitting matrix:\n {json.dumps(matrix, indent=4)}")

Path(os.environ["GITHUB_OUTPUT"]).write_text(f"matrix={json.dumps(matrix)}")