Repository: napari/napari

Issue:
Vendored tests failing for darkdetect
## 🧰 Task
There is a new version of [darkdetect](https://github.com/albertosottile/darkdetect) out now causing our vendored test to fail.

There was some discussion around whether to vendor or not in the original PR - see https://github.com/napari/napari/pull/3370#issuecomment-921321704, which lead to the test getting created.

Now that a new version is out, I'm curious should we just update all the files? If so is there an easy tool to do this? Or do we actually want to end up depending on package. I don't mind, I just want to see our tests all passing again :-)

Thoughts @jni @Carreau @goanpeca and anyone else interested?


Discussion:
it would also be nice to have this test on a cron job instead of PRs... not necessary to have PRs fail because our vendored code is behind
> it would also be nice to have this test on a cron job instead of PRs... not necessary to have PRs fail because our vendored code is behind

yeah, that's a good idea too!
@tlambert03  did #3626, 

What we can even do is use https://github.com/marketplace/actions/create-pull-request so that when `tools/check_vendored_modules.py` find changes, it actually send a PR with updates. 

Drawbacks is it will keep sending it until the first one is merge so we may want to use `0 2 * * 1` to only make PRs on monday :-) 
Actually correcting myself:

> The default behaviour of the action is to create a pull request that will be continually updated with new changes until it is merged or closed.

Resolving patch:
diff --git a/tools/check_vendored_modules.py b/tools/check_vendored_modules.py
--- a/tools/check_vendored_modules.py
+++ b/tools/check_vendored_modules.py
@@ -52,10 +52,14 @@ def check_vendored_module(org : str, reponame : str, tag : str) -> str:
 
 
 def main():
+    CI = '--ci' in sys.argv
     print("\n\nChecking vendored modules\n")
     for org, reponame, tag in [("albertosottile", "darkdetect", "master")]:
         print(f"\n * Checking '{org}/{reponame}'\n")
         diff = check_vendored_module(org, reponame, tag)
+        if CI:
+            print("::set-output name=vendored::{org}/{reponame}")
+            sys.exit(0)
         if diff:
             print(diff)
             print(f"\n * '{org}/{reponame}' vendor code seems to not be up to date!!!\n")


Test patch:
diff --git a/.github/workflows/test_vendored.yml b/.github/workflows/test_vendored.yml
--- a/.github/workflows/test_vendored.yml
+++ b/.github/workflows/test_vendored.yml
@@ -16,4 +16,18 @@ jobs:
         with:
           python-version: 3.8
       - name: Run check
-        run: python tools/check_vendored_modules.py
+        id: check_v
+        run: python tools/check_vendored_modules.py --ci
+
+      - name: Create PR updating vendored modules
+          uses: peter-evans/create-pull-request@v3
+          with:
+            commit-message: Update vendored modules.
+            branch: update-vendored-examples
+            delete-branch: true
+            title: "[Automatic] Update ${{ steps.check_v.outputs.vendored }} vendored module"
+            body: |
+              This PR is automatically created and updated by napari GitHub
+              action cron to keep vendored modules up to date.
+
+              It look like ${{ steps.check_v.outputs.vendored }} has a new version.