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

Set installability analysis workflow (WIP) #29

Draft
wants to merge 16 commits into
base: main
Choose a base branch
from
37 changes: 37 additions & 0 deletions .github/workflows/installability.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Plugins

on:
schedule:
# Every Monday and Thursday, at 6am
- cron: "0 6 * * 1,4"
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
pull_request:
branches:
- main

jobs:
packages:
name: Installability
runs-on: ubuntu-latest
if: startsWith(github.repository, 'napari')
strategy:
fail-fast: false
matrix:
subdir:
- "linux-64"
- "osx-64"
- "osx-arm64"
- "win-64"

steps:
- uses: actions/checkout@v2
- uses: mamba-org/provision-with-micromamba@main
with:
environment-file: environments/installability.yml
- name: Run script
shell: bash -el {0}
env:
CONDA_SUBDIR: ${{ matrix.subdir }}
run: python ci_scripts/check_installability_plugins.py
jaimergp marked this conversation as resolved.
Show resolved Hide resolved

79 changes: 79 additions & 0 deletions ci_scripts/check_installability_plugins.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#!/usr/bin/env python

"""
Check if all Hub-listed plugins can be installed together with latest napari
"""

import json
from subprocess import CalledProcessError, check_output, STDOUT

import requests

NPE2API_CONDA = "https://npe2api.vercel.app/api/conda"


def check_output_verbose(*args, **kwargs):
"""
Check return code of a subprocess, capturing stdout and stderr.
If an error happened, print both streams, then raise.
"""
kwargs.pop("stderr", None)
kwargs.pop("text", None)
kwargs.pop("universal_newlines", None)
try:
return check_output(*args, stderr=STDOUT, text=True, **kwargs)
except CalledProcessError as exc:
print("Output:")
print(exc.stdout)
raise


def latest_napari_on_conda_forge():
r = requests.get("https://api.anaconda.org/package/conda-forge/napari")
r.raise_for_status()
return r.json()["latest_version"]


def all_plugin_names():
r = requests.get(NPE2API_CONDA)
r.raise_for_status()
return r.json()


def is_latest_version(name, version):
r = requests.get(f"{NPE2API_CONDA}/{name}")
r.raise_for_status()
latest_version = r.json()["latest_version"]
return version >= latest_version


def solve(specs):
resp = check_output_verbose(
[
"micromamba",
"create",
"-n",
"notused",
"--dry-run",
"-c",
"conda-forge",
"--json",
*specs,
]
)
print(resp)
jaimergp marked this conversation as resolved.
Show resolved Hide resolved
return json.loads(resp)


def main():
specs = [f"napari={latest_napari_on_conda_forge()}"]
plugin_names = all_plugin_names()
for _, conda_name in plugin_names.items():
if conda_name is not None:
specs.append(conda_name.replace("/", "::"))

result = solve(specs)


if __name__ == "__main__":
main()
7 changes: 7 additions & 0 deletions environments/installability.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: installability
channels:
- conda-forge
dependencies:
- conda
- mamba
- python