Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial Drone support #1069

Merged
merged 14 commits into from
May 24, 2019
2 changes: 1 addition & 1 deletion conda_smithy/cli.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ def __init__(self, parser):
default="conda-forge",
help="github organisation under which to register this repo",
)
for ci in ["Azure", "Travis", "Circle", "Appveyor"]:
for ci in ["Azure", "Travis", "Circle", "Appveyor", "Drone"]:
scp.add_argument(
"--without-{}".format(ci.lower()),
dest=ci.lower(),
Expand Down
64 changes: 61 additions & 3 deletions conda_smithy/configure_feedstock.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -973,7 +973,6 @@ def render_appveyor(jinja_env, forge_config, forge_dir):


def _azure_specific_setup(jinja_env, forge_config, forge_dir, platform):
# TODO:
platform_templates = {
"linux": [
"azure-pipelines-linux.yml.tmpl",
Expand Down Expand Up @@ -1029,6 +1028,59 @@ def render_azure(jinja_env, forge_config, forge_dir):
)


def _drone_specific_setup(jinja_env, forge_config, forge_dir, platform):
platform_templates = {
"linux": [
"build_steps.sh.tmpl",
],
"osx": [],
"win": [],
}
template_files = platform_templates.get(platform, [])

# Explicitly add in a newline character to ensure that jinja templating doesn't do something stupid
build_setup = "run_conda_forge_build_setup\n"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use _get_build_setup_line here?


if platform == "linux":
yum_build_setup = generate_yum_requirements(forge_dir)
if yum_build_setup:
forge_config['yum_build_setup'] = yum_build_setup

forge_config["build_setup"] = build_setup

_render_template_exe_files(
forge_config=forge_config,
target_dir=os.path.join(forge_dir, ".drone"),
jinja_env=jinja_env,
template_files=template_files,
)


def render_drone(jinja_env, forge_config, forge_dir):
target_path = os.path.join(forge_dir, ".drone.yml")
template_filename = "drone.yml.tmpl"
fast_finish_text = ""

# TODO: for now just get this ignoring other pieces
platforms, archs, keep_noarchs, upload_packages = _get_platforms_of_provider(
"drone", forge_config
)

return _render_ci_provider(
"drone",
jinja_env=jinja_env,
forge_config=forge_config,
forge_dir=forge_dir,
platforms=platforms,
archs=archs,
fast_finish_text=fast_finish_text,
platform_target_path=target_path,
platform_template_file=template_filename,
platform_specific_setup=_drone_specific_setup,
keep_noarchs=keep_noarchs,
upload_packages=upload_packages,
)

def render_README(jinja_env, forge_config, forge_dir):
# we only care about the first metadata object for sake of readme
metas = conda_build.api.render(
Expand Down Expand Up @@ -1109,6 +1161,7 @@ def _load_forge_config(forge_dir, exclusive_config_file):
"command": "bash",
},
"templates": {},
"drone": {},
"travis": {},
"circle": {},
"appveyor": {},
Expand Down Expand Up @@ -1220,6 +1273,10 @@ def _load_forge_config(forge_dir, exclusive_config_file):
if config["provider"][platform] == "default":
config["provider"][platform] = "azure"

# TODO: Switch default to Drone
if config["provider"]["linux_aarch64"] in {"native"}:
config["provider"]["linux_aarch64"] = "drone"

if config["provider"]["linux_ppc64le"] in {"native", "default"}:
config["provider"]["linux_ppc64le"] = "travis"

Expand Down Expand Up @@ -1348,7 +1405,7 @@ def main(
check_version_uptodate(r, "conda-smithy", __version__, True)
get_cfp_file_path(r, True)
return True

error_on_warn = False if no_check_uptodate else True
index = conda_build.conda_interface.get_index(channel_urls=["conda-forge"])
r = conda_build.conda_interface.Resolve(index)
Expand All @@ -1370,7 +1427,7 @@ def main(

config = _load_forge_config(forge_dir, exclusive_config_file)

for each_ci in ["travis", "circle", "appveyor"]:
for each_ci in ["travis", "circle", "appveyor", "drone"]:
if config[each_ci].pop("enabled", None):
warnings.warn(
"It is not allowed to set the `enabled` parameter for `%s`."
Expand All @@ -1396,6 +1453,7 @@ def main(
render_travis(env, config, forge_dir)
render_appveyor(env, config, forge_dir)
render_azure(env, config, forge_dir)
render_drone(env, config, forge_dir)
render_README(env, config, forge_dir)

if os.path.isdir(os.path.join(forge_dir, ".ci_support")):
Expand Down
10 changes: 10 additions & 0 deletions conda_smithy/templates/README.md.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,16 @@ Current build status
</td>
</tr>
{%- endif -%}
{%- if drone.enabled -%}
<tr>
<td>Drone</td>
<td>
<a href="https://cloud.drone.io/{{ github.user_or_org }}/{{ github.repo_name }}">
<img alt="linux" src="{{ shield }}drone/build/{{ github.user_or_org }}/{{ github.branch_name }}.svg?label=Linux">
</a>
</td>
</tr>
{%- endif -%}
{%- if appveyor.enabled -%}
<tr>
<td>Appveyor</td>
Expand Down
10 changes: 5 additions & 5 deletions conda_smithy/templates/build_steps.sh.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@

set -xeuo pipefail
export PYTHONUNBUFFERED=1
export FEEDSTOCK_ROOT=/home/conda/feedstock_root
export RECIPE_ROOT=/home/conda/recipe_root
export CI_SUPPORT=/home/conda/feedstock_root/.ci_support
export FEEDSTOCK_ROOT="${FEEDSTOCK_ROOT:-/home/conda/feedstock_root}"
export RECIPE_ROOT="${RECIPE_ROOT:-/home/conda/recipe_root}"
export CI_SUPPORT="${FEEDSTOCK_ROOT}/.ci_support"
export CONFIG_FILE="${CI_SUPPORT}/${CONFIG}.yaml"

cat >~/.condarc <<CONDARC

conda-build:
root-dir: /home/conda/feedstock_root/build_artifacts
root-dir: ${FEEDSTOCK_ROOT}/build_artifacts

CONDARC

Expand All @@ -39,4 +39,4 @@ if [[ "${UPLOAD_PACKAGES}" != "False" ]]; then
upload_package "${FEEDSTOCK_ROOT}" "${RECIPE_ROOT}" "${CONFIG_FILE}"
fi

touch "/home/conda/feedstock_root/build_artifacts/conda-forge-build-done-${CONFIG}"
touch "${FEEDSTOCK_ROOT}/build_artifacts/conda-forge-build-done-${CONFIG}"
30 changes: 30 additions & 0 deletions conda_smithy/templates/drone.yml.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{% if configs[0] -%}
{%- for config_name, platform, upload, config in configs | sort -%}
---
kind: pipeline
name: {{ config_name }}

platform:
os: linux
arch: arm64

steps:
- name: Install and build
image: {{ config["docker_image"][-1] }}
environment:
CONFIG: {{ config_name }}
UPLOAD_PACKAGES: {{ upload }}
PLATFORM: {{ platform }}
#BINSTAR_TOKEN: ""
{%- if 'linux' in platform %}
commands:
- export FEEDSTOCK_ROOT="$CI_WORKSPACE"
- export RECIPE_ROOT="$FEEDSTOCK_ROOT/recipe"
- export CI=drone
- sed -i '$ichown -R conda:conda "$FEEDSTOCK_ROOT"' /opt/docker/bin/entrypoint
- /opt/docker/bin/entrypoint $FEEDSTOCK_ROOT/.drone/build_steps.sh
- echo "Done building"
{%- endif %}

{% endfor %}
{%- endif %}
29 changes: 29 additions & 0 deletions news/drone.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
**Added:**

* Added native aarch64 support for builds using Drone.io. This can be enabled by
either using `provider: {linux_aarch64: drone}` or `provider: {linux_aarch64:
native}` in the conda-forge.yml.

Currently, drone has to be enabled manually as there is no automatic CI
registration for repos.

**Changed:**

* <news item>

**Deprecated:**

* <news item>

**Removed:**

* <news item>

**Fixed:**

* <news item>

**Security:**

* <news item>