Skip to content

Commit

Permalink
Use recipe/conda_build_config.yaml for labels for more fine-grained c…
Browse files Browse the repository at this point in the history
…ontrol
  • Loading branch information
isuruf committed Oct 20, 2023
1 parent 4c4c898 commit 98eb99c
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 26 deletions.
64 changes: 42 additions & 22 deletions conda_smithy/configure_feedstock.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ def _collapse_subpackage_variants(
"channel_targets",
"docker_image",
"build_number_decrement",
"github_actions_labels",
# The following keys are required for some of our aarch64 builds
# Added in https://github.com/conda-forge/conda-forge-pinning-feedstock/pull/180
"cdt_arch",
Expand Down Expand Up @@ -1285,10 +1286,6 @@ def _github_actions_specific_setup(
"os": "ubuntu",
"self_hosted_labels": ("linux", "ARM64"),
},
"linux-ppc64le": {
"os": "ubuntu",
"self_hosted_labels": ("linux", ""),
},
"win-64": {
"os": "windows",
"self_hosted_labels": ("windows", "x64"),
Expand All @@ -1307,14 +1304,34 @@ def _github_actions_specific_setup(
# This avoid potential collisions with other CI providers :crossed_fingers:
data["gha_os"] = runs_on[data["build_platform"]]["os"]
data["gha_with_gpu"] = False

self_hosted_default = list(
runs_on[data["build_platform"]]["self_hosted_labels"]
)
self_hosted_default += ["self-hosted"]
hosted_default = [data["gha_os"] + "-latest"]

labels_default = (
["hosted"]
if forge_config["github_actions"]["self_hosted"]
else ["self-hosted"]
)
labels = list(
data["config"].get("github_actions_labels", labels_default)
)

if len(labels) == 1 and labels[0] == "hosted":
labels = hosted_default
elif len(labels) == 1 and labels[0] in "self-hosted":
labels = self_hosted_default
else:
# Prepend the required ones
labels += self_hosted_default

if forge_config["github_actions"]["self_hosted"]:
data["gha_runs_on"] = [
"self-hosted",
# default, per-platform labels
*runs_on[data["build_platform"]]["self_hosted_labels"],
]
data["gha_runs_on"] = []
# labels provided in conda-forge.yml
for label in forge_config["github_actions"]["self_hosted_labels"]:
for label in labels:
if label.startswith("cirun-"):
label += (
"--${{ github.run_id }}-" + data["short_config_name"]
Expand All @@ -1323,7 +1340,7 @@ def _github_actions_specific_setup(
data["gha_with_gpu"] = True
data["gha_runs_on"].append(label)
else:
data["gha_runs_on"] = data["gha_os"] + "-latest"
data["gha_runs_on"] = hosted_default

build_setup = _get_build_setup_line(forge_dir, platform, forge_config)

Expand Down Expand Up @@ -1380,13 +1397,6 @@ def render_github_actions(

logger.debug("github platforms retrieved")

if forge_config["github_actions"]["self_hosted"]:
forge_config["github_actions"]["triggers"] = forge_config[
"github_actions"
]["self_hosted_triggers"]
else:
forge_config["github_actions"]["triggers"] = ["push", "pull_request"]

remove_file_or_dir(target_path)
return _render_ci_provider(
"github_actions",
Expand Down Expand Up @@ -1904,10 +1914,9 @@ def _load_forge_config(forge_dir, exclusive_config_file, forge_yml=None):
},
"github_actions": {
"self_hosted": False,
"self_hosted_labels": [],
"self_hosted_triggers": ["push"],
"self_hosted_timeout_minutes": 360,
"cancel_in_progress": False,
"triggers": "default",
"timeout_minutes": 360,
"cancel_in_progress": "default",
# Set maximum parallel jobs
"max_parallel": None,
# Toggle creating artifacts for conda build_artifacts dir
Expand Down Expand Up @@ -2065,6 +2074,17 @@ def _load_forge_config(forge_dir, exclusive_config_file, forge_yml=None):
if config["test"] is None:
config["test"] = "all"

if config["github_actions"]["cancel_in_progress"] == "default":
config["github_actions"]["cancel_in_progress"] = config[
"github_actions"
]["self_hosted"]

if config["github_actions"]["triggers"] == "default":
self_hosted = config["github_actions"]["self_hosted"]
config["github_actions"]["triggers"] = (
["push"] if self_hosted else ["push", "pull_request"]
)

# An older conda-smithy used to have some files which should no longer exist,
# remove those now.
old_files = [
Expand Down
6 changes: 2 additions & 4 deletions conda_smithy/templates/github-actions.yml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
name: Build conda package
on: {{ github_actions.triggers }}

{%- if github_actions.cancel_in_progress or github_actions.self_hosted %}
{%- if github_actions.cancel_in_progress %}
concurrency:
group: {% raw %}${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}{% endraw %}
cancel-in-progress: true
Expand All @@ -23,9 +23,7 @@ jobs:
build:
name: {% raw %}${{ matrix.CONFIG }}{% endraw %}
runs-on: {% raw %}${{ matrix.runs_on }}{% endraw %}
{%- if github_actions.self_hosted and github_actions.self_hosted_timeout_minutes %}
timeout-minutes: {{ github_actions.self_hosted_timeout_minutes }}
{%- endif %}
timeout-minutes: {{ github_actions.timeout_minutes }}
strategy:
fail-fast: false
{%- if github_actions.max_parallel %}
Expand Down

0 comments on commit 98eb99c

Please sign in to comment.