Debian Codegraph @

.cirrus.star

raw
1 # Ref: https://github.com/scipy/scipy/blob/main/.cirrus.star
2
3 # The guide to programming cirrus-ci tasks using starlark is found at
4 # https://cirrus-ci.org/guide/programming-tasks/
5 #
6 # In this simple starlark script we simply check conditions for whether
7 # a CI run should go ahead. If the conditions are met, then we just
8 # return the yaml containing the tasks to be run.
9
10 load("cirrus", "re", "env", "fs", "http")
11
12 BUILD_PATTERN = re.compile(
13 r"\[wheel build(: (?P<build_ref>.+?))?\]"
14 )
15
16 # This may match false postives but it is good enough.
17 # Bad matches will be caught in the python check
18 SEMVER_TAG_PATTERN = re.compile(
19 r"^v\d+\.\d+\.\d+((a|b|rc)\d+)?$"
20 )
21
22 def main(ctx):
23 ######################################################################
24 # Should wheels be built?
25 # Only test on the scipy/scipy repository
26 # Test if the run was triggered by:
27 # - a cron job called "nightly". The cron job is not set in this file,
28 # but on the cirrus-ci repo page
29 # - commit message containing [wheel build]
30 ######################################################################
31 if env.get("CIRRUS_REPO_FULL_NAME") != "has2k1/scikit-misc":
32 return []
33
34 # Obtain commit message for the event. Unfortunately CIRRUS_CHANGE_MESSAGE
35 # only contains the actual commit message on a non-PR trigger event.
36 # For a PR event it contains the PR title and description.
37 SHA = env.get("CIRRUS_CHANGE_IN_REPO")
38 url = "https://api.github.com/repos/has2k1/scikit-misc/git/commits/" + SHA
39 dct = http.get(url).json()
40 message = dct["message"]
41 tag = env.get("CIRRUS_TAG")
42
43 # this configuration runs a single linux_aarch64 + macosx_arm64 run.
44 # there's no need to do this during a wheel run as they automatically build
45 # and test over a wider range of Pythons.
46 if "[skip cirrus]" in message or "[skip ci]" in message:
47 return []
48
49 m = BUILD_PATTERN.search(message)
50 m2 = SEMVER_TAG_PATTERN.match(tag) if tag else None
51 if not m and not m2:
52 return []
53 return fs.read("ci/cirrus_wheels.yml")