Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 61 additions & 44 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
name: CI

# WORD OF CAUTION:
# TO anyone modifying this
# Things will break if you modify this
# without understanding how it works

# A simple flow of this file:
# Apply AutoPEP8 → Apply Plugin Metadata → CRITICAL COMMIT (format + plugin meta)
# ← ← ← ← ← ↵
# ↪ Apply Version Metadata → Commit (version meta) → Tests

on:
push:
branches:
Expand All @@ -9,48 +19,55 @@ on:
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.12"]
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.head_ref }}
fetch-depth: 0

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install Dependencies
run: |
python -m pip install -U pip
python -m pip install -U pycodestyle==2.12.1 autopep8
python -m pip install -U -r test/pip_reqs.txt

- name: Apply AutoPEP8
run: |
autopep8 --in-place --recursive --max-line-length=100 .

- name: Commit AutoPEP8
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "[ci] auto-format"
branch: ${{ github.head_ref }}

- name: Apply Version Metadata
run: |
python test/auto_apply_version_metadata.py $(git log --pretty=format:'%h' -n 1)

- name: Commit Version Metadata
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "[ci] apply-version-metadata"
branch: ${{ github.head_ref }}

- name: Execute Tests
run: |
python -m unittest discover -v
- uses: actions/checkout@v6
with:
token: ${{ secrets.GITHUB_TOKEN }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.head_ref }}
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.12"

- name: Install Dependencies
run: |
python -m pip install -U pip
python -m pip install -U pycodestyle==2.12.1 autopep8
python -m pip install -U -r test/pip_reqs.txt

- name: Apply AutoPEP8
run: |
autopep8 --in-place --recursive --max-line-length=100 .

- name: Apply Plugin Metadata
if: github.event_name == 'pull_request_target'
env:
GH_TOKEN: ${{ github.token }}
run: |
CHANGED_FILES=$(gh api "repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/files" --jq '.[].filename')
python test/auto_apply_plugin_metadata.py "$CHANGED_FILES"

# This is a CRITICAL COMMIT for the next step
# which bases this as the commit to get the sha to store in index.json or plugin.json
- name: Commit Plugin Metadata and AutoPEP8
uses: stefanzweifel/git-auto-commit-action@v7
with:
commit_message: "[ci] apply-plugin-metadata-and-formatting"
branch: ${{ github.head_ref }}

- name: Apply Version Metadata
run: |
python test/auto_apply_version_metadata.py $(git log --pretty=format:'%h' -n 1)

- name: Commit Version Metadata
uses: stefanzweifel/git-auto-commit-action@v7
with:
commit_message: "[ci] apply-version-metadata"
branch: ${{ github.head_ref }}

- name: Execute Tests
run: |
python -m unittest discover -v
10 changes: 5 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ jobs:
name: Create Release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v5
uses: actions/setup-python@v6
with:
python-version: '3.12'

Expand All @@ -27,14 +27,14 @@ jobs:

- name: set_variables
run: |
output1=$(python3 test/get_latest.py get_latest_version)
output1=$(python3 test/get_latest.py get_latest_plugman_version)
{
echo "changelog<<EOF"
python3 test/get_changes.py "$(python3 test/get_latest.py get_latest_version)"
python3 test/get_changelog.py "$(python3 test/get_latest.py get_latest_version)"
echo EOF
} >> "$GITHUB_OUTPUT"
output2=$(python3 test/get_latest.py get_latest_api)
output3=$(python3 test/version_is_lower.py ${{ steps.previoustag.outputs.tag }})
output3=$(python3 test/versioning_tools.py ${{ steps.previoustag.outputs.tag }})
echo "latestVersion=$output1" >> $GITHUB_OUTPUT
echo "latestAPI=$output2" >> $GITHUB_OUTPUT
echo "shouldRun=$output3" >> $GITHUB_OUTPUT
Expand Down
90 changes: 25 additions & 65 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,17 @@ Let's say you wanna submit this new utility-type plugin named as `sample_plugin.
# ba_meta require api 9
import babase

