Skip to content

Commit 2fd3818

Browse files
authored
Merge branch 'OctoPrint:gh-pages' into gh-pages
2 parents 825b07a + 08c7215 commit 2fd3818

172 files changed

Lines changed: 1563 additions & 927 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/ISSUE_TEMPLATE.md

Lines changed: 0 additions & 9 deletions
This file was deleted.

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<!--
2+
Thank you for your interest in registering a plugin on the official
3+
OctoPrint Plugin Repository!
4+
5+
Before you continue, please ensure & check the following things (to check, turn '[ ]' into '[x]'):
6+
-->
7+
8+
- [ ] You have read the ["Registering a new Plugin"](https://plugins.octoprint.org/help/registering/) guide.
9+
- [ ] You want to and are able to maintain the plugin you are registering, long-term.
10+
- [ ] You understand why the plugin you are registering works.
11+
- [ ] You have read and acknowledge the [Code of Conduct](https://octoprint.org/conduct/).
12+
13+
<!--
14+
Please answer the following questions:
15+
-->
16+
17+
#### What is the name of your plugin?
18+
19+
<!-- put your answer after this line -->
20+
21+
#### What does your plugin do?
22+
23+
<!-- put your answer after this line -->
24+
25+
#### Where can we find the source code of your plugin?
26+
27+
<!-- put your answer after this line -->
28+
29+
#### Was any kind of genAI (ChatGPT, Copilot etc) involved in creating this plugin?
30+
31+
<!-- put your answer after this line -->
32+
33+
#### Is your plugin commercial in nature?
34+
35+
<!-- put your answer after this line -->
36+
37+
#### Does your plugin rely on some cloud services?
38+
39+
<!-- put your answer after this line -->
40+
41+
<!--
42+
If you want to add anything else, you can do so here
43+
-->
44+
45+
#### Further notes
46+
47+
<!--
48+
If you are not actually registering a plugin but just want to make changes to one you already
49+
registered in the past, just delete this template and explain your PR yourself.
50+
-->

.github/scripts/populate_additional_metadata.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,11 @@ def out(line, prefix="", *args, **kwargs):
433433
out("Processing plugin {} at path {}".format(plugin_id, path))
434434

435435
if incl_stats:
436-
if "commercial" not in data.get("attributes", []):
436+
attributes = data.get("attributes", [])
437+
if attributes is None:
438+
attributes = []
439+
440+
if "commercial" not in attributes:
437441
def build_stats(stats):
438442
result = dict(
439443
instances=stats.get("instances", 0),

.github/scripts/requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@ requests
22
python-frontmatter
33
colorama
44
voluptuous
5-
click
5+
click!=8.2.0
66
ruamel.yaml<0.18
7+
packaging

.github/scripts/validate_front_matter.py

Lines changed: 56 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,25 @@
77
import click
88
import colorama
99
import frontmatter
10-
import pkg_resources
10+
from packaging.specifiers import SpecifierSet
1111
from voluptuous import All, Any, Invalid, Length, Optional, Required, Schema, Url
1212

1313
OCTOPRINT_PY3_SUPPORT = ("3.7", "3.8", "3.9", "3.10", "3.11", "3.12")
1414

1515
NonEmptyString = All(str, Length(min=1))
1616

17+
class ValidationError(ValueError):
18+
def __init__(self, *args, error_messages=None):
19+
super().__init__(*args)
20+
self.error_messages = error_messages
21+
1722

1823
def to_requirement(compat, name="Foo"):
1924
if not any(
2025
compat.startswith(c) for c in ("<", "<=", "!=", "==", ">=", ">", "~=", "===")
2126
):
2227
compat = ">={}".format(compat)
23-
return pkg_resources.Requirement.parse(name + compat)
28+
return SpecifierSet(compat)
2429

2530

2631
def Version(v):
@@ -88,7 +93,7 @@ def ImageLocation(v):
8893
Optional("disabled"): NonEmptyString,
8994
Optional("abandoned"): NonEmptyString,
9095
Optional("up_for_adoption"): Url(),
91-
Optional("redirect_from"): NonEmptyString,
96+
Optional("redirect_from"): Any(All([NonEmptyString]), NonEmptyString),
9297
Optional("attributes"): Any(list, None),
9398
}
9499
)
@@ -128,7 +133,7 @@ def check_url(url):
128133
# image url is a path
129134
image_path = os.path.abspath(os.path.join(src, url[1:]))
130135
if not os.path.exists(image_path):
131-
raise Invalid(
136+
raise ValidationError(
132137
"image location '{}' doesn't exist on disk ({})".format(
133138
url, image_path
134139
)
@@ -144,7 +149,7 @@ def check_url(url):
144149
return []
145150

146151

147-
def validate_image_urls(data, path):
152+
def validate_internal_assets(data, path):
148153
warnings = []
149154

150155
filename = os.path.basename(path)[:-3]
@@ -183,24 +188,50 @@ def validate_id_match(data, path):
183188
filename = os.path.basename(path)[:-3]
184189
if data["id"] != filename:
185190
return [
186-
"id '{}' does not match file name '{}.md' @ data['id']".format(
191+
"id '{}' does not match file name '{}.md', please rename the file @ data['id']".format(
187192
data["id"], filename
188193
)
189194
]
190195
return []
191196

192197

198+
def validate_asset_match(data, path):
199+
errors = []
200+
201+
filename = os.path.basename(path)[:-3]
202+
203+
def check_url(loc, url):
204+
if url.startswith("/assets/img/plugins/") and not url.startswith("/assets/img/plugins/{}".format(filename)):
205+
folder = url.split("/")[4]
206+
message = "asset folder of image '{}' does not match plugin identifier {}: {} @ {}".format(url, filename, folder, loc)
207+
errors.append(message)
208+
209+
if "screenshots" in data:
210+
count = 0
211+
for entry in data["screenshots"]:
212+
check_url("data['screenshots'][{}]['url']".format(count), entry["url"])
213+
count += 1
214+
215+
if "featuredimage" in data:
216+
check_url("data['featuredimage']", data["featuredimage"])
217+
218+
if errors:
219+
raise ValidationError("plugin references assets in mismatched asset folder", error_messages=errors)
220+
221+
return []
222+
223+
193224
def validate_python_compatibility(data):
194225
warnings = []
195226

196227
if "compatibility" in data and "python" in data["compatibility"]:
197228
requirement = to_requirement(data["compatibility"]["python"], name="Python")
198229
if all(map(lambda x: x not in requirement, OCTOPRINT_PY3_SUPPORT)):
199-
raise ValueError(
230+
raise ValidationError(
200231
"python compatibility does not include Python 3 @ data['compatibility']['python']"
201232
)
202233
else:
203-
raise ValueError("not flagged as Python 3 compatible @ data")
234+
raise ValidationError("not flagged as Python 3 compatible @ data")
204235
return warnings
205236

206237

@@ -215,13 +246,13 @@ def validate_date_unchanged(data, path, src, sha, debug=False):
215246
try:
216247
output = subprocess.check_output(command, encoding="utf-8")
217248
if not output:
218-
raise ValueError("could not read prior version")
249+
raise ValidationError("could not read prior version")
219250
except subprocess.CalledProcessError:
220251
return
221252

222253
old_metadata, old_content = frontmatter.parse(output)
223254
if data["date"] != old_metadata.get("date"):
224-
raise ValueError(
255+
raise ValidationError(
225256
"date must not be changed after initial registration @ data['date']"
226257
)
227258

@@ -232,6 +263,7 @@ def validate(
232263
src,
233264
path,
234265
id_match=False,
266+
asset_match=False,
235267
internal_assets=False,
236268
date_unchanged=False,
237269
screenshots_present=False,
@@ -250,8 +282,11 @@ def validate(
250282
if id_match:
251283
warnings += validate_id_match(metadata, path)
252284

285+
if asset_match:
286+
warnings += validate_asset_match(metadata, path)
287+
253288
if internal_assets:
254-
warnings += validate_image_urls(metadata, path)
289+
warnings += validate_internal_assets(metadata, path)
255290

256291
if screenshots_present:
257292
warnings += validate_screenshots_present(metadata)
@@ -274,6 +309,7 @@ def validate(
274309
@click.option("--debug", is_flag=True)
275310
@click.option("--src", "src")
276311
@click.option("--check-id-match", "id_match", is_flag=True)
312+
@click.option("--check-asset-match", "asset_match", is_flag=True)
277313
@click.option("--check-internal-assets", "internal_assets", is_flag=True)
278314
@click.option(
279315
"--check-date-unchanged",
@@ -289,6 +325,7 @@ def main(
289325
debug=False,
290326
src=None,
291327
id_match=False,
328+
asset_match=False,
292329
internal_assets=False,
293330
date_unchanged=None,
294331
screenshots_present=False,
@@ -321,6 +358,7 @@ def main(
321358
src,
322359
path,
323360
id_match=id_match,
361+
asset_match=asset_match,
324362
internal_assets=internal_assets,
325363
date_unchanged=date_unchanged,
326364
screenshots_present=screenshots_present,
@@ -331,6 +369,13 @@ def main(
331369
print("{}: ".format(path), end="")
332370
print(colorama.Fore.RED + colorama.Style.BRIGHT + "FAIL")
333371

372+
if isinstance(exc, ValidationError) and exc.error_messages:
373+
for error in exc.error_messages:
374+
if action_output:
375+
print("::error file={}::{}".format(path[len(src) + 1:], error))
376+
else:
377+
print(" " + error)
378+
334379
if action_output:
335380
print("::error file={}::{}".format(path[len(src) + 1 :], str(exc)))
336381
else:

.github/workflows/publish-to-github-pages.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ jobs:
2424
steps:
2525
- uses: actions/checkout@v3
2626

27-
- name: 🐍 Set up Python 3.7
27+
- name: 🐍 Set up Python 3.11
2828
uses: actions/setup-python@v4
2929
with:
30-
python-version: "3.7"
30+
python-version: "3.11"
3131

3232
- name: 🐍 Install requirements
3333
run: |
@@ -40,7 +40,7 @@ jobs:
4040
4141
- name: 🕵️‍♂ Validate front matter
4242
run: |
43-
python .github/scripts/validate_front_matter.py --action-output
43+
python .github/scripts/validate_front_matter.py --check-id-match --check-asset-match --action-output
4444
4545
- name: 🏗 Enrich front matter
4646
if: github.repository == 'OctoPrint/plugins.octoprint.org' && github.event_name != 'pull_request'
@@ -64,7 +64,7 @@ jobs:
6464
- name: 💎 Set up Ruby 3
6565
uses: ruby/setup-ruby@v1
6666
with:
67-
ruby-version: '3.2'
67+
ruby-version: '3.4'
6868
bundler-cache: true
6969

7070
- name: 🔨 Build page
@@ -90,7 +90,7 @@ jobs:
9090
peterdavehello/jsonlint jsonlint -q /json/search.json
9191
9292
- name: ⬆ Upload pages artifact
93-
uses: actions/upload-pages-artifact@v1
93+
uses: actions/upload-pages-artifact@v3
9494
with:
9595
path: ./_site
9696

@@ -123,4 +123,4 @@ jobs:
123123
steps:
124124
- name: Deploy to GitHub Pages
125125
id: deployment
126-
uses: actions/deploy-pages@v1
126+
uses: actions/deploy-pages@v4

.github/workflows/validate-pull-requests.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ jobs:
1818
path: current
1919
ref: gh-pages
2020

21-
- name: 🐍 Set up Python 3.7
21+
- name: 🐍 Set up Python 3.11
2222
uses: actions/setup-python@v4
2323
with:
24-
python-version: "3.7"
24+
python-version: "3.11"
2525

2626
- name: 🐍 Install requirements
2727
run: |
@@ -36,12 +36,13 @@ jobs:
3636
3737
while read modifier file; do
3838
if [[ $file == _plugins/* ]] && [[ $file == *.md ]]; then
39+
args="--debug --check-internal-assets --check-id-match --check-asset-match --check-py3-compat --action-output"
3940
if [ "$modifier" == "M" ]; then
4041
echo "MODIFIED: $file"
41-
python ../current/.github/scripts/validate_front_matter.py "$file" --debug --check-date-unchanged=${{ github.event.pull_request.base.sha }} --action-output
42+
python ../current/.github/scripts/validate_front_matter.py "$file" --check-date-unchanged=${{ github.event.pull_request.base.sha }} $args
4243
elif [ "$modifier" == "A" ]; then
4344
echo "ADDED: $file"
44-
python ../current/.github/scripts/validate_front_matter.py "$file" --debug --check-internal-assets --check-id-match --check-py3-compat --action-output
45+
python ../current/.github/scripts/validate_front_matter.py "$file" $args
4546
fi
4647
fi
4748
done < <(git diff-tree --no-commit-id --name-status -r ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} | xargs -n2 )

Gemfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
source 'https://rubygems.org'
22
gem 'github-pages', group: :jekyll_plugins
3+
4+
# windows
35
gem 'wdm', '>= 0.1.0' if Gem.win_platform?
46
gem 'eventmachine', '1.2.7', git: 'git@github.com:eventmachine/eventmachine', tag: 'v1.2.7' if Gem.win_platform?
57

8+
# linting
69
gem 'html-proofer'
710
gem 'jsonlint'
8-
9-
gem "webrick", "~> 1.7"

0 commit comments

Comments
 (0)