From 9b2179899b543e977d40d80a1184610ac234d8e5 Mon Sep 17 00:00:00 2001 From: Spyridon Siarapis <98518357+spiros132@users.noreply.github.com> Date: Thu, 30 Jul 2026 15:17:54 +0200 Subject: [PATCH] feat(workflow): Multiple fixes in one (#160) * fix(workflow): Re-organized the workflow, put the scripts in their own scripts folder * fix(workflow): Fixed so that we have a default SELECT selection in the issue templates * fix(workflow): Added a way to run the issue workflows manually as well * feat(workflow): Added workflow for closing issues with no selected plugin * fix(workflow): Changed so that we only use one file for jobs that only care about the plugin folders * fix(workflows): resolve repository root after script move --------- Co-authored-by: Lemmy --- .../issues-check-for-correct-plugin.yml | 37 ++++++++++++++ .../issues-notify-plugin-authors.yml | 13 +++-- .github/workflows/issues-update-title.yml | 13 +++-- ...update-issue-templates.yml => on-push.yml} | 45 +++++++++++++++-- .../PyGithub-requirement.txt} | 0 .../issues-check-for-correct-plugin.py | 40 +++++++++++++++ .../issues-notify-plugin-authors.py | 0 .../{ => scripts}/issues-update-title.py | 0 .../{ => scripts}/test_validate_plugins.py | 0 .../workflows/{ => scripts}/update-catalog.py | 2 +- .../{ => scripts}/update-issue-templates.py | 4 +- .../{ => scripts}/validate-plugins.py | 2 +- .github/workflows/update-catalog.yml | 49 ------------------- .github/workflows/validate-plugins.yml | 4 +- .gitignore | 2 +- 15 files changed, 144 insertions(+), 67 deletions(-) create mode 100644 .github/workflows/issues-check-for-correct-plugin.yml rename .github/workflows/{update-issue-templates.yml => on-push.yml} (51%) rename .github/workflows/{notify-plugin-authors-requirements.txt => scripts/PyGithub-requirement.txt} (100%) create mode 100644 .github/workflows/scripts/issues-check-for-correct-plugin.py rename .github/workflows/{ => scripts}/issues-notify-plugin-authors.py (100%) rename .github/workflows/{ => scripts}/issues-update-title.py (100%) rename .github/workflows/{ => scripts}/test_validate_plugins.py (100%) rename .github/workflows/{ => scripts}/update-catalog.py (99%) rename .github/workflows/{ => scripts}/update-issue-templates.py (99%) rename .github/workflows/{ => scripts}/validate-plugins.py (99%) delete mode 100644 .github/workflows/update-catalog.yml diff --git a/.github/workflows/issues-check-for-correct-plugin.yml b/.github/workflows/issues-check-for-correct-plugin.yml new file mode 100644 index 0000000..deb4183 --- /dev/null +++ b/.github/workflows/issues-check-for-correct-plugin.yml @@ -0,0 +1,37 @@ +name: Check for the correct plugin format in issues + +on: + issues: + types: [opened] + workflow_dispatch: + inputs: + issue-number: + required: true + type: number + +permissions: + contents: read + issues: write + +jobs: + check-for-correct-plugin: + runs-on: ubuntu-latest + if: github.repository == 'noctalia-dev/community-plugins' + steps: + - uses: actions/checkout@v7 + - uses: actions/setup-python@v7 + with: + python-version: '3.14' + cache: 'pip' + cache-dependency-path: | + .github/workflows/scripts/PyGithub-requirement.txt + + - name: Install dependencies + run: pip install -r .github/workflows/scripts/PyGithub-requirement.txt + + - name: Notify Authors + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + REPOSITORY: ${{ github.repository }} + ISSUE_NUMBER: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.issue-number || github.event.issue.number }} + run: python3 .github/workflows/scripts/issues-check-for-correct-plugin.py diff --git a/.github/workflows/issues-notify-plugin-authors.yml b/.github/workflows/issues-notify-plugin-authors.yml index 65bc06c..dab7c62 100644 --- a/.github/workflows/issues-notify-plugin-authors.yml +++ b/.github/workflows/issues-notify-plugin-authors.yml @@ -3,6 +3,11 @@ name: Notify Plugin Authors for Issues on: issues: types: [opened] + workflow_dispatch: + inputs: + issue-number: + required: true + type: number permissions: contents: read @@ -19,14 +24,14 @@ jobs: python-version: '3.14' cache: 'pip' cache-dependency-path: | - .github/workflows/notify-plugin-authors-requirements.txt + .github/workflows/scripts/PyGithub-requirement.txt - name: Install dependencies - run: pip install -r .github/workflows/notify-plugin-authors-requirements.txt + run: pip install -r .github/workflows/scripts/PyGithub-requirement.txt - name: Notify Authors env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} REPOSITORY: ${{ github.repository }} - ISSUE_NUMBER: ${{ github.event.issue.number }} - run: python3 .github/workflows/issues-notify-plugin-authors.py + ISSUE_NUMBER: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.issue-number || github.event.issue.number }} + run: python3 .github/workflows/scripts/issues-notify-plugin-authors.py diff --git a/.github/workflows/issues-update-title.yml b/.github/workflows/issues-update-title.yml index c4a175b..5c8d60a 100644 --- a/.github/workflows/issues-update-title.yml +++ b/.github/workflows/issues-update-title.yml @@ -3,6 +3,11 @@ name: Update title of issue to represent the plugin on: issues: types: [opened] + workflow_dispatch: + inputs: + issue-number: + required: true + type: number permissions: contents: read @@ -19,15 +24,15 @@ jobs: python-version: '3.14' cache: 'pip' cache-dependency-path: | - .github/workflows/notify-plugin-authors-requirements.txt + .github/workflows/scripts/PyGithub-requirement.txt - name: Install dependencies - run: pip install -r .github/workflows/notify-plugin-authors-requirements.txt + run: pip install -r .github/workflows/scripts/PyGithub-requirement.txt - name: Update Issue Title env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} REPOSITORY: ${{ github.repository }} - ISSUE_NUMBER: ${{ github.event.issue.number }} - run: python3 .github/workflows/issues-update-title.py + ISSUE_NUMBER: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.issue-number || github.event.issue.number }} + run: python3 .github/workflows/scripts/issues-update-title.py diff --git a/.github/workflows/update-issue-templates.yml b/.github/workflows/on-push.yml similarity index 51% rename from .github/workflows/update-issue-templates.yml rename to .github/workflows/on-push.yml index 71b441c..f7515cc 100644 --- a/.github/workflows/update-issue-templates.yml +++ b/.github/workflows/on-push.yml @@ -1,18 +1,56 @@ -name: Update Issue Templates +name: Jobs to run on push to main on: push: branches: - main paths-ignore: + - catalog.toml - '.**' + - README.md + - README_TEMPLATE.md workflow_dispatch: concurrency: - group: update-issue-templates-${{ github.ref }} + group: on-push-${{ github.ref }} cancel-in-progress: true jobs: + update-catalog: + runs-on: ubuntu-latest + permissions: + contents: write + if: ${{ github.repository == 'noctalia-dev/community-plugins' }} + steps: + - name: Checkout repository + uses: actions/checkout@v7 + with: + fetch-depth: 0 + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Rebuild catalog + run: python3 .github/workflows/scripts/update-catalog.py + + - name: Check for changes + id: check_changes + run: | + git add catalog.toml + if git diff --cached --quiet catalog.toml; then + echo "changed=false" >> "$GITHUB_OUTPUT" + echo "No changes to catalog.toml" + else + echo "changed=true" >> "$GITHUB_OUTPUT" + echo "Changes detected in catalog.toml" + fi + + - name: Commit and push changes + if: steps.check_changes.outputs.changed == 'true' + run: | + git config --local user.email "github-actions[bot]@users.noreply.github.com" + git config --local user.name "github-actions[bot]" + git commit -m "chore: update plugin catalog [skip ci]" + git push + update-issue-templates: runs-on: ubuntu-latest permissions: @@ -26,13 +64,12 @@ jobs: token: ${{ secrets.GITHUB_TOKEN }} - name: Update Issue Templates - run: python3 .github/workflows/update-issue-templates.py + run: python3 .github/workflows/scripts/update-issue-templates.py - name: Check for changes id: check_changes run: | git add .github/ISSUE_TEMPLATE/bug_report.yml .github/ISSUE_TEMPLATE/feature_request.yml - if git diff --quiet --cached -- .github/ISSUE_TEMPLATE/bug_report.yml && git diff --quiet --cached -- .github/ISSUE_TEMPLATE/feature_request.yml; then echo "changed=false" >> "$GITHUB_OUTPUT" echo "No changes found in the issue templates!" diff --git a/.github/workflows/notify-plugin-authors-requirements.txt b/.github/workflows/scripts/PyGithub-requirement.txt similarity index 100% rename from .github/workflows/notify-plugin-authors-requirements.txt rename to .github/workflows/scripts/PyGithub-requirement.txt diff --git a/.github/workflows/scripts/issues-check-for-correct-plugin.py b/.github/workflows/scripts/issues-check-for-correct-plugin.py new file mode 100644 index 0000000..4175960 --- /dev/null +++ b/.github/workflows/scripts/issues-check-for-correct-plugin.py @@ -0,0 +1,40 @@ +import os +import sys + +from github import Auth, Github + +token = os.environ["GITHUB_TOKEN"] +repo_name = os.environ["REPOSITORY"] +issue_number = os.environ["ISSUE_NUMBER"] + +auth = Auth.Token(token) +gh = Github(auth=auth) +repo = gh.get_repo(repo_name) + +if issue_number.isdigit(): + issue_number = int(issue_number) +else: + print("Issue number is not numeric!") + sys.exit(1) + + +issue = repo.get_issue(issue_number) +body = issue.body +lines = body.splitlines() + +try: + title_index = lines.index("### Plugin") +except ValueError: + print("No Plugin title found!") + sys.exit(0) + + +for i in range(title_index + 1, len(lines)): + if lines[i]: + break + +plugin = lines[i].strip() + +if "--- SELECT ---" in plugin: + issue.create_comment("Specify which plugin this issue is about!") + issue.edit(state='closed', state_reason='null') diff --git a/.github/workflows/issues-notify-plugin-authors.py b/.github/workflows/scripts/issues-notify-plugin-authors.py similarity index 100% rename from .github/workflows/issues-notify-plugin-authors.py rename to .github/workflows/scripts/issues-notify-plugin-authors.py diff --git a/.github/workflows/issues-update-title.py b/.github/workflows/scripts/issues-update-title.py similarity index 100% rename from .github/workflows/issues-update-title.py rename to .github/workflows/scripts/issues-update-title.py diff --git a/.github/workflows/test_validate_plugins.py b/.github/workflows/scripts/test_validate_plugins.py similarity index 100% rename from .github/workflows/test_validate_plugins.py rename to .github/workflows/scripts/test_validate_plugins.py diff --git a/.github/workflows/update-catalog.py b/.github/workflows/scripts/update-catalog.py similarity index 99% rename from .github/workflows/update-catalog.py rename to .github/workflows/scripts/update-catalog.py index 6fdccac..80a1b33 100644 --- a/.github/workflows/update-catalog.py +++ b/.github/workflows/scripts/update-catalog.py @@ -9,7 +9,7 @@ import tomllib from pathlib import Path -ROOT_DIR = Path(__file__).resolve().parents[2] +ROOT_DIR = Path(__file__).resolve().parents[3] CATALOG_PATH = ROOT_DIR / "catalog.toml" REQUIRED_FIELDS = ("id", "name", "version", "author", "plugin_api", "tags") OPTIONAL_STRING_FIELDS = ("license", "icon", "description") diff --git a/.github/workflows/update-issue-templates.py b/.github/workflows/scripts/update-issue-templates.py similarity index 99% rename from .github/workflows/update-issue-templates.py rename to .github/workflows/scripts/update-issue-templates.py index 67b88a9..e4b15b3 100644 --- a/.github/workflows/update-issue-templates.py +++ b/.github/workflows/scripts/update-issue-templates.py @@ -11,9 +11,11 @@ def build_dropdown_component(plugins: list[str]) -> str: attributes: label: Plugin description: The plugin id. + default: 0 options: + - --- SELECT --- { -"\n".join([f"""\ +"".join([f"""\ - {plugin} """ for plugin in plugins]) } diff --git a/.github/workflows/validate-plugins.py b/.github/workflows/scripts/validate-plugins.py similarity index 99% rename from .github/workflows/validate-plugins.py rename to .github/workflows/scripts/validate-plugins.py index 901a13b..56ea927 100644 --- a/.github/workflows/validate-plugins.py +++ b/.github/workflows/scripts/validate-plugins.py @@ -12,7 +12,7 @@ from pathlib import Path from typing import Any -DEFAULT_ROOT = Path(__file__).resolve().parents[2] +DEFAULT_ROOT = Path(__file__).resolve().parents[3] SEMVER_RE = re.compile(r"^\d+\.\d+\.\d+$") LAUNCHER_PREFIX_RE = re.compile(r"^[a-z]+$") DESCRIPTION_MAX_CHARS = 120 diff --git a/.github/workflows/update-catalog.yml b/.github/workflows/update-catalog.yml deleted file mode 100644 index 7f336d9..0000000 --- a/.github/workflows/update-catalog.yml +++ /dev/null @@ -1,49 +0,0 @@ -name: Update Plugin Catalog - -on: - push: - branches: - - main - paths-ignore: - - catalog.toml - workflow_dispatch: - -concurrency: - group: update-plugin-catalog-${{ github.ref }} - cancel-in-progress: true - -jobs: - update-catalog: - runs-on: ubuntu-latest - permissions: - contents: write - if: ${{ github.repository == 'noctalia-dev/community-plugins' }} - steps: - - name: Checkout repository - uses: actions/checkout@v7 - with: - fetch-depth: 0 - token: ${{ secrets.GITHUB_TOKEN }} - - - name: Rebuild catalog - run: python3 .github/workflows/update-catalog.py - - - name: Check for changes - id: check_changes - run: | - git add catalog.toml - if git diff --cached --quiet catalog.toml; then - echo "changed=false" >> "$GITHUB_OUTPUT" - echo "No changes to catalog.toml" - else - echo "changed=true" >> "$GITHUB_OUTPUT" - echo "Changes detected in catalog.toml" - fi - - - name: Commit and push changes - if: steps.check_changes.outputs.changed == 'true' - run: | - git config --local user.email "github-actions[bot]@users.noreply.github.com" - git config --local user.name "github-actions[bot]" - git commit -m "chore: update plugin catalog [skip ci]" - git push diff --git a/.github/workflows/validate-plugins.yml b/.github/workflows/validate-plugins.yml index ee3e3e3..34e8087 100644 --- a/.github/workflows/validate-plugins.yml +++ b/.github/workflows/validate-plugins.yml @@ -22,7 +22,7 @@ jobs: uses: actions/checkout@v7 - name: Validate plugin manifests - run: python3 .github/workflows/validate-plugins.py + run: python3 .github/workflows/scripts/validate-plugins.py - name: Test plugin validator - run: python3 -m unittest discover -s .github/workflows -p 'test_*.py' + run: python3 -m unittest discover -s .github/workflows/scripts -p 'test_*.py' diff --git a/.gitignore b/.gitignore index fc11c03..3ab180f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ # Editor type definitions, fetched from official-plugins (see README). /noctalia.d.luau -/.github/workflows/__pycache__ +/.github/workflows/scripts/__pycache__