Skip to content

Commit

Permalink
Merge pull request #1072 from conda-forge/fs-outputs
Browse files Browse the repository at this point in the history
feat: add request to add a feedstock output
  • Loading branch information
beckermr authored Sep 6, 2024
2 parents f92c679 + 6df45de commit 53af56b
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 3 deletions.
6 changes: 5 additions & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Hi!
Thank you for making an admin request on this repo. We strive to make a decision
on these requests within 24 hours.
on these requests within 24 hours.
Please use the text below to add context about this PR, especially if:
- You want to mark packages as broken
Expand Down Expand Up @@ -53,6 +53,10 @@ What will happen when a package is marked broken?
* [ ] Posted a link to the conda artifacts
* [ ] Posted a link to the build logs

* [ ] I want to add a package output to a feedstock:
* [ ] Pinged the relevant feedstock team(s)
* [ ] Added a small description of why the output is being added.

<!--
For example if you are trying to mark a `foo` conda package as broken.
Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ submit a PR adding your feedstock name to a new `.yml` file in `requests` folder
Available opt-in resources:

- Travis CI: See `examples/example-travis.yml`
- [`open-gpu-server`](https://github.com/Quansight/open-gpu-server) (includes GPU CI and long-running builds): See `examples/example-open-gpu-server.yml`.
- [`open-gpu-server`](https://github.com/Quansight/open-gpu-server) (includes GPU CI and long-running builds): See `examples/example-open-gpu-server.yml`.

## Request a CFEP-3 copy to conda-forge

Expand All @@ -72,3 +72,9 @@ This workflow allows users to request a copy once the manual review has been pas
To do so, please create a new `.yml` file in the `requests` folder. Check `examples/example-cfep-3.yml` for the required metadata.

For provenance and transparency, the PR description must include a link to the original PR and the logs, along with the artifact(s) to be reviewed.

## Add a package output to a feedstock

By default, `conda-forge` feedstocks cannot push packages to our channel that another feedstock makes. If you need to move a package
build from one feedstock to another, you should request the output be added to the new feedstock via this repository. An example request
is located in [examples/example-add-feedstock-output.yml](examples/example-add-feedstock-output.yml). Make a PR putting your `.yml` request file in the `requests` directory and the `conda-forge/core` team will review it.
3 changes: 2 additions & 1 deletion conda_forge_admin_requests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import importlib
import pkgutil
from . import archive_feedstock, mark_broken, token_reset, access_control, cfep3_copy
from . import archive_feedstock, mark_broken, token_reset, access_control, cfep3_copy, feedstock_outputs

actions = {}

Expand All @@ -22,6 +22,7 @@ def register_actions():
register_action("travis", access_control)
register_action("cirun", access_control)
register_action("cfep3_copy", cfep3_copy)
register_action("add_feedstock_output", feedstock_outputs)
for pkg in pkgutil.iter_modules():
if pkg.name.startswith("conda_forge_admin_requests_"):
spec = importlib.util.find_spec(pkg.name)
Expand Down
80 changes: 80 additions & 0 deletions conda_forge_admin_requests/feedstock_outputs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import json
import os
import requests

from conda_forge_metadata.feedstock_outputs import sharded_path as _get_sharded_path
import github


def _add_feedstock_output(
feedstock,
pkg_name,
):
gh_token = os.environ['GITHUB_TOKEN']
gh = github.Github(auth=github.Auth.Token(gh_token))
repo = gh.get_repo("conda-forge/feedstock-outputs")
try:
contents = repo.get_contents(_get_sharded_path(pkg_name))
except github.UnknownObjectException:
contents = None

if contents is None:
data = {"feedstocks": [feedstock]}
repo.create_file(
_get_sharded_path(pkg_name),
f"[cf admin skip] ***NO_CI*** add output {pkg_name} for conda-forge/{feedstock}-feedstock",
json.dumps(data),
)
print(f" output {pkg_name} added for feedstock conda-forge/{feedstock}-feedstock", flush=True)
else:
data = json.loads(contents.decoded_content.decode("utf-8"))
if feedstock not in data["feedstocks"]:
data["feedstocks"].append(feedstock)
repo.update_file(
contents.path,
f"[cf admin skip] ***NO_CI*** add output {pkg_name} for conda-forge/{feedstock}-feedstock",
json.dumps(data),
contents.sha,
)
print(f" output {pkg_name} added for feedstock conda-forge/{feedstock}-feedstock", flush=True)
else:
print(f" output {pkg_name} already exists for feedstock conda-forge/{feedstock}-feedstock", flush=True)


def check(request):
action = request["action"]
assert action == "add_feedstock_output"

assert request.get("feedstock_to_output_mapping")
for req in request["feedstock_to_output_mapping"]:
for feedstock, _ in req.items():
if feedstock.endswith("-feedstock"):
feedstock = feedstock[:-10]

r = requests.head(
f"https://github.com/conda-forge/{feedstock}-feedstock"
)
r.raise_for_status()


def run(request):
action = request["action"]
assert action == "add_feedstock_output"

assert request.get("feedstock_to_output_mapping")
items_to_keep = []
for req in request["feedstock_to_output_mapping"]:
for feedstock, pkg_name in req.items():
try:
if feedstock.endswith("-feedstock"):
feedstock = feedstock[:-10]
_add_feedstock_output(feedstock, pkg_name)
except Exception as e:
print(f" could not add output {pkg_name} for feedstock conda-forge/{feedstock}-feedstock: {e}", flush=True)
items_to_keep.append({feedstock: pkg_name})

if items_to_keep:
request["feedstock_to_output_mapping"] = items_to_keep
return request
else:
return None
1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ dependencies:
- pydantic
- cirun
- conda-smithy >=3.30.1
- conda-forge-metadata
3 changes: 3 additions & 0 deletions examples/example-add-feedstock-output.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
action: add_feedstock_output
feedstock_to_output_mapping:
- clang-compiler-activation: clang_impl_osx-64

0 comments on commit 53af56b

Please sign in to comment.