diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 26c74ac..9e7107d 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -3,12 +3,29 @@ name: Build
on:
push:
branches: [main, develop]
+ paths:
+ - 'Jellyfin.Plugin.ContentFilter/**'
+ - 'Jellyfin.Plugin.ContentFilter.Tests/**'
+ - '.github/workflows/build.yml'
pull_request:
- branches: [main]
+ branches: [main, develop]
+ paths:
+ - 'Jellyfin.Plugin.ContentFilter/**'
+ - 'Jellyfin.Plugin.ContentFilter.Tests/**'
+ - '.github/workflows/build.yml'
+ workflow_dispatch:
+
+concurrency:
+ group: build-${{ github.ref }}
+ cancel-in-progress: true
+
+permissions:
+ contents: read
jobs:
build:
runs-on: ubuntu-latest
+ timeout-minutes: 20
steps:
- uses: actions/checkout@v4
@@ -16,27 +33,34 @@ jobs:
uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.0.x'
+ cache: true
+ cache-dependency-path: |
+ Jellyfin.Plugin.ContentFilter/Jellyfin.Plugin.ContentFilter.csproj
+ Jellyfin.Plugin.ContentFilter.Tests/Jellyfin.Plugin.ContentFilter.Tests.csproj
- name: Restore dependencies
- run: dotnet restore
+ run: dotnet restore Jellyfin.Plugin.ContentFilter.Tests/Jellyfin.Plugin.ContentFilter.Tests.csproj
- name: Build
- run: dotnet build --no-restore --configuration Release
+ run: dotnet build Jellyfin.Plugin.ContentFilter.Tests/Jellyfin.Plugin.ContentFilter.Tests.csproj --no-restore --configuration Release
- name: Run tests
- run: dotnet test --no-build --configuration Release --logger "trx;LogFileName=test-results.trx"
+ run: dotnet test Jellyfin.Plugin.ContentFilter.Tests/Jellyfin.Plugin.ContentFilter.Tests.csproj --no-build --configuration Release --logger "trx;LogFileName=test-results.trx" --results-directory TestResults
- name: Upload test results
uses: actions/upload-artifact@v4
if: always()
with:
name: test-results
- path: '**/*.trx'
+ path: TestResults/**/*.trx
+ if-no-files-found: warn
retention-days: 7
- name: Upload build artifacts
uses: actions/upload-artifact@v4
+ if: success()
with:
name: plugin-build
- path: '**/bin/Release/net9.0/'
+ path: Jellyfin.Plugin.ContentFilter/bin/Release/net9.0/
+ if-no-files-found: error
retention-days: 7
diff --git a/.github/workflows/init-pages.yml b/.github/workflows/init-pages.yml
index 3053eb0..d3da796 100644
--- a/.github/workflows/init-pages.yml
+++ b/.github/workflows/init-pages.yml
@@ -3,22 +3,32 @@ name: Initialize gh-pages
on:
workflow_dispatch:
+concurrency:
+ group: init-gh-pages
+ cancel-in-progress: false
+
jobs:
init:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- - name: Create gh-pages branch
+ - name: Create or refresh gh-pages branch
run: |
git clone https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }} repo
cd repo
- git checkout --orphan gh-pages
- git rm -rf .
+
+ if git ls-remote --heads origin gh-pages | grep -q gh-pages; then
+ git checkout gh-pages
+ else
+ git checkout --orphan gh-pages
+ git rm -rf .
+ fi
+
echo '[]' > repository.json
echo '
PureFin Plugin Repository
Add this URL to Jellyfin: https://BarbellDwarf.github.io/PureFin-Plugin/repository.json
' > index.html
git add repository.json index.html
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- git commit -m "Initialize gh-pages"
+ git diff --staged --quiet || git commit -m "Initialize gh-pages"
git push origin gh-pages
diff --git a/.github/workflows/lint-workflows.yml b/.github/workflows/lint-workflows.yml
new file mode 100644
index 0000000..8bf9476
--- /dev/null
+++ b/.github/workflows/lint-workflows.yml
@@ -0,0 +1,29 @@
+name: Lint Workflows
+
+on:
+ push:
+ branches: [main, develop]
+ paths:
+ - '.github/workflows/**'
+ pull_request:
+ branches: [main, develop]
+ paths:
+ - '.github/workflows/**'
+ workflow_dispatch:
+
+concurrency:
+ group: lint-workflows-${{ github.ref }}
+ cancel-in-progress: true
+
+permissions:
+ contents: read
+
+jobs:
+ actionlint:
+ runs-on: ubuntu-latest
+ timeout-minutes: 10
+ steps:
+ - uses: actions/checkout@v4
+
+ - name: Lint GitHub Actions workflows
+ uses: reviewdog/action-actionlint@v1
\ No newline at end of file
diff --git a/.github/workflows/release-ai-services.yml b/.github/workflows/release-ai-services.yml
index 80c47e1..7650667 100644
--- a/.github/workflows/release-ai-services.yml
+++ b/.github/workflows/release-ai-services.yml
@@ -6,6 +6,11 @@ on:
paths:
- 'ai-services/**'
- '.github/workflows/release-ai-services.yml'
+ workflow_dispatch:
+
+concurrency:
+ group: release-ai-services-main
+ cancel-in-progress: false
permissions:
contents: write
@@ -13,6 +18,7 @@ permissions:
jobs:
release-ai-services:
runs-on: ubuntu-latest
+ timeout-minutes: 30
steps:
- name: Checkout
@@ -52,6 +58,7 @@ jobs:
SERVICES=""
if [[ "${SHARED_CHANGED}" == "true" ]]; then
for service_dir in ai-services/services/*; do
+ [[ -d "${service_dir}" ]] || continue
service_name="$(basename "${service_dir}")"
SERVICES="${SERVICES} ${service_name}"
done
@@ -61,7 +68,7 @@ jobs:
done
fi
- SERVICES="$(echo "${SERVICES}" | xargs || true)"
+ SERVICES="$(echo "${SERVICES}" | tr ' ' '\n' | sed '/^$/d' | sort -u | xargs || true)"
if [[ -z "${SERVICES}" ]]; then
echo "should_release=false" >> "$GITHUB_OUTPUT"
echo "services=" >> "$GITHUB_OUTPUT"
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 1ae8226..983fed4 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -12,14 +12,35 @@ concurrency:
jobs:
release:
runs-on: ubuntu-latest
+ timeout-minutes: 30
permissions:
contents: write
- pages: write
- id-token: write
steps:
- uses: actions/checkout@v4
+ - name: Ensure gh-pages branch exists
+ shell: bash
+ run: |
+ set -euo pipefail
+
+ if git ls-remote --heads origin gh-pages | grep -q gh-pages; then
+ echo "gh-pages branch already exists."
+ exit 0
+ fi
+
+ git clone "https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}" repo
+ cd repo
+ git checkout --orphan gh-pages
+ git rm -rf .
+ echo '[]' > repository.json
+ echo 'PureFin Plugin Repository
Add this URL to Jellyfin: https://BarbellDwarf.github.io/PureFin-Plugin/repository.json
' > index.html
+ git add repository.json index.html
+ git config user.name "github-actions[bot]"
+ git config user.email "github-actions[bot]@users.noreply.github.com"
+ git commit -m "Initialize gh-pages"
+ git push origin gh-pages
+
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
diff --git a/.github/workflows/test-ai-services.yml b/.github/workflows/test-ai-services.yml
index 31f1534..df9ad45 100644
--- a/.github/workflows/test-ai-services.yml
+++ b/.github/workflows/test-ai-services.yml
@@ -5,14 +5,25 @@ on:
branches: [main, develop]
paths:
- 'ai-services/**'
+ - '.github/workflows/test-ai-services.yml'
pull_request:
- branches: [main]
+ branches: [main, develop]
paths:
- 'ai-services/**'
+ - '.github/workflows/test-ai-services.yml'
+ workflow_dispatch:
+
+concurrency:
+ group: test-ai-services-${{ github.ref }}
+ cancel-in-progress: true
+
+permissions:
+ contents: read
jobs:
test:
runs-on: ubuntu-latest
+ timeout-minutes: 20
steps:
- uses: actions/checkout@v4
@@ -20,16 +31,19 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: '3.11'
+ cache: pip
+ cache-dependency-path: ai-services/tests/requirements-test.txt
- name: Install test dependencies
- run: pip install -r ai-services/tests/requirements-test.txt
+ run: |
+ python -m pip install --upgrade pip
+ pip install -r ai-services/tests/requirements-test.txt
- name: Run tests
run: pytest ai-services/tests/ -v --tb=short
- name: Validate Python syntax
run: |
- python -m py_compile ai-services/services/nsfw-detector/app.py
- python -m py_compile ai-services/services/content-classifier/app.py
- python -m py_compile ai-services/services/scene-analyzer/app.py
+ python -m compileall ai-services/services -q
+ python -m compileall ai-services/scripts -q
echo "All Python files syntax OK"