plugman = dict(
plugin_name="sample_plugin",
description="A test plugin for demonstration purposes blah blah.",
external_url="https://www.youtube.com/watch?v=dQw4w9WgXcQ",
authors=[
{"name": "Loup", "email": "loupg450@gmail.com", "discord": "loupgarou_"},
{"name": "brostos", "email": "", "discord": "brostos"}
],
version="1.0.0",
)

# ba_meta export babase.Plugin
class Main(babase.Plugin):
def on_app_running(self):
Expand All @@ -107,49 +118,13 @@ class Main(babase.Plugin):
```

You'll have to fork this repository and add your `sample_plugin.py` plugin file into the appropriate directory, which for
utility plugin is [plugins/utilities](plugins/utilities). After that, you'll have to add an entry for your plugin
in [plugins/utilities.json](plugins/utilities.json) so that it gets picked up by the Plugin Manager in-game.

To do this, you'll have to edit the file and add something like this:
```json
{
"name": "Utilities",
...
"plugins": {
...
"sample_plugin": {
"description": "Shows screenmessages!",
"external_url": "",
"authors": [
{
"name": "Alex",
"email": "alex@example.com",
"discord": null
}
],
"versions": {
"1.0.0": null
}
},
...
}
...
}
```
You can add whatever you wanna add to these fields. However, leave the value for your version key as `null`:
```json
"1.0.0": null
```
Version values will automatically be populated through github-actions (along with formatting your code as per PEP8 style
utility plugin is [plugins/utilities](plugins/utilities). After that, plugin details and version values will automatically be populated through github-actions in [plugins/utilities.json](plugins/utilities.json)(along with formatting your code as per PEP8 style
guide) once you open a pull request.

Save `utilities.json` with your modified changes and now you can create a [pull request](../../compare) with the
plugin you've added and the modified JSON metadata file!

### Updating a Plugin

- Make a [pull request](../../compare) with whatever changes you'd like to make to an existing plugin, and add a new
version entry in your plugin category's JSON metadata file.
version number in your plugin in the plugman dict.

#### Example

Expand All @@ -160,39 +135,24 @@ diff --git a/plugins/utilities/sample_plugin.py b/plugins/utilities/sample_plugi
index ebb7dcc..da2b312 100644
--- a/plugins/utilities/sample_plugin.py
+++ b/plugins/utilities/sample_plugin.py
@@ -5,6 +5,7 @@ import babase
class Main(babase.Plugin):
def on_app_running(self):
babase.screenmessage("Hi! I am a sample plugin!")

def has_settings_ui(self):
@@ -9,7 +9,7 @@
{"name": "Loup", "email": "loupg450@gmail.com", "discord": "loupgarou_"},
{"name": "brostos", "email": "", "discord": "brostos"}
],
- version="1.0.0",
+ version="1.1.0",
)

# ba_meta export babase.Plugin
@@ -21,4 +21,4 @@
return True

def show_settings_ui(self, source_widget):
- babase.screenmessage("You tapped my settings!")
+ babase.screenmessage("Hey! This is my new screenmessage!")
```

To name this new version as `1.1.0`, add `"1.1.0": null,` just above the previous plugin version in `utilities.json`:
```diff
diff --git a/plugins/utilities.json b/plugins/utilities.json
index d3fd5bc..34ce9ad 100644
--- a/plugins/utilities.json
+++ b/plugins/utilities.json
@@ -14,7 +14,10 @@
}
],
"versions": {
- "1.0.0": null
+ "1.1.0": null,
+ "1.0.0": {
+ ...
+ }
}
},
...
```
That's it! Now you can make a [pull request](../../compare) with both the updated `sample_plugin.py` and `utilities.json` files.
That's it! Now you can make a [pull request](../../compare) with the updated `sample_plugin.py` file.

## 3rd Party Plugin Sources

Expand Down
Loading