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
20 changes: 14 additions & 6 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,33 @@
version: 2
updates:
# Update Python packages

- package-ecosystem: "uv"
target-branch: "main"
directory: "/"
schedule:
interval: "weekly"
open-pull-requests-limit: 10


- package-ecosystem: "pip"
target-branch: "develop"
target-branch: "main"
directory: "/"
schedule:
interval: "weekly"
open-pull-requests-limit: 10

# Update GitHub Actions

- package-ecosystem: "github-actions"
directory: "/"
target-branch: "develop"
target-branch: "main"
schedule:
interval: "weekly"
open-pull-requests-limit: 10

# Update Docker base images

- package-ecosystem: "docker"
directory: "/"
target-branch: "develop"
target-branch: "main"
schedule:
interval: "weekly"
open-pull-requests-limit: 10
116 changes: 93 additions & 23 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,104 @@
name: Lint
name: checks
on:
pull_request:
branches: ["main"]
workflow_dispatch:

permissions: {}

jobs:
lint:
setup:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: "Set up Python"
uses: actions/setup-python@v6
with:
python-version-file: "pyproject.toml"
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
version: 0.8.*
- name: Install dependencies
run: uv sync --locked
- name: Cache dependencies
uses: actions/cache/save@v4
with:
path: |
.venv
~/.cache/uv
key: ${{ runner.os }}-uv-${{ hashFiles('uv.lock') }}

permissions:
contents: read
packages: read
statuses: write
lint:
runs-on: ubuntu-latest
needs: setup
steps:
- uses: actions/checkout@v5
- name: "Set up Python"
uses: actions/setup-python@v6
with:
python-version-file: "pyproject.toml"
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
version: 0.8.*
- name: Restore dependencies
uses: actions/cache/restore@v4
with:
path: |
.venv
~/.cache/uv
key: ${{ runner.os }}-uv-${{ hashFiles('uv.lock') }}
fail-on-cache-miss: true
- name: Run linting
run: |
uv run ruff check

typecheck:
runs-on: ubuntu-latest
needs: setup
steps:
- uses: actions/checkout@v5
- name: "Set up Python"
uses: actions/setup-python@v6
with:
python-version-file: "pyproject.toml"
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
version: 0.8.*
- name: Restore dependencies
uses: actions/cache/restore@v4
with:
path: |
.venv
~/.cache/uv
key: ${{ runner.os }}-uv-${{ hashFiles('uv.lock') }}
fail-on-cache-miss: true
- name: Run type checking
run: uv run ty check
vulture:
runs-on: ubuntu-latest
needs: setup
steps:
- name: Checkout Code
uses: actions/checkout@v4
- uses: actions/checkout@v5
- name: "Set up Python"
uses: actions/setup-python@v6
with:
python-version-file: "pyproject.toml"
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
version: 0.8.*
- name: Restore dependencies
uses: actions/cache/restore@v4
with:
fetch-depth: 0
path: |
.venv
~/.cache/uv
key: ${{ runner.os }}-uv-${{ hashFiles('uv.lock') }}
fail-on-cache-miss: true
- name: Run vulture
run: uv run vulture --min-confidence 100 --exclude ".venv" .

- name: Lint Code Base
uses: github/super-linter@v7
env:
VALIDATE_ALL_CODEBASE: true
FIX_PYTHON_RUFF: true
VALIDATE_PYTHON_RUFF: true
FIX_MARKDOWN_PRETTIER: true
VALIDATE_MARKDOWN_PRETTIER: true
VALIDATE_GITLEAKS: true
VALIDATE_GITHUB_ACTIONS: true
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.13
9 changes: 5 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM python:3.12-slim
FROM ghcr.io/astral-sh/uv:0.9.16-trixie-slim


ENV PYTHONUNBUFFERED=1
ENV GITHUB_TOKEN=""
Expand All @@ -22,15 +23,15 @@ RUN apt-get update && apt-get install -y cron && rm -rf /var/lib/apt/lists/*

COPY . .

RUN pip install --no-cache-dir -r requirements.txt
RUN /usr/local/bin/uv sync --locked

# Create a cron job file
RUN echo '#!/bin/sh' > /app/cron_job.sh && \
echo 'set -a' >> /app/cron_job.sh && \
echo '. /app/.env' >> /app/cron_job.sh && \
echo 'set +a' >> /app/cron_job.sh && \
echo 'if [ -n "$COLLECTION_ID" ]; then' >> /app/cron_job.sh && \
echo ' /usr/local/bin/python /app/starwarden.py -id "$COLLECTION_ID" >> /app/starwarden.log 2>&1' >> /app/cron_job.sh && \
echo ' /app/.venv/bin/python -m starwarden.main -id "$COLLECTION_ID" >> /app/starwarden.log 2>&1' >> /app/cron_job.sh && \
echo 'else' >> /app/cron_job.sh && \
echo ' echo "Error: COLLECTION_ID is not set" >> /app/starwarden.log' >> /app/cron_job.sh && \
echo 'fi' >> /app/cron_job.sh && \
Expand All @@ -48,7 +49,7 @@ RUN echo '#!/bin/sh' > /app/start.sh && \
echo 'crontab /etc/cron.d/starwarden-cron' >> /app/start.sh && \
echo 'cron' >> /app/start.sh && \
echo 'if [ -n "$COLLECTION_ID" ]; then' >> /app/start.sh && \
echo ' /usr/local/bin/python /app/starwarden.py -id "$COLLECTION_ID"' >> /app/start.sh && \
echo ' /app/.venv/bin/python -m starwarden.main -id "$COLLECTION_ID"' >> /app/start.sh && \
echo 'else' >> /app/start.sh && \
echo ' echo "Error: COLLECTION_ID is not set"' >> /app/start.sh && \
echo 'fi' >> /app/start.sh && \
Expand Down
15 changes: 0 additions & 15 deletions docker-compose.build.yml

This file was deleted.

1 change: 0 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
version: "3"
services:
starwarden:
image: rtuszik/starwarden:latest
Expand Down
80 changes: 80 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
[project]
name = "starwarden"
version = "1.4.1"
description = "Sync GitHub Stars to Linkwarden"
readme = "README.md"
requires-python = ">=3.13"
dependencies = [
"apprise==1.9.3",
"pygithub==2.6.1",
"python-dotenv==1.1.1",
"requests==2.32.4",
"rich==14.0.0",
"tqdm==4.67.1",
]

[dependency-groups]
dev = ["bandit>=1.8.6", "ruff>=0.12.12", "ty>=0.0.1a20", "vulture>=2.14"]

[build-system]
requires = ["uv_build>=0.9.16"]
build-backend = "uv_build"

[tool.uv.build-backend]
module-name = "starwarden"
module-root = ""

[tool.ruff]
indent-width = 4
line-length = 120


[tool.ruff.lint]
ignore = [
"ANN", # flake8-annotations
"COM", # flake8-commas
"C90", # mccabe complexity
"DJ", # django
"EXE", # flake8-executable
"BLE", # blind except
"PTH", # flake8-pathlib
"T10", # debugger
"TID", # flake8-tidy-imports
"D100",
"D101",
"D102",
"D103",
"D104",
"D105",
"D106",
"D107",
"D101",
"D107", # missing docstring in public module
"D102", # missing docstring in public class
"D104", # missing docstring in public package
"D213",
"D203",
"D400",
"D415",
"G004",
"PLR2004",
"E501", # line too long
"TRY",
"SIM105", # faster without contextlib
]

extend-select = ["B", "S", "SIM", "T20", "C901"]


fixable = ["ALL"]
unfixable = []

# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"

[tool.ruff.format]
quote-style = "double"
indent-style = "space"
line-ending = "auto"

docstring-code-format = false
6 changes: 0 additions & 6 deletions renovate.json

This file was deleted.

6 changes: 0 additions & 6 deletions requirements.txt

This file was deleted.

14 changes: 4 additions & 10 deletions starwarden/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,14 @@

from dotenv import load_dotenv

from .utils.logger import get_logger
from starwarden.utils.logger import get_logger

logger = get_logger()


def parse_args():
parser = argparse.ArgumentParser(
description="Export GitHub starred repositories as individual links to Linkwarden"
)
parser.add_argument(
"-id", type=int, help="Specify the collection ID to sync"
)
parser = argparse.ArgumentParser(description="Export GitHub starred repositories as individual links to Linkwarden")
parser.add_argument("-id", type=int, help="Specify the collection ID to sync")
parser.add_argument(
"-d",
"--debug",
Expand All @@ -39,13 +35,11 @@ def load_env():
"opt_tag_username": os.getenv("OPT_TAG_USERNAME", "false").lower() in ("true", "1"),
"opt_tag_custom": os.getenv("OPT_TAG_CUSTOM", ""),
"APPRISE_URLS": os.getenv("APPRISE_URLS"),
"DOCKERIZED": os.getenv("DOCKERIZED", "false").lower() in ("true", "1")

"DOCKERIZED": os.getenv("DOCKERIZED", "false").lower() in ("true", "1"),
}

if not all([config["github_username"], config["linkwarden_url"], config["linkwarden_token"]]):
logger.error("Missing required environment variables. Please check your .env file.")
sys.exit(1)

return config

Loading